/* ==========================================================================
   mAICoach Admin — Modern Design System
   ========================================================================== */

/* ---------- Design Tokens ---------- */
:root {
    --sidebar-width: 260px;
    --topbar-height: 64px;

    /* Brand colors */
    --brand-primary: #6366f1;
    --brand-primary-light: #818cf8;
    --brand-primary-dark: #4f46e5;

    /* Sidebar */
    --sidebar-bg: #0f172a;
    --sidebar-hover: rgba(255, 255, 255, 0.06);
    --sidebar-active: rgba(99, 102, 241, 0.25);
    --sidebar-text: rgba(255, 255, 255, 0.55);
    --sidebar-text-hover: rgba(255, 255, 255, 0.95);

    /* Surface & Background */
    --bg-body: #f1f5f9;
    --bg-surface: #ffffff;
    --bg-surface-hover: #f8fafc;

    /* Text */
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;

    /* Borders */
    --border-light: #e2e8f0;
    --border-input: #cbd5e1;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.06), 0 2px 4px -2px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.06);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.06);

    /* Radii */
    --radius-sm: 0.375rem;
    --radius-md: 0.625rem;
    --radius-lg: 0.875rem;
    --radius-xl: 1rem;

    /* Status colors */
    --color-success: #10b981;
    --color-warning: #f59e0b;
    --color-danger: #ef4444;
    --color-info: #3b82f6;
}

/* ---------- Reset & Base ---------- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ---------- Login ---------- */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: var(--sidebar-bg);
    position: relative;
    overflow: hidden;
}

.login-container::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.15), transparent 70%);
    top: -200px;
    right: -100px;
}

.login-container::after {
    content: '';
    position: absolute;
    width: 500px;
    height: 500px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.12), transparent 70%);
    bottom: -150px;
    left: -100px;
}

.login-card {
    background: var(--bg-surface);
    padding: 2.5rem;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 420px;
    position: relative;
    z-index: 1;
}

.login-card .brand-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, var(--brand-primary), #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
    margin: 0 auto 1rem;
}

.login-card h2 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

.login-card .form-control {
    border-radius: var(--radius-md);
    padding: 0.625rem 0.875rem;
    border-color: var(--border-input);
    font-size: 0.9375rem;
    transition: all 0.2s ease;
}

.login-card .form-control:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.login-card .btn-primary {
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-primary-dark));
    border: none;
    border-radius: var(--radius-md);
    padding: 0.625rem 1rem;
    font-weight: 600;
    font-size: 0.9375rem;
    transition: all 0.2s ease;
}

.login-card .btn-primary:hover {
    background: linear-gradient(135deg, var(--brand-primary-light), var(--brand-primary));
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

/* ---------- Layout Wrapper ---------- */
.wrapper {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

/* ---------- Sidebar ---------- */
#sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 999;
    display: flex;
    flex-direction: column;
    background: var(--sidebar-bg);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-right: 1px solid rgba(255, 255, 255, 0.04);
}

#sidebar .sidebar-header {
    padding: 1.5rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

#sidebar .sidebar-header h4 {
    font-size: 1.125rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

#sidebar .sidebar-header .brand-dot {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--brand-primary), #8b5cf6);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
}

.nav-section-label {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 1.25rem 1.25rem 0.5rem;
    opacity: 0.5;
}

#sidebar .nav {
    flex: 1;
    padding: 0.5rem 0;
}

#sidebar .nav-link {
    color: var(--sidebar-text);
    padding: 0.625rem 1.25rem;
    margin: 0.125rem 0.625rem;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.15s ease;
    gap: 0.75rem;
}

#sidebar .nav-link i {
    width: 20px;
    text-align: center;
    font-size: 1.05rem;
    opacity: 0.7;
}

#sidebar .nav-link:hover {
    color: var(--sidebar-text-hover);
    background: var(--sidebar-hover);
}

#sidebar .nav-link:hover i {
    opacity: 1;
}

#sidebar .nav-link.active {
    color: #c7d2fe;
    background: var(--sidebar-active);
    font-weight: 600;
}

#sidebar .nav-link.active i {
    color: var(--brand-primary-light);
    opacity: 1;
}

#sidebar .sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    margin-top: auto;
}

