/* ================================================
   SAPI FIT — CSS Design System
   Premium SaaS dark theme
   ================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --navy: #183068;
    --navy-light: #1e3a7a;
    --navy-dark: #0f1f45;
    --graphite: #1F2430;
    --bg-dark: #0f1117;
    --bg-card: #161a25;
    --bg-card-hover: #1c2131;
    --bg-sidebar: #111520;
    --bg-input: #1a1f2e;
    --border: #2a3040;
    --border-light: #353b4d;
    --text-primary: #f0f2f5;
    --text-secondary: #8b95a8;
    --text-muted: #5f6980;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --emerald: #059669;
    --radius: 10px;
    --radius-lg: 14px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.15);
    --transition: all 0.2s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ── Auth Pages ── */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-dark) 0%, var(--graphite) 50%, var(--navy-dark) 100%);
    padding: 20px;
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow);
}

.auth-logo {
    display: block;
    margin: 0 auto 28px;
    height: 44px;
}

.auth-title {
    text-align: center;
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.auth-subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 28px;
}

/* ── Form Controls ── */
.form-label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-control,
.form-select {
    background: var(--bg-input) !important;
    border: 1px solid var(--border) !important;
    color: var(--text-primary) !important;
    border-radius: 8px !important;
    padding: 10px 14px !important;
    font-family: 'Inter', sans-serif !important;
    font-size: 14px !important;
    transition: var(--transition) !important;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15) !important;
    outline: none !important;
}

.form-control::placeholder {
    color: var(--text-muted) !important;
}

.form-group {
    margin-bottom: 18px;
}

/* ── Buttons ── */
.btn-primary {
    background: var(--accent) !important;
    border: none !important;
    color: #fff !important;
    font-weight: 600 !important;
    padding: 11px 24px !important;
    border-radius: 8px !important;
    font-size: 14px !important;
    transition: var(--transition) !important;
    letter-spacing: 0.3px;
}

.btn-primary:hover {
    background: var(--accent-hover) !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3) !important;
}

.btn-navy {
    background: var(--navy) !important;
    border: none !important;
    color: #fff !important;
    font-weight: 600 !important;
    padding: 11px 24px !important;
    border-radius: 8px !important;
}

.btn-navy:hover {
    background: var(--navy-light) !important;
}

.btn-outline-light {
    border: 1px solid var(--border) !important;
    color: var(--text-secondary) !important;
    background: transparent !important;
    border-radius: 8px !important;
    padding: 9px 18px !important;
}

.btn-outline-light:hover {
    background: var(--bg-card-hover) !important;
    color: var(--text-primary) !important;
}

.btn-danger {
    background: var(--danger) !important;
    border: none !important;
}

.btn-danger:hover {
    background: var(--danger-hover) !important;
}

.btn-success {
    background: var(--success) !important;
    border: none !important;
}

.btn-sm {
    padding: 6px 14px !important;
    font-size: 12px !important;
}

/* ── App Layout ── */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: var(--transition);
}

.sidebar-logo {
    padding: 20px 22px;
    border-bottom: 1px solid var(--border);
}

.sidebar-logo img {
    height: 32px;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 10px;
    overflow-y: auto;
}

.sidebar-section {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-muted);
    padding: 14px 14px 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 8px;
    margin-bottom: 2px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.nav-item:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(59, 130, 246, 0.12);
    color: var(--accent);
}

.nav-item i {
    width: 20px;
    margin-right: 10px;
    text-align: center;
    font-size: 15px;
}

.sidebar-footer {
    padding: 14px 16px;
    border-top: 1px solid var(--border);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--navy);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 600;
    font-size: 13px;
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 11px;
    color: var(--text-muted);
}

/* ── Main Content ── */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 28px 32px;
    min-height: 100vh;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
}

.page-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
}

.page-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ── Cards ── */
.card {
    background: var(--bg-card) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius) !important;
    box-shadow: var(--shadow-sm) !important;
    color: var(--text-primary) !important;
}

.card-header {
    background: transparent !important;
    border-bottom: 1px solid var(--border) !important;
    padding: 16px 20px !important;
    font-weight: 600;
    font-size: 15px;
}

.card-body {
    padding: 20px !important;
}

/* ── Stat Cards ── */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    transition: var(--transition);
}

.stat-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    margin-bottom: 12px;
}

.stat-icon.blue {
    background: rgba(59, 130, 246, 0.12);
    color: var(--accent);
}

.stat-icon.green {
    background: rgba(16, 185, 129, 0.12);
    color: var(--success);
}

.stat-icon.amber {
    background: rgba(245, 158, 11, 0.12);
    color: var(--warning);
}

