/* ================================
   TITC 2026 - Sistem Kedudukan
   ================================ */
:root {
    --primary: #1a237e;
    --primary-light: #3949ab;
    --secondary: #ffd600;
    --accent: #e53935;
    --success: #2e7d32;
    --warning: #f57f17;
    --danger: #c62828;
    --text: #212121;
    --text-light: #757575;
    --bg: #f5f6fa;
    --card-bg: #ffffff;
    --border: #e0e0e0;
    --radius: 12px;
    --radius-sm: 6px;
    --shadow: 0 4px 20px rgba(0,0,0,0.08);
    --shadow-hover: 0 8px 30px rgba(0,0,0,0.15);
    --font: 'Segoe UI', Arial, sans-serif;
    --transition: all 0.25s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* ====== HERO ====== */
.hero-header {
    background: linear-gradient(135deg, var(--primary) 0%, #283593 50%, #1565c0 100%);
    color: white;
    text-align: center;
    padding: 60px 20px 50px;
    position: relative;
    overflow: hidden;
}

.hero-header::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.03) 0%, transparent 60%);
}

.hero-logo { font-size: 64px; margin-bottom: 12px; filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3)); }
.hero-header h1 { font-size: 3rem; font-weight: 800; letter-spacing: 2px; text-shadow: 0 2px 8px rgba(0,0,0,0.3); }
.hero-header p { font-size: 1.1rem; opacity: 0.85; margin-top: 6px; }
.hero-sub { font-size: 0.95rem; opacity: 0.7; margin-top: 4px; }

.hero-stats {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-top: 28px;
    flex-wrap: wrap;
}

.hero-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.hero-stat-val {
    font-size: 2rem;
    font-weight: 800;
    color: var(--secondary);
    text-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.hero-stat span:last-child {
    font-size: 0.8rem;
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ====== TAB NAV ====== */
.tab-nav {
    background: white;
    border-bottom: 2px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.tab-nav-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    overflow-x: auto;
    scrollbar-width: none;
}

.tab-link {
    padding: 16px 22px;
    text-decoration: none;
    color: var(--text-light);
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    border-bottom: 3px solid transparent;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
}

.tab-link:hover { color: var(--primary); background: #f5f6fa; }
.tab-link.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ====== CONTAINER ====== */
.container { max-width: 1200px; margin: 0 auto; padding: 24px 16px 60px; }

.reveal-banner {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 220px;
    gap: 20px;
    align-items: center;
    background: linear-gradient(135deg, #fff8e1 0%, #ffffff 100%);
    border: 1px solid #ffe082;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px 20px;
    margin-bottom: 20px;
}

.reveal-banner.is-active {
    border-color: #ffca28;
}

.reveal-banner.is-complete {
    background: linear-gradient(135deg, #e8f5e9 0%, #ffffff 100%);
    border-color: #81c784;
}

.reveal-banner.is-pending {
    background: linear-gradient(135deg, #e3f2fd 0%, #ffffff 100%);
    border-color: #90caf9;
}

.reveal-banner strong {
    display: block;
    color: var(--primary);
    margin-bottom: 4px;
}

.reveal-banner p {
    color: var(--text-light);
    margin: 0;
}

.reveal-progress-wrap {
    text-align: right;
}

.reveal-progress-label {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 8px;
}

.reveal-progress-bar {
    height: 10px;
    background: rgba(26, 35, 126, 0.08);
    border-radius: 999px;
    overflow: hidden;
}

.reveal-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--secondary) 0%, var(--primary-light) 100%);
    border-radius: 999px;
}

/* ====== NAVBAR (ADMIN) ====== */
.navbar {
    background: var(--primary);
    padding: 0 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.2);
}

.nav-brand {
    color: white;
    font-size: 18px;
    font-weight: 700;
}

.nav-brand span {
    font-size: 12px;
    opacity: 0.7;
    margin-left: 8px;
    font-weight: 400;
}

.nav-links { display: flex; gap: 12px; align-items: center; }
.nav-links a { color: rgba(255,255,255,0.85); text-decoration: none; font-size: 14px; }
.btn-logout {
    background: rgba(255,255,255,0.15);
    padding: 6px 14px;
    border-radius: 6px;
    transition: var(--transition);
}
.btn-logout:hover { background: rgba(255,255,255,0.25); color: white !important; }

/* ====== CARDS ====== */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 20px;
}

.card-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fafbff;
}

