/* =========================================
   AHKF Scoring System v1.5.16
   Style Sheet
   ========================================= */

:root {
    --primary: #1976d2;
    --secondary: #424242;
    --success: #4caf50;
    --danger: #d32f2f;
    --role-bg: #00897b;
    --bg-light: #f5f5f5;
    --card-bg: #ffffff;
    --border: #e0e0e0;
    --base-size: 18px;
}

body {
    background-color: var(--bg-light);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    margin: 0;
    padding: 0;
    font-size: var(--base-size);
    line-height: 1.6;
    color: #333;
}

/* --- Layout --- */
.ahkf-dashboard, 
#ahkf-app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.card {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    padding: 25px;
    margin-bottom: 25px;
}

/* --- Section Colors --- */
.section-yellow { background-color: #fffde7; border: 1px solid #fff9c4; }
.section-green { background-color: #e8f5e9; border: 1px solid #c8e6c9; }
.assign-box-yellow { background-color: #fff8e1; border-left: 6px solid #ffb300; }

/* --- Typography --- */
h2 { font-size: 1.8rem; margin-bottom: 20px; color: var(--primary); }
h3 { font-size: 1.5rem; margin-bottom: 15px; border-bottom: 2px solid #eee; padding-bottom: 10px; }
h4 { font-size: 1.3rem; margin: 15px 0; font-weight: 600; }
.text-sm { font-size: 0.85rem; color: #666; }
.text-blue { color: var(--primary); }
.text-center { text-align: center; }

/* --- Forms --- */
input[type="text"], input[type="password"], input[type="date"], input[type="number"], select, input[type="file"] {
    width: 100%; padding: 12px 15px; margin: 5px 0 15px 0;
    border: 1px solid #ccc; border-radius: 6px; box-sizing: border-box; font-size: 1.1rem;
}

/* --- Buttons --- */
button {
    cursor: pointer; border: none; border-radius: 6px; padding: 12px 24px;
    font-size: 1.1rem; font-weight: 600; transition: 0.2s;
    background-color: #eee; color: #333;
}
.btn-primary { background-color: var(--primary); color: white; }
.btn-primary:hover { background-color: #1565c0; }
.btn-success { background-color: var(--success); color: white; }
.btn-action { background-color: #ff9800; color: white; }
.btn-small { padding: 8px 16px; font-size: 0.95rem; }
.btn-logout { float: right; background: var(--danger); color: white; padding: 8px 20px; }
.full-width { width: 100%; }
.mt-10 { margin-top: 10px; }
.mt-15 { margin-top: 15px; }
.mb-15 { margin-bottom: 15px; }

/* --- Flex Grid --- */
.form-row { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; margin-bottom: 15px; }
.col { flex: 1; min-width: 200px; }
.flex-2 { flex: 2; }
.align-end { align-items: flex-end; }

/* --- Admin Assign UI --- */
.assign-row {
    background: #fff; padding: 15px; border-bottom: 1px solid #eee;
    display: flex; align-items: flex-start; justify-content: space-between; gap: 15px;
}
.assign-left { flex: 1; display: flex; align-items: center; gap: 10px; font-weight: bold; padding-top: 8px; }
.assign-right { flex: 2; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; }
.role-select-container {
    display: none; background: #fafafa; border: 1px solid #ddd;
    padding: 10px; border-radius: 6px; width: 100%; box-sizing: border-box;
    max-height: 200px; overflow-y: auto;
}
.role-option { display: block; margin-bottom: 6px; font-size: 0.95rem; cursor: pointer; padding: 4px; border-radius: 4px; }
.role-option:hover { background-color: #e3f2fd; }
.role-option input { width: auto !important; margin: 0 8px 0 0 !important; }

/* --- Tables --- */
.table-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.ahkf-table { width: 100%; border-collapse: collapse; min-width: 600px; }
.ahkf-table th, .ahkf-table td { padding: 15px; border-bottom: 1px solid #eee; text-align: left; font-size: 1rem; }
.ahkf-table th { background-color: #f8f9fa; font-weight: bold; color: #555; white-space: nowrap; }

/* Summary Table Specifics */
.summary-table th { background-color: #e8eaf6; color: #1a237e; border-bottom: 2px solid #c5cae9; }
.summary-score { font-weight: bold; color: #2e7d32; font-size: 1.1rem; }

/* --- Tabs --- */
.ahkf-tabs { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.tab-btn { background: #e0e0e0; color: #555; padding: 15px 25px; font-size: 1.1rem; }
.tab-btn.active { background: var(--primary); color: white; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* --- Modal --- */
.ahkf-modal {
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.6); z-index: 9999; justify-content: center; align-items: center;
}
.ahkf-modal.show { display: flex; }
.modal-content {
    background: white; padding: 30px; border-radius: 12px;
    width: 90%; max-width: 600px; max-height: 85vh; overflow-y: auto;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
}
.modal-list-container { margin: 20px 0; max-height: 400px; overflow-y: auto; border: 1px solid #eee; padding: 10px; background: #fafafa; }
.modal-team-item { display: block; padding: 12px; border-bottom: 1px solid #e0e0e0; cursor: pointer; }
.modal-team-item:hover { background: #e3f2fd; }
.modal-actions { text-align: right; margin-top: 20px; display: flex; justify-content: flex-end; gap: 10px; }

/* --- Report Matrix --- */
.report-score-cell { 
    text-align: center; border: 1px solid #eee; padding: 10px; 
    background: #fff; vertical-align: top; font-size: 0.95rem; line-height: 1.5;
}
.report-role-row {
    border-bottom: 1px dashed #eee; padding-bottom: 6px; margin-bottom: 6px; text-align: left;
}
.report-role-row:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.report-role-label {
    display: inline-block; background-color: #e0f2f1; color: #00695c;
    font-size: 0.8rem; padding: 2px 6px; border-radius: 4px; margin-right: 5px; font-weight: bold;
}
.score-main { font-weight: bold; color: #333; font-size: 1.1rem; }
.score-detail { color: #888; font-size: 0.85rem; display: block; margin-top: 2px; }

/* --- Criteria Editor --- */
.criteria-row {
    display: flex; gap: 10px; margin-bottom: 15px;
    background: #fff; padding: 15px; border: 1px solid #ddd;
    border-radius: 8px; align-items: center; flex-wrap: wrap;
}
.c-section-input { width: 100%; margin-bottom: 10px; border: 1px dashed #999; background: #fafafa; font-size: 0.95rem !important; color: #444; }

/* --- App Scoring UI --- */
.info-grid { display: flex; gap: 20px; margin-bottom: 20px; flex-wrap: wrap; }
.info-box { flex: 1; padding: 20px; border-radius: 10px; min-width: 250px; }
.judge-box { background: #e3f2fd; color: #0d47a1; }
.team-box { background: #fff3e0; color: #e65100; }
.info-content { font-size: 1.6rem; font-weight: bold; }
.judge-role-badge {
    display: inline-block; background: #bbdefb; color: #0d47a1;
    padding: 4px 10px; border-radius: 15px; font-size: 0.85rem;
    margin-right: 5px; margin-top: 5px; font-weight: bold;
}

.score-section-header {
    background-color: #37474f; color: #fff;
    padding: 15px 20px; border-radius: 8px;
    margin-top: 30px; margin-bottom: 15px;
    font-size: 1.3rem; font-weight: bold;
    border-left: 5px solid #ffca28;
}

.role-section-divider {
    background-color: var(--role-bg); color: white; padding: 12px 20px;
    border-radius: 8px; margin-top: 30px; margin-bottom: 15px;
    font-size: 1.2rem; font-weight: bold; display: flex; align-items: center;
    box-shadow: 0 3px 6px rgba(0,0,0,0.1); border-left: 6px solid #004d40;
}
.role-header-icon { margin-right: 10px; font-size: 1.4rem; }

/* Member Names Display */
.member-display-box {
    background-color: #e0f7fa; border: 1px solid #b2ebf2; color: #006064;
    padding: 10px 15px; border-radius: 8px; margin-top: 10px;
    font-size: 1.1rem; font-weight: bold; display: flex; align-items: center;
}
.member-icon { margin-right: 8px; font-size: 1.2rem; }

/* Member Editor Modal */
.member-input-row {
    display: flex; align-items: center; margin-bottom: 15px;
    border-bottom: 1px dashed #eee; padding-bottom: 10px;
}
.member-input-label { flex: 1; font-weight: bold; color: #555; }
.member-input-field { flex: 2; }

/* Scoring Card */
.criteria-card {
    background: white; border: 1px solid #ddd; padding: 20px;
    margin-bottom: 25px; border-radius: 10px; box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.criteria-card label {
    display: block; font-size: 1.4rem; font-weight: bold;
    margin-bottom: 5px; color: #222;
}
.criteria-subtitle-display { color: #666; margin-bottom: 12px; font-size: 1rem; }
.scale-container { display: flex; align-items: center; gap: 15px; margin-top: 10px; }
.scale-label { font-size: 0.9rem; color: #757575; font-weight: bold; white-space: nowrap; }
.scale-label.bad { color: #d32f2f; }
.scale-label.good { color: #388e3c; }

.radio-group { display: flex; flex-wrap: wrap; gap: 8px; flex: 1; justify-content: center; }
.radio-box { flex: 1; min-width: 45px; max-width: 80px; text-align: center; position: relative; }
.radio-box input { position: absolute; opacity: 0; }
.radio-box span {
    display: block; padding: 12px 5px; background: #f0f0f0;
    border-radius: 8px; font-size: 1.2rem; font-weight: bold;
    cursor: pointer; transition: 0.2s; border: 2px solid transparent;
}
.radio-box input:checked + span { background: var(--primary); color: white; transform: scale(1.1); }

.total-bar {
    position: sticky; bottom: 0; background: rgba(33,33,33,0.95);
    color: white; padding: 20px; text-align: center;
    font-size: 1.5rem; border-radius: 12px 12px 0 0;
    margin-top: 20px; z-index: 100;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .form-row { flex-direction: column; align-items: stretch; }
    .col { width: 100%; }
    .scale-container { flex-direction: column; }
    .radio-group { justify-content: space-between; }
    .radio-box { min-width: 18%; margin-bottom: 5px; }
    .assign-row { flex-direction: column; align-items: stretch; }
    .assign-right { align-items: stretch; }
}

/* Ranking Table Styles (v1.5.17) */
.ranking-category-block {
    margin-bottom: 30px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
}
.ranking-cat-title {
    background: #fce4ec;
    color: #c2185b;
    margin: 0;
    padding: 12px 20px;
    font-size: 1.2rem;
    font-weight: bold;
    border-bottom: 1px solid #f8bbd0;
}
.ranking-table th {
    background: #fafafa;
    color: #555;
    font-size: 0.95rem;
}
.rank-cell {
    font-weight: bold;
    font-size: 1.2rem;
    color: #1976d2;
}
.status-tie {
    color: #d32f2f;
    font-weight: bold;
    font-size: 0.9rem;
    background: #ffebee;
    padding: 2px 6px;
    border-radius: 4px;
}
.status-ok {
    color: #388e3c;
    font-size: 1.2rem;
}
.row-tie {
    background-color: #fff8e1; /* Highlight tie rows */
}
.manual-rank-input {
    width: 80px;
    text-align: center;
    padding: 5px;
    margin: 0;
    border: 1px solid #ccc;
    border-radius: 4px;
}

/* ... (保留原有樣式) ... */

/* Ranking Table Styles (v1.5.17) */
.ranking-category-block {
    margin-bottom: 30px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
}
.ranking-cat-title {
    background: #fce4ec;
    color: #c2185b;
    margin: 0;
    padding: 12px 20px;
    font-size: 1.2rem;
    font-weight: bold;
    border-bottom: 1px solid #f8bbd0;
}
.ranking-table th {
    background: #fafafa;
    color: #555;
    font-size: 0.95rem;
}
.rank-cell {
    font-weight: bold;
    font-size: 1.2rem;
    color: #1976d2;
}
.status-tie {
    color: #d32f2f;
    font-weight: bold;
    font-size: 0.9rem;
    background: #ffebee;
    padding: 2px 6px;
    border-radius: 4px;
}
.status-ok {
    color: #388e3c;
    font-size: 1.2rem;
}
.row-tie {
    background-color: #fff8e1;
}
.manual-rank-input {
    width: 80px;
    text-align: center;
    padding: 5px;
    margin: 0;
    border: 1px solid #ccc;
    border-radius: 4px;
}

/* Judge Sort Input (v1.5.19) */
.judge-sort-input {
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 4px;
}

/* Sortable Drag Handles (v1.5.20) */
.drag-handle-judge, .drag-handle-team {
    cursor: grab;
    color: #bbb;
    transition: color 0.2s, background-color 0.2s;
    user-select: none;
}
.drag-handle-judge:hover, .drag-handle-team:hover {
    color: #333;
    background-color: #f5f5f5;
}
.drag-handle-judge:active, .drag-handle-team:active {
    cursor: grabbing;
}

/* Sortable Ghost (拖曳時的殘影) */
.sortable-ghost {
    background-color: #e3f2fd !important;
    opacity: 0.8;
    border: 2px dashed #2196f3;
}

/* 確保表格在拖曳時保持形狀 */
#judge-list-body tr, #team-list-tbody tr {
    background: #fff;
    border-bottom: 1px solid #eee;
}

/* Ranking Table Styles */
.ranking-category-block {
    margin-bottom: 30px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
}
.ranking-cat-title {
    background: #fce4ec;
    color: #c2185b;
    margin: 0;
    padding: 12px 20px;
    font-size: 1.2rem;
    font-weight: bold;
    border-bottom: 1px solid #f8bbd0;
}
.ranking-table th {
    background: #fafafa;
    color: #555;
    font-size: 0.95rem;
}
.rank-cell {
    font-weight: bold;
    font-size: 1.2rem;
    color: #1976d2;
}
.status-tie {
    color: #d32f2f;
    font-weight: bold;
    font-size: 0.9rem;
    background: #ffebee;
    padding: 2px 6px;
    border-radius: 4px;
}
.status-ok {
    color: #388e3c;
    font-size: 1.2rem;
}
.row-tie {
    background-color: #fff8e1;
}
.manual-rank-input {
    width: 80px;
    text-align: center;
    padding: 5px;
    margin: 0;
    border: 1px solid #ccc;
    border-radius: 4px;
}

/* AHKF Style v1.5.25 */
body { background: #f0f2f5; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; margin: 0; padding: 20px; color: #333; }
.ahkf-login-container { max-width: 400px; margin: 50px auto; }
.ahkf-dashboard { max-width: 1200px; margin: 0 auto; }
#ahkf-app-container { max-width: 600px; margin: 0 auto; }

/* Cards & Layout */
.card { background: #fff; padding: 20px; border-radius: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.1); margin-bottom: 20px; }
.form-group { margin-bottom: 15px; }
.form-group label { display: block; margin-bottom: 5px; font-weight: 600; }
.full-width { width: 100%; padding: 10px; border: 1px solid #ddd; border-radius: 6px; box-sizing: border-box; }
.form-row { display: flex; gap: 15px; margin-bottom: 15px; }
.col { flex: 1; }
.flex-2 { flex: 2; }
.align-end { align-items: flex-end; }

/* Buttons */
button { cursor: pointer; border: none; border-radius: 6px; font-size: 14px; padding: 8px 16px; transition: 0.2s; }
.btn-primary { background: #1976d2; color: #fff; }
.btn-primary:hover { background: #1565c0; }
.btn-primary:disabled { background: #ccc; }
.btn-action { background: #f57f17; color: #fff; }
.btn-success { background: #2e7d32; color: #fff; }
.btn-logout { background: #d32f2f; color: #fff; padding: 5px 10px; font-size: 12px; }
.btn-small { padding: 4px 8px; font-size: 12px; }

/* Tabs */
.ahkf-tabs { display: flex; gap: 10px; margin-bottom: 20px; overflow-x: auto; padding-bottom: 5px; }
.tab-btn { background: #e0e0e0; color: #333; white-space: nowrap; }
.tab-btn.active { background: #1976d2; color: #fff; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Tables */
.table-container { overflow-x: auto; }
.ahkf-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.ahkf-table th, .ahkf-table td { padding: 10px; border-bottom: 1px solid #eee; text-align: left; }
.ahkf-table th { background: #f8f9fa; font-weight: 600; color: #555; }
.text-center { text-align: center !important; }

/* App Header */
.app-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; background: #fff; padding: 15px; border-radius: 12px; box-shadow: 0 2px 5px rgba(0,0,0,0.05); }
.event-title { font-weight: bold; font-size: 16px; color: #1976d2; }

/* Info Boxes */
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 15px; }
.info-box { background: #fff; padding: 12px; border-radius: 8px; border-left: 4px solid #ccc; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.judge-box { border-left-color: #7b1fa2; }
.team-box { border-left-color: #1976d2; }
.info-label { font-size: 11px; color: #666; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.info-content { font-weight: bold; font-size: 15px; }

/* Criteria Cards */
.criteria-card { background: #fff; border-radius: 8px; padding: 15px; margin-bottom: 15px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); border: 1px solid #eee; }
.criteria-card label { font-weight: 600; display: block; margin-bottom: 8px; font-size: 15px; }
.criteria-subtitle-display { font-size: 12px; color: #666; margin-bottom: 10px; font-style: italic; }
.score-section-header { margin: 25px 0 10px 0; font-weight: bold; color: #1976d2; border-bottom: 2px solid #e3f2fd; padding-bottom: 5px; }
.role-section-divider { background: #e3f2fd; color: #1565c0; padding: 8px 12px; border-radius: 6px; margin: 20px 0 15px 0; font-weight: bold; display: flex; align-items: center; gap: 8px; }

/* Scale & Radio */
.scale-container { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: #f9f9f9; padding: 10px; border-radius: 8px; }
.scale-label { font-size: 10px; color: #888; width: 40px; text-align: center; line-height: 1.2; }
.radio-group { display: flex; flex: 1; justify-content: space-between; }
.radio-box { display: flex; flex-direction: column; align-items: center; cursor: pointer; position: relative; }
.radio-box input { position: absolute; opacity: 0; }
.radio-box span { width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: #fff; border: 1px solid #ccc; font-size: 12px; font-weight: bold; transition: 0.2s; }
.radio-box input:checked + span { background: #1976d2; color: #fff; border-color: #1976d2; transform: scale(1.1); box-shadow: 0 2px 5px rgba(25, 118, 210, 0.3); }

/* Bottom Bar */
.total-bar { position: fixed; bottom: 0; left: 0; right: 0; background: #fff; padding: 15px 20px; box-shadow: 0 -2px 10px rgba(0,0,0,0.1); display: flex; align-items: center; justify-content: space-between; font-size: 18px; font-weight: bold; z-index: 100; max-width: 600px; margin: 0 auto; }
.submit-btn { width: auto !important; margin: 0 !important; padding: 10px 25px; }
#app-score-view { padding-bottom: 80px; }

/* Badges & Status */
.badge { padding: 2px 6px; border-radius: 4px; font-size: 11px; font-weight: bold; }
.role-badge { display: inline-block; padding: 3px 8px; border-radius: 12px; font-size: 11px; margin-right: 5px; margin-bottom: 3px; }
.role-badge.team { background: #e3f2fd; color: #1565c0; }
.role-badge.individual { background: #fff3e0; color: #ef6c00; }
.role-badge.target { background: #e8f5e9; color: #2e7d32; border: 1px solid #c8e6c9; }
.status-tie { color: #d32f2f; font-weight: bold; font-size: 12px; }
.status-ok { color: #2e7d32; }

/* Admin Specific */
.section-yellow { background: #fffde7; border: 1px solid #fff9c4; }
.section-green { background: #e8f5e9; border: 1px solid #c8e6c9; }
.assign-box-yellow { background: #fff9c4; border-left: 5px solid #fbc02d; }
.assign-controls { display: flex; gap: 10px; margin-top: 10px; }
.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; max-height: 400px; overflow-y: auto; }
.assign-row { background: #fff; padding: 10px; border: 1px solid #eee; border-radius: 6px; display: flex; flex-direction: column; gap: 8px; }
.assign-left { display: flex; align-items: center; gap: 10px; font-weight: bold; }
.assign-right { display: flex; flex-direction: column; gap: 5px; padding-left: 25px; }
.role-select-container { background: #f5f5f5; padding: 8px; border-radius: 4px; margin-top: 5px; }
.role-option { display: block; font-size: 13px; margin-bottom: 3px; cursor: pointer; }
.sortable-ghost { opacity: 0.4; background: #e3f2fd; }

/* Modal */
.ahkf-modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 1000; justify-content: center; align-items: center; }
.ahkf-modal.show { display: flex; }
.modal-content { background: #fff; padding: 25px; border-radius: 12px; width: 90%; max-width: 500px; max-height: 80vh; overflow-y: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; padding-top: 15px; border-top: 1px solid #eee; }
.modal-list-container { max-height: 300px; overflow-y: auto; border: 1px solid #eee; padding: 10px; border-radius: 4px; margin: 10px 0; }
.modal-team-item { display: block; padding: 8px; border-bottom: 1px solid #f5f5f5; cursor: pointer; }
.modal-team-item:hover { background: #f9f9f9; }
.member-input-row { display: flex; align-items: center; margin-bottom: 10px; }
.member-input-label { width: 100px; font-weight: bold; font-size: 13px; color: #555; }
.member-input-field { flex: 1; }
.member-name-input { width: 100%; padding: 6px; border: 1px solid #ddd; border-radius: 4px; }
.member-display-box { font-size: 13px; color: #444; margin-top: 4px; background: #f5f5f5; padding: 4px 8px; border-radius: 4px; display: inline-block; margin-right: 5px; }

/* Ranking Table Specific */
.ranking-table th { background: #e3f2fd; color: #1565c0; }
.ranking-table tr.row-tie { background: #fff3e0; }
.rank-cell { font-size: 16px; color: #1976d2; }
.manual-rank-input { width: 40px; text-align: center; padding: 4px; border: 1px solid #ccc; border-radius: 4px; }
