/* ===== CSS Variables ===== */
:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #eef2ff;
    --primary-gradient: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    --sidebar-bg: #1e1b4b;
    --sidebar-hover: rgba(255, 255, 255, 0.08);
    --sidebar-active: rgba(255, 255, 255, 0.15);
    --navbar-bg: #ffffff;
    --body-bg: #f1f5f9;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-light: #94a3b8;
    --border: #e2e8f0;
    --success: #059669;
    --success-light: #ecfdf5;
    --danger: #dc2626;
    --danger-light: #fef2f2;
    --warning: #d97706;
    --warning-light: #fffbeb;
    --purple: #7c3aed;
    --purple-light: #f5f3ff;
    --radius: 10px;
    --radius-sm: 6px;
    --radius-lg: 16px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.12);
    --sidebar-width: 260px;
    --navbar-height: 64px;
    --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
    --transition: 0.25s ease;
}

/* ===== Reset & Base ===== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 14px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--body-bg);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    text-decoration: none;
    color: inherit;
}

img {
    max-width: 100%;
}

code {
    font-size: 0.82rem;
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--primary);
}

/* ===== Layout ===== */
.layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: #fff;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: transform var(--transition);
    overflow: hidden;
}

.sidebar-brand {
    height: var(--navbar-height);
    display: flex;
    align-items: center;
    padding: 0 24px;
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(0, 0, 0, 0.15);
}

.sidebar-brand span {
    color: #a5b4fc;
}

.sidebar-nav {
    flex: 1;
    padding: 8px 0;
    overflow-y: auto;
}

.sidebar-section-label {
    padding: 16px 24px 6px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: rgba(255, 255, 255, 0.35);
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 24px;
    color: rgba(255, 255, 255, 0.65);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition);
    border-left: 3px solid transparent;
    margin: 1px 0;
}

.sidebar-nav a:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

.sidebar-nav a.active {
    background: var(--sidebar-active);
    color: #fff;
    border-left-color: #a5b4fc;
}

.sidebar-nav a i {
    width: 20px;
    text-align: center;
    font-size: 0.95rem;
    opacity: 0.85;
}