.card-header h2, .card-header h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
}

.card-body { padding: 24px; }

.badge-count {
    background: var(--primary);
    color: white;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-live {
    background: var(--success);
}

.best-participant-card {
    border: 1px solid rgba(26, 35, 126, 0.08);
}

.best-participant-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 20px;
    align-items: center;
}

.best-participant-name {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1.2;
}

.best-participant-school {
    margin-top: 6px;
    color: var(--text);
    font-weight: 600;
}

.best-participant-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
    align-items: center;
}

.best-participant-tag {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    background: #eef2ff;
    color: var(--primary);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.best-participant-scorebox {
    min-width: 140px;
    text-align: center;
    padding: 18px 20px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    box-shadow: 0 10px 24px rgba(26,35,126,0.18);
}

.best-score {
    font-size: 2.2rem;
    font-weight: 800;
    line-height: 1;
    color: var(--secondary);
}

.best-score-label {
    margin-top: 8px;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    opacity: 0.85;
}

.best-participant-breakdown {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
    color: var(--text);
    font-weight: 600;
}

.best-category-section {
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

.best-category-section h3 {
    color: var(--primary);
    font-size: 1rem;
    margin-bottom: 14px;
}

.best-category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
}

.best-category-item {
    background: #f8faff;
    border: 1px solid #e6ebff;
    border-radius: 12px;
    padding: 14px;
}

.best-category-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--primary-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.best-category-name {
    font-weight: 800;
    color: var(--text);
    line-height: 1.3;
}

.best-category-school {
    margin-top: 5px;
    font-size: 0.92rem;
    color: var(--text-light);
}

.best-category-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
}

.best-category-points {
    font-weight: 800;
    color: var(--primary);
    white-space: nowrap;
}

/* ====== FORMS ====== */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 18px;
    padding: 24px;
}

.form-group { display: flex; flex-direction: column; gap: 6px; }

.form-group label {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 10px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: var(--font);
    transition: var(--transition);
    outline: none;
    background: white;
    color: var(--text);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,35,126,0.1);
}

.field-helper {
    font-size: 0.8rem;
    color: var(--text-light);
    line-height: 1.5;
}

.compact-grid {
    padding: 0;
    margin-top: 18px;
}

.reveal-admin-status {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 220px;
    gap: 18px;
    align-items: center;
    padding: 16px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fafbff;
}

.reveal-admin-status strong {
    display: block;
    color: var(--primary);
    margin-bottom: 4px;
}

.reveal-admin-status p {
    color: var(--text-light);
    margin: 0;
}

.reveal-admin-progress span {
    display: block;
    text-align: right;
    color: var(--primary);
    font-size: 1.2rem;
    font-weight: 800;
    margin-bottom: 8px;
}

.form-actions {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 12px;
    background: #fafbff;
}

/* ====== BUTTONS ====== */
.btn {
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
}

.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
.btn:active { transform: translateY(0); }

