@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700;800&display=swap');

:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #e0e7ff;
    --secondary: #06b6d4;
    --accent: #f59e0b;
    --success: #10b981;
    --danger: #ef4444;
    --background: #f1f5f9;
    --card-bg: rgba(255, 255, 255, 0.8);
    --text: #0f172a;
    --text-muted: #64748b;
    --border-color: rgba(226, 232, 240, 0.8);
    
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
    
    --glass-bg: rgba(255, 255, 255, 0.45);
    --glass-border: rgba(255, 255, 255, 0.6);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 10px 25px -5px rgba(79, 70, 229, 0.08), 0 8px 16px -6px rgba(79, 70, 229, 0.08);
    --shadow-lg: 0 20px 40px -15px rgba(0, 0, 0, 0.08);
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

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

body {
    font-family: var(--font-body);
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 700;
}

/* Background Gradients */
.bg-decor {
    position: fixed;
    width: 500px;
    height: 500px;
    border-radius: 50%;
    filter: blur(120px);
    z-index: -1;
    opacity: 0.15;
}
.bg-decor-1 {
    top: -100px;
    left: -100px;
    background: var(--primary);
}
.bg-decor-2 {
    bottom: -150px;
    right: -100px;
    background: var(--secondary);
}

/* Main Container */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
    flex: 1;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 1rem;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    gap: 8px;
}
.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, #6366f1 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.35);
}
.btn-secondary {
    background: var(--glass-bg);
    color: var(--text);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
}
.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.7);
    transform: translateY(-2px);
}
.btn-danger {
    background: linear-gradient(135deg, var(--danger) 0%, #f87171 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}
.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.35);
}
.btn-success {
    background: linear-gradient(135deg, var(--success) 0%, #34d399 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}
.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.35);
}
.btn-sm {
    padding: 8px 16px;
    font-size: 0.875rem;
    border-radius: var(--radius-sm);
}

/* Glassmorphism Cards */
.card {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: var(--radius-md);
    padding: 30px;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
}
.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

/* Glass Header */
header {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    top: 0;
    z-index: 100;
}
.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
}
.logo-area img {
    height: 48px;
    width: auto;
    object-fit: contain;
}
.logo-text h1 {
    font-size: 1.25rem;
    color: var(--text);
}
.logo-text p {
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 1px;
}

/* Login Page Styling */
.login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 1;
    padding: 24px;
}
.login-card {
    width: 100%;
    max-width: 450px;
    text-align: center;
}
.login-icon {
    width: 80px;
    height: 80px;
    background: var(--primary-light);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    color: var(--primary);
    font-size: 2.25rem;
}
.login-title {
    margin-bottom: 8px;
    font-size: 1.75rem;
    color: var(--text);
}
.login-subtitle {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 30px;
}
.form-group {
    text-align: left;
    margin-bottom: 20px;
}
.form-group label {
    display: block;
    font-family: var(--font-heading);
    font-weight: 500;
    font-size: 0.9rem;
    margin-bottom: 8px;
    color: var(--text);
}
.form-input {
    width: 100%;
    padding: 14px 16px;
    font-family: var(--font-body);
    font-size: 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.7);
    color: var(--text);
    outline: none;
    transition: var(--transition);
}
.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-light);
    background: #fff;
}
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid transparent;
}
.alert-danger {
    background: #fef2f2;
    color: #b91c1c;
    border-color: #fca5a5;
}
.alert-success {
    background: #ecfdf5;
    color: #047857;
    border-color: #6ee7b7;
}

/* Candidate Selection Cards */
.candidate-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 30px;
    margin-top: 30px;
}
.candidate-card {
    text-align: center;
    position: relative;
    overflow: hidden;
}
.candidate-num {
    position: absolute;
    top: 15px;
    left: 15px;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 1.5rem;
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.3);
    z-index: 10;
}
.candidate-img-wrapper {
    position: relative;
    width: 100%;
    height: 300px;
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
}
.candidate-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition);
}
.candidate-card:hover .candidate-img {
    transform: scale(1.05);
}
.candidate-name {
    font-size: 1.5rem;
    color: var(--text);
    margin-bottom: 4px;
}
.candidate-role {
    font-size: 0.85rem;
    color: var(--text-muted);
    letter-spacing: 1.5px;
    text-transform: uppercase;
    font-weight: 600;
    margin-bottom: 20px;
}
.candidate-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* Modal styling */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    padding: 16px;
}
.modal.active {
    opacity: 1;
    pointer-events: auto;
}
.modal-content {
    background: white;
    border-radius: var(--radius-md);
    max-width: 600px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.modal.active .modal-content {
    transform: scale(1);
}
.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: var(--transition);
}
.modal-close:hover {
    color: var(--danger);
}
.modal-body {
    padding: 24px;
}
.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* ============================================
   ADMIN SIDEBAR — UNIFIED DESIGN SYSTEM
   ============================================ */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar container */
