@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* UI-UX Pro Max - Enterprise SaaS (Light Mode) */
  --color-primary: #4F46E5; /* Indigo */
  --color-secondary: #7C3AED; /* Violet */
  --color-background: #F8FAFC; /* Slate 50 */
  --color-surface: #FFFFFF;
  --color-foreground: #0F172A; /* Slate 900 */
  --color-muted: #64748B; /* Slate 500 */
  --color-border: #E2E8F0; /* Slate 200 */
  --color-accent: #4F46E5;
  --color-accent-hover: #4338CA;
  --color-destructive: #EF4444;
  --color-success: #10B981;
  
  --font-heading: 'Plus Jakarta Sans', sans-serif;
  --font-body: 'Plus Jakarta Sans', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  --spacing-1: 0.25rem;
  --spacing-2: 0.5rem;
  --spacing-3: 0.75rem;
  --spacing-4: 1rem;
  --spacing-6: 1.5rem;
  --spacing-8: 2rem;
  --spacing-12: 3rem;
  --spacing-16: 4rem;
  
  --radius-sm: 0.375rem; /* 6px */
  --radius-md: 0.5rem; /* 8px input/button */
  --radius-lg: 1rem; /* 16px cards */
  --radius-pill: 9999px;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(79, 70, 229, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(79, 70, 229, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

button {
  cursor: pointer;
}

body {
  font-family: var(--font-body);
  background-color: var(--color-background);
  color: var(--color-foreground);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: var(--spacing-4);
  color: var(--color-foreground);
  letter-spacing: -0.02em;
}

h1 { font-weight: 800; }

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover { color: var(--color-accent-hover); }

/* Base Layouts */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--spacing-4);
}

.main-content {
  flex: 1;
  padding: var(--spacing-8) 0;
}

/* UI Elements */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-3) var(--spacing-6);
  font-family: var(--font-body);
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 0.875rem;
}

.btn-primary {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
  color: #FFFFFF;
  box-shadow: 0 4px 14px 0 rgba(79, 70, 229, 0.39);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(79, 70, 229, 0.23);
}

.btn-outline {
  background-color: transparent;
  color: var(--color-foreground);
  border: 1px solid var(--color-border);
}

.btn-outline:hover {
  background-color: var(--color-background);
  border-color: var(--color-muted);
}

.btn-destructive {
  background-color: var(--color-destructive);
  color: #FFF;
}

.card {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--spacing-6);
  margin-bottom: var(--spacing-6);
  box-shadow: var(--shadow-sm);
}

.input-group { margin-bottom: var(--spacing-4); }

label {
  display: block;
  margin-bottom: var(--spacing-2);
  font-size: 0.875rem;
  color: var(--color-foreground);
  font-weight: 600;
}

input[type="text"], input[type="email"], input[type="password"], input[type="number"], select, textarea {
  width: 100%;
  padding: var(--spacing-3);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-foreground);
  font-family: var(--font-body);
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

/* Tables */
.table-container { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
th, td { padding: var(--spacing-4); text-align: left; border-bottom: 1px solid var(--color-border); }
th { font-weight: 600; color: var(--color-muted); text-transform: uppercase; letter-spacing: 0.05em; font-size: 0.75rem; }
tbody tr:hover { background-color: var(--color-background); }

/* Utilities */
.text-center { text-align: center; }
.mt-4 { margin-top: var(--spacing-4); }
.mb-4 { margin-bottom: var(--spacing-4); }
.mb-8 { margin-bottom: var(--spacing-8); }
.flex { display: flex; }
.justify-between { justify-content: space-between; }
.items-center { align-items: center; }
.gap-4 { gap: var(--spacing-4); }
.text-muted { color: var(--color-muted); }
.text-sm { font-size: 0.875rem; }
.hidden { display: none !important; }

/* Navbar */
.navbar {
  background-color: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: var(--spacing-4) 0;
  box-shadow: var(--shadow-sm);
}

.navbar .container { display: flex; justify-content: space-between; align-items: center; }
.navbar-brand { font-family: var(--font-heading); font-size: 1.5rem; font-weight: 800; color: var(--color-primary); text-decoration: none; }
.navbar-nav { display: flex; align-items: center; gap: var(--spacing-6); list-style: none; }
.nav-link { color: var(--color-muted); font-weight: 500; font-size: 0.875rem; }
.nav-link:hover { color: var(--color-foreground); }

/* Dashboard Layout */
.app-layout { display: flex; height: 100vh; overflow: hidden; background-color: var(--color-background); }

.sidebar {
  width: 260px;
  background-color: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  padding: var(--spacing-4) 0;
  flex-shrink: 0;
}

.brand-logo {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--color-primary);
  padding: 0 var(--spacing-6) var(--spacing-6);
}

.nav-menu {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-2);
  padding: 0 var(--spacing-4);
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-3);
  padding: var(--spacing-3) var(--spacing-4);
  color: var(--color-muted);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  transition: all var(--transition-fast);
}

.nav-item:hover { background-color: var(--color-background); color: var(--color-foreground); }
.nav-item.active { background-color: rgba(79, 70, 229, 0.1); color: var(--color-primary); }