.btn-primary  { background: var(--primary); color: white; }
.btn-secondary{ background: #e8eaf0; color: var(--text); }
.btn-warning  { background: #ff8f00; color: white; }
.btn-danger   { background: var(--danger); color: white; }
.btn-sm       { padding: 6px 12px; font-size: 12px; }
.btn-full     { width: 100%; justify-content: center; padding: 14px; font-size: 16px; }

/* ====== ALERTS ====== */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 14px;
    border-left: 4px solid;
}

.alert-success { background: #e8f5e9; color: #1b5e20; border-color: #2e7d32; }
.alert-danger  { background: #ffebee; color: #b71c1c; border-color: #c62828; }

/* ====== TABLE ====== */
.table-wrapper { overflow-x: auto; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th {
    padding: 12px 14px;
    background: var(--primary);
    color: white;
    font-weight: 600;
    text-align: left;
    white-space: nowrap;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}

.data-table tbody tr:hover { background: #f5f6fa; }
.data-table tbody tr:last-child td { border-bottom: none; }

.rank-1 td { background: linear-gradient(90deg, rgba(255,215,0,0.1), transparent); }
.rank-2 td { background: linear-gradient(90deg, rgba(192,192,192,0.1), transparent); }
.rank-3 td { background: linear-gradient(90deg, rgba(205,127,50,0.1), transparent); }

.rank-cell { font-size: 20px; text-align: center; }

.kedudukan-table .data-table th { background: #1a237e; }

/* ====== BADGES & TAGS ====== */
.daerah-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    color: white;
    font-size: 12px;
    font-weight: 600;
}

.daerah-info { display: flex; align-items: center; gap: 8px; }
.daerah-dot  { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

.daerah-pill {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    color: white;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}

@media (max-width: 768px) {
    .reveal-banner,
    .reveal-admin-status,
    .best-participant-grid {
        grid-template-columns: 1fr;
    }

    .reveal-progress-wrap,
    .reveal-admin-progress span {
        text-align: left;
    }

    .best-participant-scorebox {
        width: 100%;
    }
}

.tag {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.tag-rendah   { background: #e3f2fd; color: #1565c0; }
.tag-menengah { background: #fce4ec; color: #880e4f; }

.tag-pasukan {
    background: #e8f5e9;
    color: #2e7d32;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
}

.tempat-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.tempat-johan      { background: #fff3cd; color: #856404; border: 2px solid #ffc107; }
.tempat-naib_johan { background: #f8f9fa; color: #495057; border: 2px solid #adb5bd; }
.tempat-ketiga     { background: #fdf3e7; color: #7c5109; border: 2px solid #cd7f32; }

.mata-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 13px;
}

.mata-rendah   { background: #e3f2fd; color: #1565c0; }
.mata-menengah { background: #fce4ec; color: #880e4f; }
.mata-total    { font-size: 22px; font-weight: 800; }

/* ====== PODIUM ====== */
.podium-container {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 16px;
    margin: 30px auto;
    max-width: 700px;
    padding: 0 16px;
}

.podium-item {
    flex: 1;
    max-width: 200px;
    text-align: center;
}

.podium-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 6px;
}

.podium-points {
    font-size: 26px;
    font-weight: 800;
    color: var(--dcolor, var(--primary));
}

.podium-points small { font-size: 13px; font-weight: 400; }

.podium-sub {
    font-size: 11px;
    color: var(--text-light);
    margin-bottom: 8px;
}

.podium-block {
    border-radius: var(--radius) var(--radius) 0 0;
    background: var(--dcolor, var(--primary));
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-weight: 800;
}

.podium-1 .podium-block { height: 130px; }
.podium-2 .podium-block { height: 100px; }
.podium-3 .podium-block { height: 80px; }

.podium-rank { font-size: 18px; }

/* ====== PROGRESS BAR ====== */
.progress-bar {
    height: 12px;
    background: #e0e0e0;
    border-radius: 6px;
    overflow: hidden;
    min-width: 100px;
}

.progress-fill {
    height: 100%;
    border-radius: 6px;
    transition: width 0.6s ease;
}

/* ====== SECTION HEADERS ====== */
.section-header {
    margin: 24px 0 16px;
}

.section-header h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
}

.section-header p {
    font-size: 13px;
    color: var(--text-light);
    margin-top: 4px;
}

/* ====== PERTANDINGAN GRID ====== */
.pertandingan-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

/* ====== KATEGORI & RESULT ====== */
.kategori-section {
    border-top: 1px solid var(--border);
    padding: 14px 18px;
}

.kategori-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.sekolah-section { padding: 0 18px 16px; }
.sekolah-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--primary);
    padding: 12px 0 4px;
    border-bottom: 2px solid var(--border);
    margin-bottom: 12px;
}

.result-list { display: flex; flex-direction: column; gap: 8px; }

.result-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: #fafbff;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    flex-wrap: wrap;
}

.result-detail { display: flex; align-items: center; gap: 8px; flex: 1; flex-wrap: wrap; }

.result-names {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.result-names span { font-size: 13px; font-weight: 600; }
.result-names small { font-size: 11px; color: var(--text-light); }

/* ====== FILTER BAR ====== */
.filter-bar, .public-filter {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-bar select, .public-filter select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: var(--font);
    outline: none;
}

/* ====== EMPTY STATE ====== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-light);
}

.empty-icon { font-size: 48px; margin-bottom: 12px; }

/* ====== LOGIN ====== */
.login-body {
    background: linear-gradient(135deg, #1a237e, #1565c0);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-container {
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    padding: 40px;
    width: 100%;
    max-width: 400px;
}

.login-header { text-align: center; margin-bottom: 28px; }
.login-logo { font-size: 52px; margin-bottom: 8px; }
.login-header h1 { font-size: 24px; font-weight: 800; color: var(--primary); }
.login-header p { font-size: 13px; color: var(--text-light); margin-top: 4px; }

.login-form .form-group { margin-bottom: 16px; }
.login-form label { display: block; font-size: 12px; font-weight: 700; color: var(--text-light); 
                     text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.login-form input { width: 100%; }
.login-footer { text-align: center; margin-top: 20px; font-size: 13px; }
.login-footer a { color: var(--primary); text-decoration: none; }

/* ====== ACTION BTNS ====== */
.action-btns { display: flex; gap: 6px; }

/* ====== FOOTER ====== */
.site-footer {
    background: var(--primary);
    color: rgba(255,255,255,0.8);
    text-align: center;
    padding: 30px 20px;
    margin-top: 40px;
}

.footer-inner p { margin-bottom: 4px; font-size: 14px; }
.footer-admin-link {
    display: inline-block;
    margin-top: 12px;
    background: rgba(255,255,255,0.15);
    color: white;
    text-decoration: none;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 12px;
    transition: var(--transition);
}

.footer-admin-link:hover { background: rgba(255,255,255,0.25); }

/* ====== RESPONSIVE ====== */
@media (max-width: 768px) {
    .hero-header h1 { font-size: 2rem; }
    .hero-stats { gap: 20px; }
    .form-grid { grid-template-columns: 1fr; }
    .pertandingan-grid { grid-template-columns: 1fr; }
    .podium-container { gap: 8px; }
    .podium-name { font-size: 13px; }
    .podium-points { font-size: 20px; }
    .podium-1 .podium-block { height: 100px; }
    .podium-2 .podium-block { height: 80px; }
    .podium-3 .podium-block { height: 65px; }
    .tab-link { padding: 12px 14px; font-size: 12px; }
	
	/* ====== IOT INFO BOX ====== */
.iot-info {
    margin-top: 6px;
    padding: 8px 12px;
    background: #e8f5e9;
    border-left: 3px solid #2e7d32;
    border-radius: 4px;
    font-size: 12px;
    color: #1b5e20;
    line-height: 1.5;
}

/* ====== LABEL WAJIB / OPTIONAL ====== */
.label-wajib {
    color: #c62828;
    font-weight: 700;
    margin-left: 2px;
}

.label-optional {
    color: #757575;
    font-size: 11px;
    font-weight: 400;
    font-style: italic;
    margin-left: 4px;
}

/* ====== TAG TIADA (IOT tiada kategori) ====== */
.tag-na {
    color: #bdbdbd;
    font-style: italic;
    font-size: 12px;
}

/* ====== HIDDEN ====== */
.hidden { display: none !important; }
}