.admin-sidebar {
    width: 260px;
    flex-shrink: 0;
    background: #0f172a;
    display: flex;
    flex-direction: column;
    padding: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    border-right: 1px solid rgba(255,255,255,0.06);
    transition: width 0.3s ease;
}

/* Brand / Logo area */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    margin-bottom: 8px;
}
.sidebar-brand-icon {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, var(--primary), #818cf8);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: white;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(99,102,241,0.4);
}
.sidebar-brand-logo {
    flex-shrink: 0;
}
.sidebar-brand-text {
    min-width: 0;
}
.sidebar-brand-title {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 1.05rem;
    color: #f1f5f9;
    letter-spacing: 0.5px;
    line-height: 1.2;
}
.sidebar-brand-sub {
    font-size: 0.68rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    margin-top: 2px;
}

/* Nav section labels */
.sidebar-nav {
    flex: 1;
    padding: 0 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
}
.sidebar-nav-section {
    font-size: 0.62rem;
    font-weight: 700;
    color: #334155;
    text-transform: uppercase;
    letter-spacing: 1.8px;
    padding: 12px 8px 4px;
    margin-top: 4px;
}

/* Nav links */
.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 12px;
    border-radius: 9px;
    color: #94a3b8;
    text-decoration: none;
    font-family: var(--font-heading);
    font-weight: 500;
    font-size: 0.88rem;
    transition: all 0.18s ease;
    position: relative;
    overflow: hidden;
}
.sidebar-nav-item i {
    font-size: 0.95rem;
    width: 18px;
    text-align: center;
    flex-shrink: 0;
}
.sidebar-nav-item span {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-nav-item:hover {
    background: rgba(255,255,255,0.06);
    color: #e2e8f0;
}
.sidebar-nav-item.active {
    background: linear-gradient(135deg, rgba(99,102,241,0.25), rgba(99,102,241,0.12));
    color: #a5b4fc;
    border: 1px solid rgba(99,102,241,0.25);
    font-weight: 600;
}
.sidebar-nav-item.active i {
    color: #818cf8;
}

/* Live TV badge */
.sidebar-live-badge {
    background: rgba(239,68,68,0.2);
    color: #f87171;
    border: 1px solid rgba(239,68,68,0.3);
    font-size: 0.55rem;
    font-weight: 800;
    letter-spacing: 1px;
    padding: 2px 6px;
    border-radius: 9999px;
    flex-shrink: 0;
}
.sidebar-nav-live {
    color: #c4b5fd;
}
.sidebar-nav-live:hover {
    color: #a78bfa;
    background: rgba(167,139,250,0.08);
}

/* Logout link */
.sidebar-nav-logout {
    color: #64748b;
}
.sidebar-nav-logout:hover {
    background: rgba(239,68,68,0.1);
    color: #f87171;
}

/* Admin user info footer */
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid rgba(255,255,255,0.07);
    margin-top: auto;
    background: rgba(255,255,255,0.02);
}
.sidebar-user-avatar {
    width: 34px;
    height: 34px;
    background: linear-gradient(135deg, rgba(99,102,241,0.3), rgba(99,102,241,0.15));
    border: 1px solid rgba(99,102,241,0.3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    color: #818cf8;
    flex-shrink: 0;
}
.sidebar-user-name {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.82rem;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-user-role {
    font-size: 0.68rem;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Keep old sidebar-menu alias for backward compat */
.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 0 20px;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    margin-bottom: 16px;
}
.sidebar-logout {
    margin-top: auto;
}

.admin-main {
    flex: 1;
    padding: 40px;
    background: #f8fafc;
    overflow-y: auto;
}
.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

/* Admin Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 24px;
    margin-bottom: 30px;
}
.stat-card {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
}
.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    background: var(--primary-light);
    color: var(--primary);
}
.stat-icon.success {
    background: #d1fae5;
    color: var(--success);
}
.stat-icon.warning {
    background: #fef3c7;
    color: var(--accent);
}
.stat-number {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text);
}
.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Chart and Quick Count Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 30px;
    margin-bottom: 30px;
}
@media (max-width: 992px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

/* Table Styling */
.table-wrapper {
    overflow-x: auto;
    background: white;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    margin-top: 20px;
}
.table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}
.table th {
    background: #f8fafc;
    padding: 16px 20px;
    font-family: var(--font-heading);
    font-weight: 600;
    color: var(--text);
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border-color);
}
.table td {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text);
    font-size: 0.925rem;
}
.table tr:last-child td {
    border-bottom: none;
}
.table tr:hover {
    background: #f8fafc;
}
.badge {
    display: inline-flex;
    padding: 4px 12px;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}