#sidebar .sidebar-footer .btn {
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
    font-weight: 500;
    border-color: rgba(255, 255, 255, 0.12);
    color: var(--sidebar-text);
    transition: all 0.15s ease;
}

#sidebar .sidebar-footer .btn:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.2);
    color: var(--sidebar-text-hover);
}

/* ---------- Main Content ---------- */
#content {
    width: calc(100% - var(--sidebar-width));
    min-height: 100vh;
    margin-left: var(--sidebar-width);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#content main {
    padding: 1.75rem 2rem;
    min-height: calc(100vh - var(--topbar-height));
}

/* ---------- Topbar ---------- */
.topbar {
    height: var(--topbar-height);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    background: rgba(255, 255, 255, 0.85);
}

#sidebarToggle {
    font-size: 1.25rem;
    color: var(--text-secondary);
    border: none;
    background: none;
    padding: 0.375rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s ease;
}

#sidebarToggle:hover {
    background: var(--bg-body);
    color: var(--text-primary);
}

.topbar .user-info {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.topbar .user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-primary), #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 0.75rem;
}

/* ---------- Page Header ---------- */
.page-header {
    margin-bottom: 1.75rem;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--text-primary);
    margin: 0;
}

.page-header .badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.375rem 0.75rem;
    border-radius: 9999px;
}

/* ---------- Stat Cards ---------- */
.stat-card {
    border: none;
    border-radius: var(--radius-lg);
    transition: all 0.2s ease;
    overflow: hidden;
    position: relative;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), transparent);
    pointer-events: none;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.stat-card .card-body {
    padding: 1.375rem;
    position: relative;
}

.stat-card .stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.025em;
}

.stat-card .stat-label {
    font-size: 0.8125rem;
    font-weight: 500;
    opacity: 0.8;
    margin-bottom: 0.25rem;
}

.stat-card .stat-sub {
    font-size: 0.75rem;
    opacity: 0.65;
    margin-top: 0.5rem;
}

/* Stat card color variants */
.stat-card.bg-gradient-primary {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
}

.stat-card.bg-gradient-success {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
}

.stat-card.bg-gradient-warning {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
}

.stat-card.bg-gradient-info {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
}

/* ---------- Cards ---------- */
.card {
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
    border-radius: var(--radius-lg);
    background: var(--bg-surface);
    transition: box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-light);
    padding: 1rem 1.375rem;
}

.card-header .card-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-header .card-title i {
    color: var(--brand-primary);
    font-size: 1rem;
}

.card-body {
    padding: 1.375rem;
}

/* ---------- Tables ---------- */
.table {
    margin-bottom: 0;
    font-size: 0.875rem;
}

.table thead th {
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-light);
    border-top: none;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.75rem 1rem;
    white-space: nowrap;
}

.table tbody td {
    vertical-align: middle;
    padding: 0.75rem 1rem;
    border-color: var(--border-light);
    color: var(--text-primary);
}

.table tbody tr {
    transition: background 0.1s ease;
}

