/* ============================================
   VeloGate — Modern Design System
   ============================================ */
:root {
  --primary: #4f46e5;
  --primary-light: #818cf8;
  --primary-dark: #3730a3;
  --primary-50: #eef2ff;
  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --info: #3b82f6;
  --info-light: #dbeafe;
  --bg: #f8fafc;
  --bg-dark: #0f172a;
  --card: #ffffff;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -2px rgba(0,0,0,.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -4px rgba(0,0,0,.04);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,.1), 0 8px 10px -6px rgba(0,0,0,.04);
  --transition: .2s cubic-bezier(.4,0,.2,1);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  --sidebar-w: 260px;
  --header-h: 64px;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

/* ---- Layout ---- */
.app-layout { display: flex; min-height: 100vh; }
.app-main { flex: 1; margin-left: var(--sidebar-w); padding: 24px; max-width: calc(100vw - var(--sidebar-w)); }
.app-container { max-width: 1200px; margin: 0 auto; }

/* ---- Sidebar ---- */
.sidebar {
  position: fixed; left: 0; top: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-dark);
  color: #e2e8f0;
  display: flex; flex-direction: column;
  z-index: 100;
  overflow-y: auto;
  transition: transform var(--transition);
}
.sidebar-brand {
  padding: 20px 24px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; gap: 12px;
}
.sidebar-brand .logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: 10px;
  display: grid; place-items: center;
  font-weight: 800; color: #fff; font-size: 18px;
}
.sidebar-brand .logo-text { font-weight: 700; font-size: 18px; color: #fff; }
.sidebar-brand .logo-text span { color: var(--primary-light); }
.sidebar-nav { flex: 1; padding: 16px 12px; }
.sidebar-nav .nav-section { margin-bottom: 20px; }
.sidebar-nav .nav-section-title {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .08em; color: #64748b; padding: 0 12px; margin-bottom: 8px;
}
.sidebar-nav .nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: #94a3b8; font-size: 14px; font-weight: 500;
  cursor: pointer; transition: var(--transition);
  text-decoration: none; border: none; background: none; width: 100%; text-align: left;
}
.sidebar-nav .nav-item:hover { background: rgba(255,255,255,.06); color: #e2e8f0; }
.sidebar-nav .nav-item.active { background: var(--primary); color: #fff; }
.sidebar-nav .nav-item .nav-icon { width: 20px; height: 20px; flex-shrink: 0; }
.sidebar-nav .nav-item .nav-badge {
  margin-left: auto; background: var(--primary); color: #fff;
  font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px;
}
.sidebar-footer {
  padding: 16px; border-top: 1px solid rgba(255,255,255,.08);
}
.sidebar-footer .user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; border-radius: var(--radius-sm);
  background: rgba(255,255,255,.04);
}
.sidebar-footer .user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 14px;
}
.sidebar-footer .user-info { flex: 1; min-width: 0; }
.sidebar-footer .user-name { font-size: 13px; font-weight: 600; color: #e2e8f0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-footer .user-role { font-size: 11px; color: #64748b; }
.sidebar-footer .logout-btn {
  color: #64748b; background: none; border: none; cursor: pointer;
  padding: 6px; border-radius: 6px; transition: var(--transition);
}
.sidebar-footer .logout-btn:hover { color: var(--danger); background: rgba(239,68,68,.1); }

/* ---- Header ---- */
.top-header {
  background: var(--card); border-bottom: 1px solid var(--border);
  height: var(--header-h);
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
}
.top-header .header-left { display: flex; align-items: center; gap: 16px; }
.top-header .menu-toggle {
  display: none; background: none; border: none; cursor: pointer;
  padding: 8px; border-radius: var(--radius-sm); color: var(--text-secondary);
}
.top-header .menu-toggle:hover { background: var(--border-light); }
.top-header .page-title { font-size: 20px; font-weight: 700; }
.top-header .header-right { display: flex; align-items: center; gap: 12px; }
.top-header .header-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--card);
  font-size: 13px; font-weight: 500; color: var(--text-secondary);
  cursor: pointer; transition: var(--transition);
}
.top-header .header-btn:hover { background: var(--bg); border-color: var(--text-muted); }