.main-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.top-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 var(--spacing-6);
  height: 64px;
  background-color: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.header-left { display: flex; align-items: center; gap: var(--spacing-6); height: 100%; }
.header-title { font-family: var(--font-heading); font-weight: 700; font-size: 1.1rem; }
.header-tabs { display: flex; height: 100%; }
.tab { display: flex; align-items: center; padding: 0 var(--spacing-4); cursor: pointer; border-bottom: 2px solid transparent; color: var(--color-muted); font-weight: 600; transition: all var(--transition-fast); }
.tab:hover { color: var(--color-foreground); }
.tab.active { color: var(--color-primary); border-bottom-color: var(--color-primary); }

.header-right { display: flex; align-items: center; gap: var(--spacing-4); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%); border: 2px solid var(--color-surface); box-shadow: var(--shadow-sm); }

.page-content { flex: 1; overflow-y: auto; padding: var(--spacing-8); display: none; }
.page-content.active { display: block; }
.content-wrapper { max-width: 1400px; margin: 0 auto; }

/* KPIs */
.kpi-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--spacing-6); margin-bottom: var(--spacing-8); }
.kpi-card { background-color: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: var(--spacing-6); box-shadow: var(--shadow-md); transition: transform var(--transition-fast); }
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.kpi-value { font-size: 2.5rem; font-family: var(--font-heading); font-weight: 800; color: var(--color-foreground); }
.kpi-sub { font-size: 0.875rem; color: var(--color-muted); font-weight: 500; }
.kpi-progress-bg { height: 6px; background-color: var(--color-border); border-radius: 3px; overflow: hidden; margin-top: 12px; }
.kpi-progress-fill { height: 100%; background: linear-gradient(90deg, var(--color-primary) 0%, var(--color-secondary) 100%); transition: width 0.3s ease; }

.main-grid { display: grid; grid-template-columns: 3fr 2fr; gap: var(--spacing-6); margin-bottom: var(--spacing-6); }

/* Clean "Terminal" (Now a data list) */
.terminal-window {
  flex: 1;
  background-color: var(--color-surface);
  border-radius: var(--radius-md);
  padding: var(--spacing-4);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  overflow-y: auto;
  min-height: 350px;
  max-height: 500px;
  border: 1px solid var(--color-border);
  box-shadow: inset var(--shadow-sm);
  color: var(--color-muted);
}
.log-line { margin-bottom: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--color-border); }
.log-info { color: var(--color-primary); font-weight: 600; }


/* Bugfixes for sidebar and icons */
.nav-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: var(--spacing-4);
  border-top: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
}


/* =========================================
   DASHBOARD SPECIFIC LAYOUT V2
   ========================================= */
body.dashboard-body {
    background-color: var(--color-background);
    margin: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Top Navbar */
.dash-header {
    height: 64px;
    background: #FFFFFF;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--spacing-6);
    flex-shrink: 0;
    z-index: 10;
}
.dash-header-left {
    display: flex;
    align-items: center;
    gap: var(--spacing-8);
}
.dash-brand {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--color-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}
.dash-nav-links {
    display: flex;
    gap: var(--spacing-6);
}
.dash-nav-link {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-muted);
    text-decoration: none;
}
.dash-nav-link.active {
    color: var(--color-primary);
    border-bottom: 2px solid var(--color-primary);
    padding-bottom: 20px;
    margin-bottom: -22px;
}
.dash-header-right {
    display: flex;
    align-items: center;
    gap: var(--spacing-4);
}

/* Main Dashboard Wrapper */
.dash-wrapper {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Left Sidebar */
.dash-sidebar {
    width: 240px;
    background: #FFFFFF;
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    padding: var(--spacing-6) 0;
    flex-shrink: 0;
}
.dash-menu {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-2);
    padding: 0 var(--spacing-4);
}
.dash-menu-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-3);
    padding: var(--spacing-3) var(--spacing-4);
    border-radius: var(--radius-md);
    color: var(--color-muted);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 600;
    transition: all 0.2s;
}
.dash-menu-item:hover {
    background: #F1F5F9;
    color: var(--color-foreground);
}
.dash-menu-item.active {
    background: #6366F1;
    color: white;
}
.dash-menu-item svg {
    width: 18px;
    height: 18px;
}
.credits-widget {
    margin-top: auto;
    padding: 0 var(--spacing-4);
}
.credits-box {
    background: #EEF2FF;
    border-radius: var(--radius-md);
    padding: var(--spacing-4);
}
.credits-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: var(--spacing-2);
}
.credits-bar-bg {
    height: 6px;
    background: #C7D2FE;
    border-radius: 3px;
    overflow: hidden;
}
.credits-bar-fill {
    height: 100%;
    background: var(--color-primary);
    border-radius: 3px;
}

