/* ═══════════════════════════════════════════════════════
   ExpoAI — Design System
   ═══════════════════════════════════════════════════════ */

:root {
  --sidebar-width: 240px;
  --sidebar-collapsed-width: 64px;
  --topbar-height: 60px;

  --color-primary: #1a1a2e;
  --color-primary-light: #16213e;
  --color-accent: #e94560;
  --color-accent-hover: #c73652;
  --color-success: #0f9b58;
  --color-warning: #f59e0b;
  --color-danger: #ef4444;
  --color-info: #3b82f6;

  --color-bg: #f0f2f5;
  --color-surface: #ffffff;
  --color-border: #e2e8f0;
  --color-text: #1e293b;
  --color-text-muted: #64748b;
  --color-text-light: #94a3b8;

  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,.10);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.12);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --font-sans: 'Inter', system-ui, sans-serif;
  --font-display: 'Space Grotesk', system-ui, sans-serif;

  --transition: all .2s cubic-bezier(.4,0,.2,1);
}

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

body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  margin: 0;
  overflow-x: hidden;
  font-size: 14px;
  line-height: 1.6;
}

/* ─── SIDEBAR ────────────────────────────────────────── */

.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--color-primary);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: var(--transition);
  overflow: hidden;
}

.sidebar.collapsed { width: var(--sidebar-collapsed-width); }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  min-height: 72px;
  flex-shrink: 0;
}

.brand-icon {
  width: 36px; height: 36px;
  background: var(--color-accent);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-size: 18px;
  flex-shrink: 0;
}

.company-logo-sm {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  object-fit: contain;
  background: white;
  padding: 2px;
  flex-shrink: 0;
}

.brand-text { overflow: hidden; }
.brand-name {
  display: block;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: white;
  white-space: nowrap;
}
.brand-company {
  display: block;
  font-size: 11px;
  color: rgba(255,255,255,.45);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.1) transparent;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255,255,255,.3);
  padding: 16px 10px 6px;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.65);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  transition: var(--transition);
  position: relative;
  margin-bottom: 2px;
}

.sidebar-nav .nav-link i {
  font-size: 16px;
  width: 20px;
  flex-shrink: 0;
  text-align: center;
}

.sidebar-nav .nav-link span { overflow: hidden; }

.sidebar-nav .nav-link:hover {
  background: rgba(255,255,255,.08);
  color: white;
}

.sidebar-nav .nav-link.active {
  background: var(--color-accent);
  color: white;
}

.nav-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 20px;
  flex-shrink: 0;
}
.nav-badge.danger { background: var(--color-danger); color: white; }
.nav-badge.primary { background: var(--color-info); color: white; }

.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,.08);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--color-accent);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.user-details { overflow: hidden; flex: 1; }
.user-name {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role { display: block; font-size: 11px; color: rgba(255,255,255,.4); }

.btn-logout {
  color: rgba(255,255,255,.4);
  font-size: 18px;
  text-decoration: none;
  transition: var(--transition);
  flex-shrink: 0;
}
.btn-logout:hover { color: var(--color-accent); }

.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-section-label,
.sidebar.collapsed .nav-link span,
.sidebar.collapsed .nav-badge,
.sidebar.collapsed .user-details { display: none; }

.sidebar.collapsed .sidebar-footer { justify-content: center; }
.sidebar.collapsed .btn-logout { display: none; }

/* ─── MAIN CONTENT ───────────────────────────────────── */

.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: var(--transition);
}

.main-content.expanded { margin-left: var(--sidebar-collapsed-width); }

/* ─── TOPBAR ─────────────────────────────────────────── */