/* ---- Cards ---- */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
  box-shadow: var(--shadow);
  transition: var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--border-light);
}
.card-title { font-size: 16px; font-weight: 600; }
.card-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ---- Stats Grid ---- */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px; margin-bottom: 24px;
}
.stat-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  display: flex; align-items: center; gap: 16px;
  transition: var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: grid; place-items: center; flex-shrink: 0;
}
.stat-icon.blue { background: var(--info-light); color: var(--info); }
.stat-icon.green { background: var(--success-light); color: var(--success); }
.stat-icon.purple { background: var(--primary-50); color: var(--primary); }
.stat-icon.orange { background: var(--warning-light); color: var(--warning); }
.stat-info .stat-value { font-size: 28px; font-weight: 700; line-height: 1.2; }
.stat-info .stat-label { font-size: 13px; color: var(--text-muted); font-weight: 500; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; font-family: var(--font);
  border: 1px solid transparent; cursor: pointer;
  transition: var(--transition); text-decoration: none; white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-secondary { background: var(--card); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); border-color: var(--text-muted); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; color: #fff; }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--border-light); color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 14px 28px; font-size: 15px; }
.btn-icon { padding: 8px; width: 36px; height: 36px; }
.btn-block { width: 100%; }

/* ---- Forms ---- */
.form-group { margin-bottom: 20px; }
.form-label {
  display: block; font-size: 13px; font-weight: 600;
  color: var(--text-secondary); margin-bottom: 6px;
}
.form-label .required { color: var(--danger); }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 10px 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14px; font-family: var(--font); color: var(--text);
  background: var(--card); transition: var(--transition);
  outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.1);
}
.form-input::placeholder, .form-textarea::placeholder { color: var(--text-muted); }
.form-textarea { min-height: 100px; resize: vertical; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: 12px; color: var(--danger); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ---- Tables ---- */
.table-container { overflow-x: auto; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  background: var(--bg); padding: 12px 16px; text-align: left;
  font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .04em; color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border-light); }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--bg); }
.table .table-actions { display: flex; gap: 8px; }

