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

/* ═══════════════════════════════════════════════════════════
   DESIGN SYSTEM — SmartSuite
   Dark mode, Glassmorphism, Violet accent
═══════════════════════════════════════════════════════════ */

:root {
    --primary:      #7C3AED;
    --primary-light:#A78BFA;
    --primary-dark: #5B21B6;
    --accent:       #06B6D4;
    --accent-light: #67E8F9;
    --success:      #10B981;
    --warning:      #F59E0B;
    --danger:       #EF4444;

    --bg-base:      #0F0F1A;
    --bg-surface:   #16162A;
    --bg-card:      #1E1E35;
    --bg-hover:     #252540;

    --text-primary: #F1F5F9;
    --text-muted:   #94A3B8;
    --text-faint:   #475569;

    --border:       rgba(255,255,255,0.06);
    --border-glow:  rgba(124,58,237,0.35);

    --glass-bg:     rgba(30,30,53,0.7);
    --glass-border: rgba(255,255,255,0.08);
    --shadow-sm:    0 2px 8px rgba(0,0,0,0.3);
    --shadow-md:    0 8px 24px rgba(0,0,0,0.4);
    --shadow-glow:  0 8px 32px rgba(124,58,237,0.25);

    --sidebar-w:    260px;
    --radius-sm:    8px;
    --radius-md:    14px;
    --radius-lg:    20px;
    --radius-xl:    28px;
}

/* ── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

#app { min-height: 100vh; }

a { text-decoration: none; color: inherit; }
img { max-width: 100%; }

/* ── Typography ─────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 { font-weight: 700; line-height: 1.2; }
.text-muted  { color: var(--text-muted) !important; }
.text-faint  { color: var(--text-faint) !important; }
.text-primary-color { color: var(--primary) !important; }
.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.fw-bold { font-weight: 700; }
.fw-semibold { font-weight: 600; }

/* ── Layout ─────────────────────────────────────────────── */
.app-layout {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 24px 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-brand {
    padding: 0 20px 24px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}

.sidebar-brand .logo-mark {
    width: 42px; height: 42px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem; margin-bottom: 12px;
    box-shadow: var(--shadow-glow);
}

.sidebar-brand h2 {
    font-size: 1.15rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--text-primary), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-brand .tenant-badge {
    margin-top: 6px;
    font-size: 0.75rem;
    color: var(--primary-light);
    background: rgba(124,58,237,0.12);
    padding: 3px 10px;
    border-radius: 50px;
    display: inline-block;
    border: 1px solid rgba(124,58,237,0.2);
}

.nav-section-label {
    padding: 8px 20px 4px;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-faint);
    font-weight: 600;
}

.nav-menu { list-style: none; padding: 0; flex-grow: 1; }

.nav-item a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    margin: 2px 12px;
    transition: all 0.2s ease;
    position: relative;
}

.nav-item a:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item a.active {
    background: rgba(124,58,237,0.15);
    color: var(--primary-light);
    font-weight: 600;
}

.nav-item a.active::before {
    content: '';
    position: absolute;
    left: -12px; top: 50%;
    transform: translateY(-50%);
    width: 3px; height: 60%;
    background: var(--primary);
    border-radius: 0 3px 3px 0;
}

.nav-item a i { font-size: 1.1rem; width: 22px; text-align: center; }

.sidebar-bottom {
    padding: 20px;
    border-top: 1px solid var(--border);
    margin-top: auto;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    margin-bottom: 12px;
}

.sidebar-user .avatar {
    width: 36px; height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.9rem; font-weight: 700; flex-shrink: 0;
}

.sidebar-user .user-info .name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 130px;
}

.sidebar-user .user-info .role {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: capitalize;
}

.btn-logout {
    display: flex; align-items: center; gap: 8px;
    width: 100%; padding: 10px 14px;
    background: rgba(239,68,68,0.08);
    border: 1px solid rgba(239,68,68,0.15);
    color: #F87171;
    border-radius: var(--radius-sm);
    font-size: 0.85rem; font-weight: 500; cursor: pointer;
    transition: all 0.2s;
}
.btn-logout:hover {
    background: rgba(239,68,68,0.15);
    color: #FCA5A5;
}

