/* ============================================
   Light Theme - White Background + Blue Accent
   ============================================ */

:root {
    --bg-primary: #f5f6fa;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-hover: #f0f2f5;
    --bg-input: #ffffff;
    --border-color: #dee2e6;
    --text-primary: #212529;
    --text-secondary: #495057;
    --text-muted: #6c757d;
    --accent: #4a90d9;
    --accent-hover: #3a7bc8;
    --accent-light: rgba(74, 144, 217, 0.08);
    --accent-glow: rgba(74, 144, 217, 0.2);
    --gradient-1: linear-gradient(135deg, #4a90d9 0%, #6366f1 100%);
    --gradient-2: linear-gradient(135deg, #e8f0fe 0%, #e0e7ff 100%);
    --danger: #e74c3c;
    --success: #2ecc71;
    --warning: #f39c12;
    --sidebar-width: 250px;
    --header-height: 56px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* ========== Guest Layout (Login) ========== */
body.guest-layout {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(74, 144, 217, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(99, 102, 241, 0.04) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(74, 144, 217, 0.04) 0%, transparent 50%);
    min-height: 100vh;
    padding: 20px;
}

.login-wrapper {
    width: 100%;
    max-width: 420px;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 40px 32px;
    box-shadow: 0 2px 16px rgba(0,0,0,0.08), 0 0 40px rgba(74,144,217,0.04);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    background: var(--gradient-1);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: #fff;
    box-shadow: 0 4px 16px var(--accent-glow);
}

.login-header h3 {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.btn-login {
    padding: 12px;
    font-weight: 600;
    font-size: 1rem;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.btn-login:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-admin {
    background: var(--gradient-1);
    border: none;
    color: #fff;
}

.btn-admin:hover {
    background: linear-gradient(135deg, #5ca0e9 0%, #7375f5 100%);
    color: #fff;
}

/* ========== Form Styling ========== */
.form-control, .form-select {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 10px 14px;
    border-radius: 8px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus, .form-select:focus {
    background: var(--bg-input);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
    color: var(--text-primary);
}

.form-control::placeholder { color: var(--text-muted); }

.input-group-text {
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.form-label {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.9rem;
    margin-bottom: 6px;
}

/* ========== App Layout (Sidebar + Content) ========== */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* ========== Sidebar ========== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform 0.3s ease;
    box-shadow: 1px 0 8px rgba(0,0,0,0.04);
}

.sidebar-header {
    padding: 20px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.sidebar-header i {
    font-size: 1.4rem;
    background: var(--gradient-1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.92rem;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--accent-light);
    color: var(--accent);
    border-left-color: var(--accent);
    font-weight: 500;
}

.sidebar-footer {
    padding: 12px 0;
    border-top: 1px solid var(--border-color);
}

/* ========== Mobile Header ========== */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 99;
    box-shadow: 0 1px 6px rgba(0,0,0,0.06);
}

.mobile-toggle {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px 8px;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.3);
    z-index: 98;
}

.sidebar-overlay.active { display: block; }

/* ========== Main Content ========== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    padding: 24px;
    padding-top: 24px;
}

.content-header {
    margin-bottom: 24px;
}

.content-header h4 {
    margin: 0;
    font-weight: 600;
    color: var(--text-primary);
}

/* ========== Cards ========== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 16px 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.card-body { padding: 20px; }

/* ========== Stat Cards ========== */
.stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.stat-card:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 16px var(--accent-light);
    transform: translateY(-2px);
}

.stat-card .stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    margin-bottom: 12px;
}

.stat-card .stat-icon.blue {
    background: rgba(74, 144, 217, 0.12);
    color: var(--accent);
}

.stat-card .stat-icon.green {
    background: rgba(46, 204, 113, 0.12);
    color: var(--success);
}

.stat-card .stat-icon.orange {
    background: rgba(243, 156, 18, 0.12);
    color: var(--warning);
}

.stat-card .stat-icon.red {
    background: rgba(231, 76, 60, 0.12);
    color: var(--danger);
}

.stat-card .stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-card .stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -30%;
    width: 120px;
    height: 120px;
    background: radial-gradient(circle, var(--accent-light) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

/* ========== Tables ========== */
.table-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
}

.table {
    color: var(--text-primary);
    margin: 0;
}

.table thead th {
    background: #f8f9fa;
    border-bottom: 2px solid var(--border-color);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 12px 16px;
}

.table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.table tbody tr:hover {
    background: var(--bg-hover);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* ========== Buttons ========== */
.btn {
    border-radius: 8px;
    padding: 8px 16px;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
}

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.btn-outline-primary {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-outline-primary:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.btn-sm { padding: 5px 12px; font-size: 0.82rem; }

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

/* ========== Badges ========== */
.badge {
    padding: 5px 10px;
    border-radius: 6px;
    font-weight: 500;
    font-size: 0.95rem;
}

.counter-badge {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.82rem;
    min-width: 40px;
    text-align: center;
}

/* ========== Alerts ========== */
.alert {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 10px;
}

.alert-danger {
    border-color: rgba(231, 76, 60, 0.25);
    background: rgba(231, 76, 60, 0.06);
}

.alert-success {
    border-color: rgba(46, 204, 113, 0.25);
    background: rgba(46, 204, 113, 0.06);
}

/* ========== Modals ========== */
.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
}

.modal-header {
    border-bottom: 1px solid var(--border-color);
    padding: 16px 20px;
}

.modal-footer {
    border-top: 1px solid var(--border-color);
    padding: 16px 20px;
}

/* ========== Pagination ========== */
.pagination .page-link {
    background: var(--bg-card);
    border-color: var(--border-color);
    color: var(--text-secondary);
}

.pagination .page-link:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.pagination .active .page-link {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* ========== Search/Filter ========== */
.search-box {
    position: relative;
}

.search-box input {
    padding-left: 36px;
}

.search-box i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

/* ========== Keyword increment row ========== */
.keyword-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.increment-btn {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: 1px solid var(--accent);
    background: var(--accent-light);
    color: var(--accent);
    cursor: pointer;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.increment-btn:hover {
    background: var(--accent);
    color: #fff;
}

/* ========== Record history ========== */
.record-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.record-list li {
    padding: 6px 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.record-list li:last-child { border-bottom: none; }

/* ========== QR Code image ========== */
.qr-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
.qr-grid-item {
    position: relative;
    cursor: pointer;
}
.qr-grid-item img {
    width: 100%;
    height: 80px;
    object-fit: contain;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: #f8f9fa;
}
.qr-grid-item .btn-del {
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 10px;
    padding: 0 4px;
    line-height: 1.4;
}

/* Lightbox modal */
.qr-lightbox {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.85);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}
.qr-lightbox.show {
    display: flex;
}
.qr-lightbox img {
    max-width: 90vw;
    max-height: 90vh;
    border-radius: 8px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.5);
}

/* ========== Dropdown menu ========== */
.dropdown-menu {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.dropdown-item {
    color: var(--text-secondary);
}

.dropdown-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.dropdown-divider {
    border-color: var(--border-color);
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .mobile-header { display: flex; }

    .main-content {
        margin-left: 0;
        padding-top: calc(var(--header-height) + 16px);
    }

    .login-card {
        padding: 28px 20px;
    }

    .stat-cards {
        grid-template-columns: 1fr 1fr;
    }

    .table-container { overflow-x: auto; }

    .content-header {
        flex-direction: column;
        gap: 12px;
    }
}

/* ========== Mobile package cards ========== */
.mobile-pkg-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
}

@media (max-width: 576px) {
    .stat-cards {
        grid-template-columns: 1fr;
    }

    .stat-cards.member-stats {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .stat-cards.member-stats .stat-card {
        padding: 12px 8px;
        text-align: center;
    }

    .stat-cards.member-stats .stat-icon {
        width: 32px;
        height: 32px;
        font-size: 1rem;
        margin: 0 auto 6px;
    }

    .stat-cards.member-stats .stat-value {
        font-size: 1.1rem;
    }

    .stat-cards.member-stats .stat-label {
        font-size: 0.72rem;
    }

    .login-wrapper {
        max-width: 100%;
    }

    .btn-group { flex-direction: column; }
    .btn-group .btn { border-radius: 8px !important; margin-bottom: 4px; }

    .content-header h4 { font-size: 1.1rem; }

    .badge { font-size: 0.85rem; padding: 4px 8px; }
}

/* ========== Animations ========== */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.card, .stat-card {
    animation: fadeInUp 0.3s ease;
}