/* ---- Badges ---- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 600;
}
.badge-success { background: var(--success-light); color: #065f46; }
.badge-warning { background: var(--warning-light); color: #92400e; }
.badge-danger { background: var(--danger-light); color: #991b1b; }
.badge-info { background: var(--info-light); color: #1e40af; }
.badge-primary { background: var(--primary-50); color: var(--primary-dark); }
.badge-muted { background: var(--border-light); color: var(--text-muted); }

/* ---- Tabs ---- */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 24px; overflow-x: auto; }
.tab {
  padding: 10px 20px; font-size: 14px; font-weight: 500;
  color: var(--text-muted); border: none; background: none;
  cursor: pointer; border-bottom: 2px solid transparent;
  margin-bottom: -2px; transition: var(--transition); white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---- Alerts ---- */
.alert {
  padding: 14px 18px; border-radius: var(--radius-sm);
  font-size: 14px; display: flex; align-items: flex-start; gap: 12px;
  margin-bottom: 16px;
}
.alert-info { background: var(--info-light); color: #1e40af; border: 1px solid #bfdbfe; }
.alert-success { background: var(--success-light); color: #065f46; border: 1px solid #a7f3d0; }
.alert-warning { background: var(--warning-light); color: #92400e; border: 1px solid #fde68a; }
.alert-danger { background: var(--danger-light); color: #991b1b; border: 1px solid #fecaca; }

/* ---- Toast ---- */
.toast-container {
  position: fixed; top: 20px; right: 20px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 14px 18px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; color: #fff;
  box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 10px;
  animation: slideIn .3s ease; min-width: 280px; max-width: 400px;
}
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--info); }
.toast-warning { background: var(--warning); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideOut { from { transform: translateX(0); opacity: 1; } to { transform: translateX(100%); opacity: 0; } }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  display: grid; place-items: center; z-index: 1000;
  opacity: 0; pointer-events: none; transition: var(--transition);
}
.modal-overlay.active { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--card); border-radius: var(--radius-lg);
  padding: 28px; width: 90%; max-width: 480px;
  box-shadow: var(--shadow-xl);
  transform: scale(.95); transition: var(--transition);
}
.modal-overlay.active .modal { transform: scale(1); }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-title { font-size: 18px; font-weight: 700; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--text-muted); padding: 4px; border-radius: 6px; }
.modal-close:hover { background: var(--border-light); color: var(--text); }

/* ---- Auth Pages ---- */
.auth-page {
  min-height: 100vh; display: grid; place-items: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 20px;
}
.auth-card {
  background: var(--card); border-radius: var(--radius-lg);
  padding: 40px; width: 100%; max-width: 420px;
  box-shadow: var(--shadow-xl);
}
.auth-logo { text-align: center; margin-bottom: 32px; }
.auth-logo .logo-icon {
  width: 56px; height: 56px; margin: 0 auto 16px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: 14px; display: grid; place-items: center;
  font-weight: 800; color: #fff; font-size: 24px;
}
.auth-logo h1 { font-size: 24px; font-weight: 700; }
.auth-logo p { color: var(--text-muted); font-size: 14px; margin-top: 4px; }
.auth-footer { text-align: center; margin-top: 24px; font-size: 14px; color: var(--text-muted); }
.auth-footer a { font-weight: 600; }

/* ---- Landing Page ---- */
.landing-hero {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #a855f7 100%);
  color: #fff; padding: 80px 24px; text-align: center;
  position: relative; overflow: hidden;
}
.landing-hero::before {
  content: ''; position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
.landing-hero h1 { font-size: 48px; font-weight: 800; margin-bottom: 16px; position: relative; }
.landing-hero p { font-size: 18px; opacity: .9; max-width: 600px; margin: 0 auto 32px; position: relative; }
.landing-hero .hero-actions { display: flex; gap: 12px; justify-content: center; position: relative; flex-wrap: wrap; }
.landing-hero .btn { padding: 14px 28px; font-size: 15px; }
.landing-hero .btn-outline {
  background: transparent; color: #fff; border: 2px solid rgba(255,255,255,.4);
}
.landing-hero .btn-outline:hover { background: rgba(255,255,255,.1); border-color: #fff; color: #fff; }

.features-section { padding: 64px 24px; }
.features-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px; max-width: 1100px; margin: 0 auto;
}
.feature-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px;
  transition: var(--transition);
}
.feature-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.feature-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: grid; place-items: center; margin-bottom: 16px;
  font-size: 24px;
}
.feature-card h3 { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.feature-card p { font-size: 14px; color: var(--text-secondary); }

/* ---- Code Block ---- */
.code-block {
  background: var(--bg-dark); color: #e2e8f0;
  padding: 20px; border-radius: var(--radius-sm);
  font-family: var(--font-mono); font-size: 13px;
  overflow-x: auto; line-height: 1.7;
}
.code-block .code-comment { color: #64748b; }
.code-block .code-string { color: #a5f3fc; }
.code-block .code-keyword { color: #c4b5fd; }

/* ---- Empty State ---- */
.empty-state {
  text-align: center; padding: 48px 24px; color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h3 { font-size: 16px; font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; }
.empty-state p { font-size: 14px; }

/* ---- Loading ---- */
.loading { display: inline-block; width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, var(--border-light) 25%, var(--border) 50%, var(--border-light) 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: var(--radius-sm); }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ---- Responsive ---- */
@media (max-width: 1024px) {
  :root { --sidebar-w: 240px; }
  .app-main { margin-left: var(--sidebar-w); max-width: calc(100vw - var(--sidebar-w)); }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .app-main { margin-left: 0; max-width: 100vw; padding: 16px; }
  .top-header .menu-toggle { display: block; }
  .form-row { grid-template-columns: 1fr; }
  .landing-hero h1 { font-size: 32px; }
  .landing-hero p { font-size: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .toast-container { left: 12px; right: 12px; }
  .toast { min-width: auto; max-width: none; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .auth-card { padding: 28px 20px; }
  .landing-hero { padding: 48px 16px; }
  .landing-hero h1 { font-size: 28px; }
}

/* ---- Utility ---- */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-small { font-size: 13px; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; } .mt-4 { margin-top: 32px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; } .mb-4 { margin-bottom: 32px; }
.hidden { display: none !important; }
.flex { display: flex; } .items-center { align-items: center; } .justify-between { justify-content: space-between; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