/* ── Main Content ────────────────────────────────────────── */
.main-content {
    padding: 32px 36px;
    background: var(--bg-base);
    overflow-x: hidden;
}

.page-header {
    margin-bottom: 32px;
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 16px;
}

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-primary);
}

.page-header p {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ── KPI Cards ───────────────────────────────────────────── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    position: relative;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.kpi-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-glow);
    border-color: var(--border-glow);
}

.kpi-card::after {
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 80px; height: 80px;
    background: radial-gradient(circle, var(--glow-color, var(--primary)) 0%, transparent 70%);
    opacity: 0.08;
    border-radius: 50%;
    transform: translate(20px, -20px);
}

.kpi-card .icon-wrap {
    width: 48px; height: 48px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
    margin-bottom: 16px;
}

.kpi-card .kpi-value {
    font-size: 2.2rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 6px;
}

.kpi-card .kpi-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    font-weight: 500;
}

.kpi-card .kpi-delta {
    font-size: 0.75rem;
    margin-top: 8px;
    display: flex; align-items: center; gap: 4px;
}

/* KPI Color variants */
.kpi-violet { --glow-color: #7C3AED; }
.kpi-violet .icon-wrap { background: rgba(124,58,237,0.15); color: var(--primary-light); }
.kpi-violet .kpi-value { color: var(--primary-light); }

.kpi-cyan { --glow-color: #06B6D4; }
.kpi-cyan .icon-wrap { background: rgba(6,182,212,0.15); color: var(--accent-light); }
.kpi-cyan .kpi-value { color: var(--accent-light); }

.kpi-green { --glow-color: #10B981; }
.kpi-green .icon-wrap { background: rgba(16,185,129,0.15); color: #6EE7B7; }
.kpi-green .kpi-value { color: #6EE7B7; }

.kpi-orange { --glow-color: #F59E0B; }
.kpi-orange .icon-wrap { background: rgba(245,158,11,0.15); color: #FCD34D; }
.kpi-orange .kpi-value { color: #FCD34D; }

/* ── Glass Card ──────────────────────────────────────────── */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 24px;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.card-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}

.card-body { padding: 24px; }

/* ── Tables ──────────────────────────────────────────────── */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
}

thead th {
    background: var(--bg-surface);
    padding: 14px 18px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    font-weight: 600;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

tbody td {
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    color: var(--text-primary);
    vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--bg-hover); }

/* ── Badges & Pills ──────────────────────────────────────── */
.badge {
    display: inline-flex; align-items: center;
    padding: 4px 12px;
    border-radius: 50px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-success { background: rgba(16,185,129,0.12); color: #6EE7B7; border: 1px solid rgba(16,185,129,0.2); }
.badge-danger  { background: rgba(239,68,68,0.12);  color: #FCA5A5; border: 1px solid rgba(239,68,68,0.2); }
.badge-warning { background: rgba(245,158,11,0.12); color: #FCD34D; border: 1px solid rgba(245,158,11,0.2); }
.badge-info    { background: rgba(6,182,212,0.12);  color: var(--accent-light); border: 1px solid rgba(6,182,212,0.2); }
.badge-violet  { background: rgba(124,58,237,0.12); color: var(--primary-light); border: 1px solid rgba(124,58,237,0.2); }
.badge-gray    { background: rgba(148,163,184,0.1); color: var(--text-muted); border: 1px solid rgba(148,163,184,0.15); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    text-decoration: none;
    font-family: 'Inter', sans-serif;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    box-shadow: 0 4px 15px rgba(124,58,237,0.35);
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(124,58,237,0.5);
}

.btn-accent {
    background: linear-gradient(135deg, var(--accent), #0891B2);
    color: #fff;
    box-shadow: 0 4px 15px rgba(6,182,212,0.3);
}
.btn-accent:hover { transform: translateY(-2px); }

.btn-ghost {
    background: var(--bg-hover);
    color: var(--text-muted);
    border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text-primary); border-color: var(--primary); }

.btn-danger-ghost {
    background: transparent;
    color: #F87171;
    border: 1px solid rgba(239,68,68,0.2);
}
.btn-danger-ghost:hover { background: rgba(239,68,68,0.08); }

.btn-sm { padding: 7px 14px; font-size: 0.8rem; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }
.btn-icon { padding: 9px; aspect-ratio: 1; border-radius: var(--radius-sm); }

/* ── Forms ───────────────────────────────────────────────── */
.form-group { margin-bottom: 20px; }

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.form-control, .form-select {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.form-control:focus, .form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(124,58,237,0.15);
    background: var(--bg-surface);
}

.form-control::placeholder { color: var(--text-faint); }
.form-control.is-invalid { border-color: var(--danger); }
.invalid-feedback { color: #F87171; font-size: 0.8rem; margin-top: 5px; }

/* ── Auth pages ──────────────────────────────────────────── */
.auth-page {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: radial-gradient(ellipse at 20% 50%, rgba(124,58,237,0.12) 0%, transparent 60%),
                radial-gradient(ellipse at 80% 20%, rgba(6,182,212,0.08) 0%, transparent 60%),
                var(--bg-base);
    padding: 24px;
}

.auth-box {
    width: 100%;
    max-width: 440px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 44px 40px;
    box-shadow: var(--shadow-md);
}

.auth-logo {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 36px;
}

.auth-logo .logo-mark {
    width: 44px; height: 44px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem;
    box-shadow: var(--shadow-glow);
}

.auth-logo h1 {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--text-primary), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.auth-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 6px;
}

.auth-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 32px;
}

/* ── Modals ──────────────────────────────────────────────── */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
    padding: 24px;
    opacity: 0; pointer-events: none;
    transition: opacity 0.3s;
}
.modal-overlay.active { opacity: 1; pointer-events: all; }

.modal-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 32px;
    max-width: 640px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    transform: scale(0.95);
    transition: transform 0.3s;
}
.modal-overlay.active .modal-box { transform: scale(1); }

.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 24px;
}

.modal-close {
    background: var(--bg-hover);
    border: none; color: var(--text-muted);
    width: 32px; height: 32px;
    border-radius: 50%; cursor: pointer; font-size: 1rem;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
}
.modal-close:hover { background: var(--bg-surface); color: var(--text-primary); }

/* ── Alert / Toast ───────────────────────────────────────── */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 16px;
}
.alert-success { background: rgba(16,185,129,0.1); color: #6EE7B7; border: 1px solid rgba(16,185,129,0.2); }
.alert-danger  { background: rgba(239,68,68,0.1);  color: #FCA5A5; border: 1px solid rgba(239,68,68,0.2); }
.alert-info    { background: rgba(6,182,212,0.1);   color: var(--accent-light); border: 1px solid rgba(6,182,212,0.2); }

/* ── Utilities ───────────────────────────────────────────── */
.d-flex { display: flex; }
.d-grid { display: grid; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.w-100 { width: 100%; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.p-4 { padding: 16px; }
.p-6 { padding: 24px; }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.me-2 { margin-right: 8px; }

/* ── Empty State ─────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 80px 24px;
    color: var(--text-muted);
}
.empty-state i { font-size: 4rem; opacity: 0.2; display: block; margin-bottom: 16px; }
.empty-state h4 { font-size: 1rem; font-weight: 600; margin-bottom: 6px; color: var(--text-primary); }
.empty-state p  { font-size: 0.875rem; }

/* ── Animations ────────────────────────────────────────────── */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(124,58,237,0.4); }
    50%       { box-shadow: 0 0 0 8px rgba(124,58,237,0); }
}

.animate-fade-up { animation: fadeUp 0.5s ease-out forwards; }
.animate-delay-1 { animation-delay: 0.1s; }
.animate-delay-2 { animation-delay: 0.2s; }
.animate-delay-3 { animation-delay: 0.3s; }

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--bg-hover); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ── Audio player ────────────────────────────────────────── */
audio {
    width: 100%;
    border-radius: var(--radius-sm);
    filter: invert(1) hue-rotate(180deg);
    opacity: 0.85;
}

/* ── Loading spinner ─────────────────────────────────────── */
.spinner {
    width: 32px; height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 40px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Chart container ─────────────────────────────────────── */
.chart-container {
    position: relative;
    height: 220px;
}