.topbar {
  height: var(--topbar-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.sidebar-toggle {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.sidebar-toggle:hover { background: var(--color-bg); color: var(--color-text); }

.topbar-title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  color: var(--color-text);
  flex: 1;
}

.topbar-actions { display: flex; align-items: center; gap: 10px; }

/* ─── PAGE CONTENT ───────────────────────────────────── */

.page-content { padding: 24px; flex: 1; }

.messages-container { padding: 16px 24px 0; }

/* ─── CARDS ──────────────────────────────────────────── */

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.card-header {
  background: transparent;
  border-bottom: 1px solid var(--color-border);
  padding: 16px 20px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
}

.card-body { padding: 20px; }

/* ─── STAT CARDS ─────────────────────────────────────── */

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.stat-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.stat-icon.primary { background: #eff6ff; color: var(--color-info); }
.stat-icon.success { background: #f0fdf4; color: var(--color-success); }
.stat-icon.warning { background: #fffbeb; color: var(--color-warning); }
.stat-icon.danger  { background: #fef2f2; color: var(--color-danger); }
.stat-icon.dark    { background: #f1f5f9; color: var(--color-primary); }
.stat-icon.accent  { background: #fff1f2; color: var(--color-accent); }

.stat-value {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1;
}
.stat-label {
  font-size: 12px;
  color: var(--color-text-muted);
  font-weight: 500;
  margin-top: 4px;
}

/* ─── PIPELINE BOARD ─────────────────────────────────── */

.pipeline-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
}

.pipeline-col {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 14px 12px;
  text-align: center;
  border-top: 3px solid;
  transition: var(--transition);
}
.pipeline-col:hover { box-shadow: var(--shadow-md); }

.pipeline-count {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
}
.pipeline-label { font-size: 11px; color: var(--color-text-muted); font-weight: 500; margin-top: 4px; }

.pipeline-new_lead    { border-top-color: #94a3b8; }
.pipeline-contacted   { border-top-color: #3b82f6; }
.pipeline-brief_received { border-top-color: #8b5cf6; }
.pipeline-design      { border-top-color: #f59e0b; }
.pipeline-proposal    { border-top-color: #f97316; }
.pipeline-contract    { border-top-color: #10b981; }
.pipeline-customer    { border-top-color: #1a1a2e; }
.pipeline-lost        { border-top-color: #ef4444; }

/* ─── TABLES ─────────────────────────────────────────── */

.table-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.table-card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.table-card-header h6 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
}

.table { margin: 0; font-size: 13.5px; }

.table thead th {
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border) !important;
  color: var(--color-text-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 10px 16px;
  white-space: nowrap;
}

.table tbody td {
  padding: 11px 16px;
  vertical-align: middle;
  border-color: var(--color-border);
}

.table tbody tr:hover { background: #fafbfc; }
.table tbody tr:last-child td { border-bottom: none; }

/* ─── STATUS BADGES ──────────────────────────────────── */

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.status-new_lead     { background: #f1f5f9; color: #475569; }
.status-contacted    { background: #eff6ff; color: #2563eb; }
.status-brief_received { background: #f5f3ff; color: #7c3aed; }
.status-design       { background: #fffbeb; color: #d97706; }
.status-proposal     { background: #fff7ed; color: #ea580c; }
.status-contract     { background: #f0fdf4; color: #16a34a; }
.status-customer     { background: #1a1a2e; color: white; }
.status-lost         { background: #fef2f2; color: #dc2626; }

/* ─── BUTTONS ────────────────────────────────────────── */

.btn-primary {
  background: var(--color-primary) !important;
  border-color: var(--color-primary) !important;
  color: white !important;
  font-weight: 500;
  border-radius: var(--radius-sm);
}
.btn-primary:hover {
  background: var(--color-accent) !important;
  border-color: var(--color-accent) !important;
}

.btn-accent {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: white;
  font-weight: 500;
  border-radius: var(--radius-sm);
}
.btn-accent:hover {
  background: var(--color-accent-hover);
  border-color: var(--color-accent-hover);
  color: white;
}

.btn-sm { font-size: 12px; padding: 4px 10px; }
.btn-icon { padding: 5px 8px; }

/* ─── FORMS ──────────────────────────────────────────── */

.form-label { font-weight: 500; font-size: 13px; color: var(--color-text); margin-bottom: 5px; }

.form-control, .form-select {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  padding: 8px 12px;
  transition: var(--transition);
  color: var(--color-text);
}

.form-control:focus, .form-select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(26,26,46,.1);
}

.form-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 24px;
  margin-bottom: 20px;
}

.form-section-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  color: var(--color-text);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ─── DETAIL PAGE ────────────────────────────────────── */

.detail-header {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 24px;
  margin-bottom: 20px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  box-shadow: var(--shadow-sm);
}

.detail-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--color-text);
  margin: 0 0 6px;
}

.detail-meta { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 10px; }
.detail-meta-item { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--color-text-muted); }
.detail-meta-item i { font-size: 15px; }

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.info-item { }
.info-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--color-text-light); margin-bottom: 3px; }
.info-value { font-size: 14px; font-weight: 500; color: var(--color-text); }

/* ─── ACTIVITY TIMELINE ──────────────────────────────── */

.timeline { position: relative; padding-left: 28px; }
.timeline::before {
  content: '';
  position: absolute;
  left: 9px; top: 0; bottom: 0;
  width: 2px;
  background: var(--color-border);
}

.timeline-item { position: relative; margin-bottom: 20px; }
.timeline-dot {
  position: absolute;
  left: -23px; top: 4px;
  width: 18px; height: 18px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px;
  color: white;
  flex-shrink: 0;
}

.timeline-content {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}

.timeline-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  gap: 10px;
}

.timeline-type {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.timeline-date { font-size: 11px; color: var(--color-text-muted); }
.timeline-desc { font-size: 13.5px; color: var(--color-text); line-height: 1.5; }
.timeline-user { font-size: 11px; color: var(--color-text-muted); margin-top: 6px; }

/* ─── FOLLOW-UP HIGHLIGHTS ───────────────────────────── */

.overdue-row td { background: #fff5f5 !important; }
.today-row td { background: #f0fdf4 !important; }

.overdue-badge { color: var(--color-danger); font-weight: 600; }
.today-badge { color: var(--color-success); font-weight: 600; }

/* ─── AUTH PAGES ─────────────────────────────────────── */

.auth-wrapper {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--color-primary) 0%, #0f3460 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 460px;
  box-shadow: var(--shadow-lg);
}

.auth-logo {
  text-align: center;
  margin-bottom: 28px;
}

.auth-logo .logo-icon {
  width: 56px; height: 56px;
  background: var(--color-accent);
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center; justify-content: center;
  font-size: 26px;
  color: white;
  margin-bottom: 12px;
}

.auth-logo h1 {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  color: var(--color-primary);
  margin: 0;
}

.auth-logo p { color: var(--color-text-muted); font-size: 13px; margin: 4px 0 0; }

/* ─── PAYMENT PROGRESS ───────────────────────────────── */

.payment-progress {
  background: var(--color-bg);
  border-radius: var(--radius-md);
  padding: 16px;
  border: 1px solid var(--color-border);
}

.payment-progress .progress { height: 10px; border-radius: 10px; }
.payment-progress-label { font-size: 12px; color: var(--color-text-muted); }
.payment-amount { font-family: var(--font-display); font-weight: 700; font-size: 18px; }

/* ─── EMPTY STATE ────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--color-text-muted);
}
.empty-state i { font-size: 48px; margin-bottom: 16px; opacity: .4; display: block; }
.empty-state h5 { color: var(--color-text); font-weight: 600; }
.empty-state p { font-size: 13px; max-width: 320px; margin: 0 auto 20px; }

/* ─── PAGE HEADER ────────────────────────────────────── */

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

.page-header h1 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  margin: 0;
  color: var(--color-text);
}

.breadcrumb { font-size: 12px; margin-bottom: 4px; }
.breadcrumb-item + .breadcrumb-item::before { color: var(--color-text-light); }

/* ─── FORMSET ────────────────────────────────────────── */

.formset-row {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 10px;
  position: relative;
}

.formset-delete { position: absolute; top: 10px; right: 10px; }

/* ─── MISC UTILITIES ─────────────────────────────────── */

.text-accent { color: var(--color-accent) !important; }
.bg-primary-dark { background: var(--color-primary); }

.divider { border-top: 1px solid var(--color-border); margin: 16px 0; }

.section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--color-text-muted);
  margin-bottom: 10px;
}

/* ─── RESPONSIVE ─────────────────────────────────────── */

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .page-content { padding: 16px; }
  .detail-header { flex-direction: column; }
  .pipeline-grid { grid-template-columns: repeat(4, 1fr); }
}