.stat-icon.red {
    background: rgba(239, 68, 68, 0.12);
    color: var(--danger);
}

/* ── Tables ── */
.table {
    color: var(--text-primary) !important;
    --bs-table-bg: transparent !important;
    --bs-table-color: var(--text-primary) !important;
    --bs-table-striped-bg: var(--bg-card-hover) !important;
    --bs-table-hover-bg: rgba(59, 130, 246, 0.06) !important;
    --bs-table-hover-color: var(--text-primary) !important;
    font-size: 13px;
}

.table th {
    font-size: 11px !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.8px !important;
    color: #a0aec0 !important;
    border-bottom: 1px solid var(--border) !important;
    padding: 10px 12px !important;
    background: transparent !important;
}

.table td {
    padding: 10px 12px !important;
    border-bottom: 1px solid var(--border) !important;
    vertical-align: middle !important;
    color: #e2e8f0 !important;
}

.table tbody tr:hover {
    background: rgba(59, 130, 246, 0.06) !important;
}

.table tbody tr:hover td {
    color: #fff !important;
}

/* ── Badges ── */
.badge-status {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.badge-active {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.badge-trial {
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent);
}

.badge-past-due {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.badge-blocked {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.badge-canceled {
    background: rgba(107, 114, 128, 0.15);
    color: var(--text-muted);
}

.badge-pending {
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent);
}

/* ── Modal ── */
.modal-content {
    background: var(--bg-card) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-lg) !important;
    color: var(--text-primary) !important;
}

.modal-header {
    border-bottom: 1px solid var(--border) !important;
    padding: 18px 24px !important;
}

.modal-title {
    font-weight: 600 !important;
}

.modal-body {
    padding: 24px !important;
}

.modal-footer {
    border-top: 1px solid var(--border) !important;
    padding: 14px 24px !important;
}

.btn-close {
    filter: invert(1) !important;
}

/* ── Alert / Toast ── */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
}

.toast-msg {
    padding: 14px 20px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    color: #fff;
    box-shadow: var(--shadow);
    animation: toastIn 0.3s ease;
    margin-bottom: 8px;
}

.toast-success {
    background: var(--success);
}

.toast-error {
    background: var(--danger);
}

.toast-info {
    background: var(--accent);
}

@keyframes toastIn {
    from {
        transform: translateX(100px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ── Spinner ── */
.spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 17, 23, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
}

.spinner-overlay .spinner-border {
    width: 42px;
    height: 42px;
    color: var(--accent);
}

/* ── Section transitions ── */
.page-section {
    display: none;
    animation: fadeIn 0.25s ease;
}

.page-section.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Empty state ── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state h5 {
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: 8px;
}

/* ── Chart container ── */
.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .sidebar {
        width: 70px;
        overflow: hidden;
    }

    .sidebar .sidebar-logo img {
        height: 24px;
    }

    .sidebar .nav-item span {
        display: none;
    }

    .sidebar .sidebar-section {
        display: none;
    }

    .sidebar .sidebar-user-info {
        display: none;
    }

    .sidebar .sidebar-footer {
        padding: 10px 8px;
    }

    .main-content {
        margin-left: 70px;
        padding: 18px 16px;
    }
}

@media (max-width: 480px) {
    .sidebar {
        display: none;
    }

    .main-content {
        margin-left: 0;
    }
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-light);
}

/* ── Student list item ── */
.student-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 8px;
    cursor: pointer;
    transition: var(--transition);
}

.student-item:hover {
    border-color: var(--accent);
    background: rgba(59, 130, 246, 0.04);
}

.student-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--navy);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    margin-right: 14px;
    flex-shrink: 0;
}

.student-name {
    font-weight: 600;
    font-size: 14px;
}

.student-meta {
    font-size: 12px;
    color: var(--text-muted);
}

/* ── Tabs custom ── */
.nav-tabs-custom {
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}

.nav-tabs-custom .nav-link {
    color: var(--text-secondary);
    border: none;
    padding: 10px 18px;
    font-size: 13px;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    cursor: pointer;
}

.nav-tabs-custom .nav-link:hover {
    color: var(--text-primary);
}

.nav-tabs-custom .nav-link.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    background: transparent;
}

/* ── Subscription card ── */
.sub-card {
    background: linear-gradient(135deg, var(--navy-dark), var(--navy));
    border-radius: var(--radius-lg);
    padding: 28px;
    border: 1px solid var(--navy-light);
}

.sub-card h3 {
    color: #fff;
    font-size: 20px;
    font-weight: 700;
}

.sub-card .sub-status {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.8);
}