.table-hover tbody tr:hover {
    background: var(--bg-surface-hover);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* ---------- Badges ---------- */
.badge {
    font-weight: 600;
    font-size: 0.6875rem;
    padding: 0.3rem 0.625rem;
    border-radius: 9999px;
    letter-spacing: 0.02em;
}

.badge.bg-success { background-color: #dcfce7 !important; color: #15803d; }
.badge.bg-warning { background-color: #fef3c7 !important; color: #92400e; }
.badge.bg-danger  { background-color: #fee2e2 !important; color: #b91c1c; }
.badge.bg-info    { background-color: #dbeafe !important; color: #1e40af; }
.badge.bg-secondary { background-color: #f1f5f9 !important; color: #475569; }
.badge.bg-primary { background-color: #e0e7ff !important; color: #3730a3; }

/* "Solid" badge variant for status */
.badge-solid.bg-success { background-color: var(--color-success) !important; color: white; }
.badge-solid.bg-warning { background-color: var(--color-warning) !important; color: white; }
.badge-solid.bg-danger  { background-color: var(--color-danger) !important; color: white; }
.badge-solid.bg-info    { background-color: var(--color-info) !important; color: white; }

/* ---------- Code ---------- */
code {
    padding: 0.15rem 0.4rem;
    font-size: 0.8125rem;
    background: #f1f5f9;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: 'SF Mono', 'Fira Code', monospace;
}

/* ---------- Pagination ---------- */
.pagination {
    margin-top: 1.5rem;
    gap: 0.25rem;
}

.page-link {
    border: none;
    color: var(--text-secondary);
    border-radius: var(--radius-sm) !important;
    font-size: 0.8125rem;
    font-weight: 500;
    padding: 0.375rem 0.75rem;
    transition: all 0.15s ease;
}

.page-link:hover {
    background: var(--bg-body);
    color: var(--text-primary);
}

.page-item.active .page-link {
    background: var(--brand-primary);
    color: white;
}

.page-item.disabled .page-link {
    color: var(--text-muted);
    background: transparent;
}

/* ---------- Forms ---------- */
.form-control,
.form-select {
    border-radius: var(--radius-md);
    border-color: var(--border-input);
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
    transition: all 0.15s ease;
    color: var(--text-primary);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.form-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.375rem;
}

.form-text {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ---------- Buttons ---------- */
.btn {
    font-weight: 600;
    font-size: 0.875rem;
    border-radius: var(--radius-md);
    padding: 0.5rem 1rem;
    transition: all 0.15s ease;
}

.btn-primary {
    background: var(--brand-primary);
    border-color: var(--brand-primary);
}

.btn-primary:hover {
    background: var(--brand-primary-dark);
    border-color: var(--brand-primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-outline-primary {
    color: var(--brand-primary);
    border-color: var(--brand-primary);
}

.btn-outline-primary:hover {
    background: var(--brand-primary);
    border-color: var(--brand-primary);
    transform: translateY(-1px);
}

.btn-outline-danger {
    font-size: 0.8125rem;
}

.btn-sm {
    padding: 0.3rem 0.625rem;
    font-size: 0.8125rem;
}

/* ---------- Alerts ---------- */
.alert {
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    padding: 0.875rem 1rem;
}

.alert-warning {
    background: #fffbeb;
    color: #92400e;
    border-left: 4px solid var(--color-warning);
}

.alert-success {
    background: #f0fdf4;
    color: #15803d;
    border-left: 4px solid var(--color-success);
}

.alert-danger {
    background: #fef2f2;
    color: #b91c1c;
    border-left: 4px solid var(--color-danger);
}

.alert-info {
    background: #eff6ff;
    color: #1e40af;
    border-left: 4px solid var(--color-info);
}

/* ---------- Flash Messages ---------- */
.flash-messages {
    margin-bottom: 1.25rem;
}

/* ---------- Definition Lists ---------- */
dl {
    margin-bottom: 0;
}

dt {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

dd {
    margin-bottom: 1.125rem;
    font-weight: 500;
    color: var(--text-primary);
}

dd:last-child {
    margin-bottom: 0;
}

/* ---------- List Groups ---------- */
.list-group-item {
    border-color: var(--border-light);
    padding: 0.875rem 1rem;
    font-size: 0.875rem;
}

/* ---------- Empty State ---------- */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    opacity: 0.4;
}

.empty-state p {
    font-size: 0.875rem;
    margin: 0;
}

/* ---------- Key Display ---------- */
.key-display {
    background: var(--sidebar-bg);
    color: #a5b4fc;
    border-radius: var(--radius-md);
    padding: 0.875rem 1rem;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.8125rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.key-display input {
    background: transparent;
    border: none;
    color: #a5b4fc;
    font-family: inherit;
    font-size: inherit;
    flex: 1;
    outline: none;
}

.key-display .btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    font-size: 0.75rem;
    padding: 0.3rem 0.625rem;
}

.key-display .btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    #sidebar {
        margin-left: calc(-1 * var(--sidebar-width));
    }

    #sidebar.active {
        margin-left: 0;
    }

    #content {
        width: 100%;
        margin-left: 0;
    }

    #content.active {
        margin-left: var(--sidebar-width);
    }

    #content main {
        padding: 1.25rem;
    }

    .topbar {
        padding: 0 1.25rem;
    }
}

@media (max-width: 576px) {
    .stat-card .stat-value {
        font-size: 1.375rem;
    }
}

/* ---------- Scrollbar ---------- */
#sidebar::-webkit-scrollbar {
    width: 4px;
}

#sidebar::-webkit-scrollbar-track {
    background: transparent;
}

#sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

/* ---------- Transitions ---------- */
.fade-in {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