.badge-success {
    background: #ecfdf5;
    color: #047857;
}
.badge-warning {
    background: #fffbeb;
    color: #b45309;
}

/* Cards for Candidate Lists in Admin */
.admin-candidate-img {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary-light);
}

/* Token Printing Styles (Print Layout) */
.print-area {
    display: none;
}

@media print {
    /* Sembunyikan seluruh struktur halaman utama saat mencetak */
    body > :not(.print-area) {
        display: none !important;
    }
    
    .print-area {
        display: block !important;
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        background: white !important;
    }
    
    .token-grid {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 15px !important;
    }
    
    .token-card {
        background: white !important;
        border: 2px dashed #000 !important;
        padding: 15px !important;
        page-break-inside: avoid;
        box-shadow: none !important;
    }
    
    .token-code {
        background: #f1f5f9 !important;
        border: 1px solid #cbd5e1 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

.token-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
    margin-top: 20px;
}
.token-card {
    background: white;
    border: 1px dashed var(--text-muted);
    border-radius: var(--radius-sm);
    padding: 20px;
    text-align: center;
    box-shadow: var(--shadow-sm);
}
.token-code {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: 2px;
    color: var(--primary);
    margin: 10px 0;
    padding: 8px;
    background: var(--primary-light);
    border-radius: var(--radius-sm);
}

/* Footer Section */
footer {
    text-align: center;
    padding: 24px;
    font-size: 0.85rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-color);
    margin-top: auto;
    background: var(--glass-bg);
}
footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}
footer a:hover {
    text-decoration: underline;
}

/* Responsive Overrides */
@media (max-width: 768px) {
    .admin-layout {
        flex-direction: column;
    }
    .admin-sidebar {
        width: 100%;
        height: auto;
        position: static;
        border-right: none;
        border-bottom: 1px solid rgba(255,255,255,0.06);
    }
    .sidebar-brand {
        margin-bottom: 0;
        padding: 16px;
    }
    .sidebar-nav {
        flex-direction: row;
        overflow-x: auto;
        padding: 10px 16px;
        gap: 8px;
    }
    .sidebar-nav-section {
        display: none; /* Hide section titles on horizontal mobile nav */
    }
    .sidebar-nav-item {
        white-space: nowrap;
        padding: 8px 14px;
        font-size: 0.8rem;
    }
    .sidebar-user {
        display: none; /* Hide user footer on mobile to save space */
    }
    .admin-main {
        padding: 20px;
    }
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* Mobile Compatibility Overrides (Android & iOS) */
@media (max-width: 480px) {
    .login-wrapper {
        padding: 16px 12px;
    }
    
    .login-card {
        padding: 24px 16px;
        width: 100%;
        max-width: 100%;
        border-radius: var(--radius-md);
    }
    
    .login-title {
        font-size: 1.5rem;
    }
    
    .login-subtitle {
        font-size: 0.825rem;
        margin-bottom: 20px;
        line-height: 1.4;
    }
    
    .form-input {
        padding: 12px 14px;
        font-size: 16px !important; /* Mencegah auto-zoom menjengkelkan pada browser seluler */
    }
    
    .header-container {
        padding: 12px 16px;
    }
    
    .logo-text h1 {
        font-size: 1.1rem;
    }
    
    .user-info-hide {
        display: none !important; /* Sembunyikan identitas panjang di header agar tidak menumpuk dengan tombol keluar */
    }
    
    .btn {
        padding: 10px 16px;
        font-size: 0.95rem;
    }
}