/* Main Content Area */
.dash-content {
    flex: 1;
    background: #F4F5F9;
    padding: var(--spacing-8);
    overflow-y: auto;
}
.dash-title-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--spacing-8);
}
.dash-title {
    font-size: 2.25rem;
    font-weight: 800;
    color: #1E1B4B;
    line-height: 1.2;
    margin-bottom: var(--spacing-2);
}
.dash-subtitle {
    font-size: 0.875rem;
    color: var(--color-muted);
    max-width: 500px;
}
.segmented-control {
    display: flex;
    background: transparent;
    padding: 0;
    gap: 8px;
    border: none;
}
.segment-btn {
    padding: 8px 16px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-muted);
    border-radius: var(--radius-md);
    cursor: pointer;
    background: transparent;
}
.segment-btn.active {
    background: #FFFFFF;
    color: var(--color-primary);
    box-shadow: 0 2px 4px rgba(0,0,0,0.04);
}

/* KPI Cards */
.dash-kpis {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-6);
    margin-bottom: var(--spacing-6);
}
.kpi-card-v2 {
    background: #FFFFFF;
    border-radius: var(--radius-lg);
    border: 1px solid rgba(0,0,0,0.03);
    box-shadow: 0 4px 12px rgba(0,0,0,0.03);
    padding: var(--spacing-6);
    display: flex;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}
.kpi-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--color-muted);
    letter-spacing: 0.05em;
    margin-bottom: var(--spacing-4);
}
.kpi-number {
    font-size: 3rem;
    font-weight: 800;
    color: #1E1B4B;
    display: flex;
    align-items: center;
    gap: var(--spacing-4);
}
.kpi-badge {
    font-size: 0.75rem;
    padding: 4px 8px;
    background: #D1FAE5;
    color: #059669;
    border-radius: 4px;
    font-weight: 600;
}
.kpi-footer {
    font-size: 0.75rem;
    color: var(--color-muted);
    margin-top: var(--spacing-4);
}
.kpi-bg-icon {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 140px;
    height: 140px;
    color: #F1F5F9;
    z-index: 0;
}
.kpi-content {
    position: relative;
    z-index: 1;
}

/* iOS Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}
.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #E2E8F0;
    transition: .4s;
    border-radius: 24px;
}
.toggle-slider:before {
    position: absolute;
    content: ;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
input:checked + .toggle-slider {
    background-color: var(--color-primary);
}
input:checked + .toggle-slider:before {
    transform: translateX(20px);
}
.toggle-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #F8FAFC;
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-4);
}

/* Terminal Adjustments */
.terminal-mac-header {
    background: #2D3748;
    padding: 8px 12px;
    display: flex;
    gap: 6px;
    border-top-left-radius: var(--radius-md);
    border-top-right-radius: var(--radius-md);
    align-items: center;
    justify-content: space-between;
}
.terminal-mac-dots {
    display: flex;
    gap: 6px;
}
.terminal-mac-title {
    font-size: 0.75rem;
    font-family: monospace;
    color: #A0AEC0;
}
.terminal-body {
    background: #0F172A;
    padding: var(--spacing-4);
    font-family: monospace;
    font-size: 0.75rem;
    color: #22C55E;
    border-bottom-left-radius: var(--radius-md);
    border-bottom-right-radius: var(--radius-md);
    min-height: 200px;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: var(--spacing-12);
}
.empty-icon {
    width: 48px;
    height: 48px;
    color: #CBD5E1;
    margin-bottom: var(--spacing-4);
}
.empty-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-foreground);
    margin-bottom: var(--spacing-2);
}
.empty-subtitle {
    font-size: 0.75rem;
    color: var(--color-muted);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: var(--spacing-6);
    right: var(--spacing-6);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-3);
    z-index: 9999;
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--spacing-3);
    padding: var(--spacing-4) var(--spacing-6);
    background: rgba(255, 255, 255, 0.85); /* Glassmorphism */
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    border-radius: var(--radius-lg);
    color: var(--color-foreground);
    font-size: 0.875rem;
    font-weight: 500;
    max-width: 350px;
    animation: toast-slide-in 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast.toast-error {
    border-left: 4px solid var(--color-destructive);
}

.toast.toast-success {
    border-left: 4px solid var(--color-accent);
}

.toast.toast-info {
    border-left: 4px solid var(--color-primary);
}

.toast.hide {
    animation: toast-slide-out 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes toast-slide-in {
    from {
        opacity: 0;
        transform: translateY(100%) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes toast-slide-out {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(20px) scale(0.9);
    }
}

/* Glass Card */
.glass-card {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}

/* Terminal Footer */
.terminal-footer {
    position: fixed;
    bottom: 0;
    right: 0;
    width: calc(100% - 240px); /* Adjust for dash-sidebar width */
    height: 140px;
    background-color: #020617; /* slate-950 */
    border-top: 1px solid #1e293b; /* slate-800 */
    color: #94a3b8; /* slate-400 */
    font-family: var(--font-mono);
    font-size: 0.75rem;
    z-index: 50;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
}

.terminal-footer-header {
    background-color: #0f172a; /* slate-900 */
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #1e293b;
}

.terminal-footer-body {
    padding: 0.75rem 1rem;
    overflow-y: auto;
    flex: 1;
}

.dash-content {
    padding-bottom: 160px; /* Leave space for terminal footer */
}