.sidebar-nav a.active i {
    opacity: 1;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Navbar */
.navbar {
    height: var(--navbar-height);
    background: var(--navbar-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.navbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.navbar-left h1 {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-primary);
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.navbar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    background: var(--body-bg);
    padding: 6px 14px;
    border-radius: 20px;
}

.navbar-user i {
    font-size: 1.1rem;
    color: var(--primary);
}

.btn-logout {
    background: none;
    border: 1px solid var(--border);
    padding: 7px 16px;
    border-radius: 20px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all var(--transition);
    font-family: var(--font);
}

.btn-logout:hover {
    border-color: var(--danger);
    color: var(--danger);
    background: var(--danger-light);
}

/* Page Body */
.page-body {
    flex: 1;
    padding: 28px;
}

/* ===== Page Header ===== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.page-header h2 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
}

.page-actions {
    display: flex;
    gap: 10px;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 20px;
    border-radius: var(--radius);
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all var(--transition);
    font-family: var(--font);
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary-gradient);
    color: #fff;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

.btn-primary:hover {
    box-shadow: 0 4px 16px rgba(79, 70, 229, 0.4);
    transform: translateY(-1px);
}

.btn-outline {
    background: var(--card-bg);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

.btn-success {
    background: var(--success);
    color: #fff;
}

.btn-success:hover {
    opacity: 0.9;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    opacity: 0.9;
}

.btn-sm {
    padding: 5px 12px;
    font-size: 0.82rem;
    border-radius: var(--radius-sm);
}

.btn-icon {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    font-size: 0.88rem;
    transition: all var(--transition);
    background: transparent;
}

.btn-edit {
    color: var(--primary);
}

.btn-edit:hover {
    background: var(--primary-light);
}

.btn-delete {
    color: var(--danger);
}

.btn-delete:hover {
    background: var(--danger-light);
}

.btn-expand {
    color: var(--text-secondary);
}

.btn-expand:hover {
    background: var(--primary-light);
    color: var(--primary);
}

/* ===== Cards ===== */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    background: #fafbfc;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

.card-title i {
    color: var(--primary);
    font-size: 0.95rem;
}

.card-body {
    padding: 24px;
}

.card-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    background: #fafbfc;
}

/* ===== Tables ===== */
.table-wrapper {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead {
    background: #f8fafc;
}

.data-table th {
    padding: 12px 18px;
    text-align: left;
    font-weight: 600;
    font-size: 0.78rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    border-bottom: 2px solid var(--border);
}

.data-table td {
    padding: 12px 18px;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.data-table tbody tr {
    transition: background var(--transition);
}

.data-table tbody tr:hover {
    background: #f8fafc;
}

.data-table .text-center {
    text-align: center;
    color: var(--text-light);
    padding: 40px 16px;
}

.text-muted {
    font-size: 0.8rem;
    color: var(--text-light);
}

.text-success {
    color: var(--success);
}

.text-danger {
    color: var(--danger);
}

.action-buttons {
    display: flex;
    gap: 4px;
    align-items: center;
}

/* ===== Filter Bar ===== */
.filter-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.table-info {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* ===== Forms ===== */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 0.88rem;
    color: var(--text-primary);
}

.form-group label i {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 9px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-family: var(--font);
    color: var(--text-primary);
    background: #fff;
    transition: all var(--transition);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.input-icon-wrapper {
    position: relative;
}

.input-icon-wrapper .form-input {
    padding-right: 42px;
}

.input-icon-btn {
    position: absolute;
    right: 2px;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--text-light);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: color var(--transition);
}

.input-icon-btn:hover {
    color: var(--primary);
}

/* ===== Modals ===== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    z-index: 200;
    align-items: center;
    justify-content: center;
}

.modal-overlay.open {
    display: flex;
}

.modal {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    
    width: 95% !important;
    max-width: 900px !important;   /* desktop */
    max-height: 85vh;
    
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.2s ease;
}

/* Tablet */
@media (max-width: 768px) {
    .modal {
        max-width: 95% !important;
        width: 95% !important;
    }
}

/* Mobile */
@media (max-width: 480px) {
    .modal {
        max-width: 98% !important;
        width: 98% !important;
        border-radius: 10px;
    }
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-close {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.modal-close:hover {
    background: var(--danger-light);
    color: var(--danger);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    background: #fafbfc;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ===== Scoped Modal Layouts ===== */
/* Optimize modal spacing for compact professional layout */
.topic-modal,
.variant-modal {
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.topic-modal .modal-body,
.variant-modal .modal-body {
    padding: 18px 20px;
    gap: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Topic Modal (3-column FCM fields) */
.topic-modal {
    max-width: 950px !important;
}

/* Variant Modal */
.variant-modal {
    max-width: 900px !important;
}

/* Optimized form spacing */
.topic-modal .form-row,
.variant-modal .form-row {
    gap: 12px;
    margin-bottom: 1px;
}

.topic-modal .form-group,
.variant-modal .form-group {
    margin-bottom: 0;
}

/* 3-Column Form Layout */
.form-row--3col {
    grid-template-columns: 1fr 1fr 1fr;
}

/* Compact Form Group (smaller textarea) */
.form-group--compact {
    margin-bottom: 8px;
}

.form-textarea--compact {
    min-height: 55px !important;
    resize: vertical;
}

/* Tight textarea for 2-column rows */
.form-textarea--tight {
    min-height: 50px !important;
    resize: vertical;
}

/* Form Section Title */
.form-section-title {
    font-size: 0.93rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 12px 0 10px 0;
    padding: 0;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0px;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .topic-modal,
    .variant-modal {
        max-width: 95% !important;
    }

    .form-row--3col {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 480px) {
    .form-row,
    .form-row--3col {
        grid-template-columns: 1fr;
    }

    .topic-modal,
    .variant-modal {
        max-width: 98% !important;
    }
}

/* ===== Pagination ===== */
.pagination {
    display: flex;
    align-items: center;
    gap: 4px;
}

.pagination button {
    min-width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    background: var(--card-bg);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font);
}

.pagination button:hover:not(:disabled):not(.active) {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

.pagination button.active {
    background: var(--primary-gradient);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 2px 6px rgba(79, 70, 229, 0.3);
}

.pagination button:disabled {
    opacity: 0.4;
    cursor: default;
}

/* ===== Status Badges ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.badge-success {
    background: var(--success-light);
    color: var(--success);
}

.badge-danger {
    background: var(--danger-light);
    color: var(--danger);
}

.badge-warning {
    background: var(--warning-light);
    color: var(--warning);
}

.badge-primary {
    background: var(--primary-light);
    color: var(--primary);
}

.badge-purple {
    background: var(--purple-light);
    color: var(--purple);
}

/* ===== Dashboard Stat Cards ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stats-grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px 24px;
    box-shadow: var(--shadow);
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-card-accent::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
}

.stat-card-accent.accent-blue::before { background: var(--primary-gradient); }
.stat-card-accent.accent-green::before { background: linear-gradient(135deg, #059669, #34d399); }
.stat-card-accent.accent-orange::before { background: linear-gradient(135deg, #d97706, #fbbf24); }
.stat-card-accent.accent-red::before { background: linear-gradient(135deg, #dc2626, #f87171); }
.stat-card-accent.accent-purple::before { background: linear-gradient(135deg, #7c3aed, #a78bfa); }

.stat-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.stat-card .stat-label {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-top: 4px;
    font-weight: 500;
}

.stat-card .stat-value {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-card .stat-sub {
    font-size: 0.78rem;
    color: var(--text-light);
    margin-top: 6px;
}

.stat-card .stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
}

.stat-icon.blue {
    background: var(--primary-light);
    color: var(--primary);
}

.stat-icon.green {
    background: var(--success-light);
    color: var(--success);
}

.stat-icon.orange {
    background: var(--warning-light);
    color: var(--warning);
}

.stat-icon.red {
    background: var(--danger-light);
    color: var(--danger);
}

.stat-icon.purple {
    background: var(--purple-light);
    color: var(--purple);
}

/* ===== Dashboard Grid ===== */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

/* ===== Toast Notifications ===== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius);
    font-size: 0.88rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 280px;
}

.toast.success {
    background: var(--success);
    color: #fff;
}

.toast.error {
    background: var(--danger);
    color: #fff;
}

.toast.warning {
    background: var(--warning);
    color: #fff;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(40px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ===== Loader ===== */
.loader-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(2px);
    z-index: 250;
    align-items: center;
    justify-content: center;
}

.loader-overlay.show {
    display: flex;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ===== Login Page ===== */
.login-wrapper {
    min-height: 100vh;
    display: flex;
}

.login-left {
    flex: 1;
    background: linear-gradient(135deg, #1e1b4b 0%, #312e81 40%, #4338ca 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    position: relative;
    overflow: hidden;
}

.login-left::before {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.03);
    top: -100px;
    right: -100px;
}

.login-left::after {
    content: '';
    position: absolute;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.03);
    bottom: -80px;
    left: -80px;
}

.login-brand-area {
    color: #fff;
    max-width: 400px;
    position: relative;
    z-index: 1;
}

.login-logo {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 12px;
    letter-spacing: 1px;
}

.login-logo span {
    color: #a5b4fc;
}

.login-brand-area h2 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 12px;
    line-height: 1.3;
}

.login-brand-area p {
    color: rgba(255, 255, 255, 0.7);
    font-size: 1rem;
    line-height: 1.6;
    margin-bottom: 32px;
}

.login-features {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.login-feature-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: var(--radius);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all var(--transition);
}

.login-feature-item:hover {
    background: rgba(255, 255, 255, 0.12);
}

.login-feature-item i {
    font-size: 1rem;
    color: #a5b4fc;
}

.login-feature-item span {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.85);
    font-weight: 500;
}

.login-right {
    width: 480px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    background: #fff;
}

.login-card {
    width: 100%;
    max-width: 380px;
}

.login-card-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}

.login-avatar i {
    font-size: 1.5rem;
    color: var(--primary);
}

.login-card h1 {
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.login-card p {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 0;
    font-size: 0.9rem;
}

.login-card .form-group {
    margin-bottom: 18px;
}

.login-card .btn {
    width: 100%;
    justify-content: center;
    padding: 11px 18px;
    font-size: 0.95rem;
    margin-top: 8px;
}

.login-error {
    background: var(--danger-light);
    color: var(--danger);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: 16px;
    display: none;
    border-left: 3px solid var(--danger);
}

/* ===== Not Authenticated Page ===== */
.auth-error-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--body-bg);
    padding: 20px;
}

.auth-error-card {
    text-align: center;
    max-width: 420px;
}

.auth-error-card i {
    font-size: 3rem;
    color: var(--danger);
    margin-bottom: 16px;
}

.auth-error-card h1 {
    font-size: 1.4rem;
    margin-bottom: 10px;
}

.auth-error-card p {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

/* ===== Profile ===== */
.profile-card {
    max-width: 600px;
}

/* ===== Table Image Thumbnail ===== */
.table-img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.table-img-placeholder {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--body-bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    color: var(--text-light);
    font-size: 0.9rem;
}

/* ===== Package Variant Rows ===== */
.pkg-row {
    border-left: 3px solid transparent;
}

.pkg-row:hover {
    border-left-color: var(--primary);
}

.variant-row td {
    padding: 0 !important;
    background: #f8fafc;
}

.variant-container {
    padding: 16px 24px 16px 48px;
}

.variant-table {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.variant-table th {
    background: #eef2ff;
    font-size: 0.75rem;
    padding: 8px 14px;
}

/* ===== User Details View ===== */
.user-details-container {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
}

.user-info-top {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 24px;
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.user-info-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

#detailAddress {
    word-break: break-word;
}


.info-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-value {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
}

.packages-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 24px;
    justify-content: space-between;   /* 🔥 main fix */
}


.package-card {
    flex: 1;
    min-width: 200px;
    max-width: 300px;
    background: var(--card-bg);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    cursor: pointer;
    transition: all var(--transition);
}

.package-card:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.1);
}

.package-card.active {
    border-color: var(--primary);
    background: var(--primary-light);
}

.card-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.variant-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.variant-info {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.transaction-table-wrapper {
    margin-top: 24px;
    border-top: 1px solid var(--border);
    padding-top: 24px;
}

.transaction-table-scroll {
    overflow-x: auto;
    max-height: 400px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.data-table th,
.data-table td {
    text-align: center;
    vertical-align: middle;
}

.no-packages {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    font-size: 0.95rem;
}


.variant-table td {
    padding: 8px 14px;
    font-size: 0.85rem;
}

.variant-empty {
    padding: 16px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.88rem;
}

.variant-empty i {
    margin-right: 6px;
    color: var(--primary);
}

.variant-empty a {
    color: var(--primary);
    font-weight: 600;
    text-decoration: underline;
}

/* ===== Confirm Dialog ===== */
.confirm-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    z-index: 210;
    align-items: center;
    justify-content: center;
}

.confirm-overlay.open {
    display: flex;
}

.confirm-box {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 28px;
    max-width: 400px;
    width: 100%;
    text-align: center;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.2s ease;
}

.confirm-box p {
    margin-bottom: 24px;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.confirm-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

/* ===== Responsive ===== */
.btn-menu-toggle {
    display: none;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: none;
    cursor: pointer;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
    vertical-align: middle;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .3s;
    border-radius: 20px;
    font-size: 0;
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #22c55e;
}

input:checked + .slider:before {
    transform: translateX(16px);
}

.status-text {
    margin-left: 8px;
    font-weight: 500;
    display: inline-block;
    vertical-align: middle;
}

.status-text.active {
    color: #22c55e;
}

.status-text.inactive {
    color: #ef4444;
}

.switch:has(input:checked) + .status-text {
    color: #22c55e;
}

.switch:has(input:not(:checked)) + .status-text {
    color: #ef4444;
}

@media (max-width: 1200px) {
    .stats-grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .modal {
        max-width: 95%;
        margin: 20px;
    }

    .stats-grid,
    .stats-grid-4 {
        grid-template-columns: 1fr;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .btn-menu-toggle {
        display: flex;
    }

    .login-wrapper {
        flex-direction: column;
    }

    .login-left {
        display: none;
    }

    .login-right {
        width: 100%;
        min-height: 100vh;
    }

    .filter-group {
        flex-wrap: wrap;
    }
}
