/* ============================================================
   CRM ARQUITETURA — Design System
   Dark/Light Mode com tema Azul Gradient Premium
   ============================================================ */

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

/* ---- CSS Variables ---------------------------------------- */
:root {
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;

  /* Blues */
  --blue-900: #0f2044;
  --blue-800: #1e3a8a;
  --blue-700: #1d4ed8;
  --blue-600: #2563eb;
  --blue-500: #3b82f6;
  --blue-400: #60a5fa;
  --blue-300: #93c5fd;
  --blue-200: #bfdbfe;
  --blue-100: #dbeafe;
  --blue-50:  #eff6ff;

  /* Gradients */
  --gradient-primary: linear-gradient(135deg, #1d4ed8 0%, #3b82f6 50%, #60a5fa 100%);
  --gradient-card:    linear-gradient(135deg, #1e3a8a 0%, #1d4ed8 100%);
  --gradient-sidebar: linear-gradient(180deg, #070d1b 0%, #0d1628 100%);
  --gradient-glow:    radial-gradient(ellipse at 50% 0%, rgba(59,130,246,0.2) 0%, transparent 70%);

  /* Animation */
  --transition-fast:   150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow:   400ms ease;

  /* Shadows */
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.08);
  --shadow-md:  0 4px 12px rgba(0,0,0,0.15), 0 2px 6px rgba(0,0,0,0.10);
  --shadow-lg:  0 10px 30px rgba(0,0,0,0.2),  0 4px 12px rgba(0,0,0,0.12);
  --shadow-xl:  0 20px 60px rgba(0,0,0,0.25), 0 8px 20px rgba(0,0,0,0.15);
  --shadow-blue: 0 4px 20px rgba(59,130,246,0.3);

  /* Border Radius */
  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  16px;
  --radius-xl:  24px;
  --radius-full: 9999px;
}

/* ---- DARK MODE (default) ---------------------------------- */
[data-theme="dark"], :root {
  --bg-base:     #070d1b;
  --bg-surface:  #0d1628;
  --bg-card:     #111f35;
  --bg-card-hover: #162540;
  --bg-input:    #0d1628;
  --bg-overlay:  rgba(7,13,27,0.85);

  --sidebar-bg:  #070d1b;
  --sidebar-border: rgba(59,130,246,0.12);
  --sidebar-item-hover: rgba(59,130,246,0.1);
  --sidebar-item-active: rgba(59,130,246,0.2);

  --border:      rgba(59,130,246,0.15);
  --border-hover: rgba(59,130,246,0.35);

  --text-primary:   #e8f0fe;
  --text-secondary: #94a3b8;
  --text-muted:     #475569;
  --text-accent:    #60a5fa;

  --accent:       #3b82f6;
  --accent-hover: #2563eb;
  --accent-light: rgba(59,130,246,0.1);

  --success:  #10b981;
  --warning:  #f59e0b;
  --danger:   #ef4444;
  --info:     #06b6d4;

  --scrollbar-track: #0d1628;
  --scrollbar-thumb: #1d4ed8;
}

/* ---- LIGHT MODE ------------------------------------------- */
[data-theme="light"] {
  --bg-base:     #f0f7ff;
  --bg-surface:  #e8f3ff;
  --bg-card:     #ffffff;
  --bg-card-hover: #f8fbff;
  --bg-input:    #ffffff;
  --bg-overlay:  rgba(240,247,255,0.85);

  --sidebar-bg:  #0f2044;
  --sidebar-border: rgba(255,255,255,0.08);
  --sidebar-item-hover: rgba(255,255,255,0.1);
  --sidebar-item-active: rgba(255,255,255,0.2);

  --border:      rgba(59,130,246,0.2);
  --border-hover: rgba(59,130,246,0.4);

  --text-primary:   #0f172a;
  --text-secondary: #475569;
  --text-muted:     #94a3b8;
  --text-accent:    #2563eb;

  --accent:       #2563eb;
  --accent-hover: #1d4ed8;
  --accent-light: rgba(37,99,235,0.08);

  --success:  #059669;
  --warning:  #d97706;
  --danger:   #dc2626;
  --info:     #0891b2;

  --scrollbar-track: #e8f3ff;
  --scrollbar-thumb: #3b82f6;
}

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

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

body {
  font-family: var(--font-sans);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  transition: background var(--transition-normal), color var(--transition-normal);
  overflow-x: hidden;
}

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

/* ---- Layout ----------------------------------------------- */
.app-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  grid-template-rows: 1fr;
  min-height: 100vh;
}

@media (max-width: 1024px) {
  .app-layout { grid-template-columns: 1fr; }
}

/* ---- Sidebar ---------------------------------------------- */
.sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
  z-index: 50;
  transition: transform var(--transition-normal);
}

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

.sidebar-logo-text {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-logo-sub {
  font-size: 0.65rem;
  color: var(--text-muted);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-top: 2px;
}

.sidebar-nav { flex: 1; padding: 16px 10px; }

.sidebar-section-title {
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 12px 10px 6px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  color: rgba(255,255,255,0.55);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: all var(--transition-fast);
  margin-bottom: 2px;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.sidebar-item:hover {
  background: var(--sidebar-item-hover);
  color: rgba(255,255,255,0.9);
}

.sidebar-item.active {
  background: var(--sidebar-item-active);
  color: var(--blue-400);
  border-left: 3px solid var(--blue-500);
}

[data-theme="light"] .sidebar-item { color: rgba(255,255,255,0.6); }
[data-theme="light"] .sidebar-item:hover { color: rgba(255,255,255,0.95); }
[data-theme="light"] .sidebar-item.active { color: #93c5fd; }

.sidebar-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.8;
}

.sidebar-badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: 0.625rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: 16px 10px;
  border-top: 1px solid var(--sidebar-border);
}

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

/* Mobile sidebar overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 40;
}

@media (max-width: 1024px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
}

/* ---- Main Content ----------------------------------------- */
.main-content {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-base);
}

/* ---- Topbar ----------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: blur(12px);
}

.topbar-search {
  flex: 1;
  max-width: 420px;
  position: relative;
}

.topbar-search input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 8px 16px 8px 40px;
  font-size: 0.875rem;
  color: var(--text-primary);
  outline: none;
  transition: border var(--transition-fast), box-shadow var(--transition-fast);
}

.topbar-search input::placeholder { color: var(--text-muted); }

.topbar-search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.topbar-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  width: 16px;
  height: 16px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

/* ---- Page Content ----------------------------------------- */
.page-body {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

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

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ---- Cards ------------------------------------------------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}

.card:hover { border-color: var(--border-hover); }

.card-premium {
  background: linear-gradient(135deg, var(--bg-card) 0%, rgba(30,58,138,0.15) 100%);
  border: 1px solid rgba(59,130,246,0.25);
  box-shadow: var(--shadow-md);
}

.card-clickable {
  cursor: pointer;
}

.card-clickable:hover {
  background: var(--bg-card-hover);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

/* ---- Stat Cards ------------------------------------------- */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all var(--transition-normal);
}

.stat-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-blue);
  transform: translateY(-1px);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 4px;
  font-weight: 500;
}

/* ---- Buttons ---------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  outline: none;
  text-decoration: none;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--gradient-primary);
  color: #fff;
  box-shadow: var(--shadow-blue);
}
.btn-primary:hover { box-shadow: 0 6px 24px rgba(59,130,246,0.5); filter: brightness(1.1); }

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

.btn-danger {
  background: rgba(239,68,68,0.1);
  color: var(--danger);
  border: 1px solid rgba(239,68,68,0.3);
}
.btn-danger:hover { background: rgba(239,68,68,0.2); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
}
.btn-ghost:hover { background: var(--accent-light); color: var(--accent); }

.btn-sm { padding: 6px 12px; font-size: 0.8125rem; }
.btn-lg { padding: 12px 24px; font-size: 1rem; }
.btn-icon { padding: 8px; border-radius: var(--radius-sm); }

/* ---- Inputs ----------------------------------------------- */
.form-group { margin-bottom: 16px; }

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

.form-control {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 9px 14px;
  font-size: 0.875rem;
  color: var(--text-primary);
  font-family: var(--font-sans);
  outline: none;
  transition: border var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control::placeholder { color: var(--text-muted); }

.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* ---- Badges ----------------------------------------------- */
.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.badge-status-orcamento  { background: rgba(99,102,241,0.12); color: #818cf8; }
.badge-status-orcamento::before { background: #818cf8; }
.badge-status-andamento  { background: rgba(59,130,246,0.12); color: #60a5fa; }
.badge-status-andamento::before { background: #60a5fa; }
.badge-status-revisao    { background: rgba(245,158,11,0.12); color: #fbbf24; }
.badge-status-revisao::before { background: #fbbf24; }
.badge-status-entregue   { background: rgba(16,185,129,0.12); color: #34d399; }
.badge-status-entregue::before { background: #34d399; }
.badge-status-arquivado  { background: rgba(100,116,139,0.12); color: #94a3b8; }
.badge-status-arquivado::before { background: #94a3b8; }

/* ---- Avatar ----------------------------------------------- */
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--gradient-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
}

.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 28px; height: 28px; font-size: 0.625rem; }
.avatar-lg { width: 48px; height: 48px; font-size: 0.875rem; }
.avatar-xl { width: 64px; height: 64px; font-size: 1rem; }

/* ---- Modal ------------------------------------------------ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(6px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
}

.modal-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  transform: translateY(20px) scale(0.97);
  transition: transform var(--transition-normal);
}

.modal-backdrop.open .modal {
  transform: translateY(0) scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-card);
  z-index: 2;
}

.modal-title {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ---- Toast ------------------------------------------------ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 360px;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  box-shadow: var(--shadow-xl);
  animation: toast-in 0.3s ease forwards;
  border-left: 3px solid var(--accent);
}

.toast.toast-success { border-left-color: var(--success); }
.toast.toast-error   { border-left-color: var(--danger);  }
.toast.toast-warning { border-left-color: var(--warning); }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(20px); }
}

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

table.crm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.crm-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.crm-table td {
  padding: 14px 16px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

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

.crm-table tbody tr {
  transition: background var(--transition-fast);
  cursor: pointer;
}

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

/* ---- Kanban ----------------------------------------------- */
.kanban-board {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding: 4px 0 16px;
  min-height: calc(100vh - 200px);
}

.kanban-col {
  flex-shrink: 0;
  width: 280px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 200px);
}

.kanban-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: grab;
}

.kanban-col-title {
  font-size: 0.875rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.kanban-col-count {
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.kanban-cards-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.kanban-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
}

.kanban-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-blue);
  transform: translateY(-1px);
}

.kanban-card.sortable-ghost {
  opacity: 0.4;
  background: var(--accent-light);
  border: 2px dashed var(--accent);
}

.kanban-card.sortable-drag {
  box-shadow: var(--shadow-xl);
  transform: rotate(2deg) scale(1.02);
}

.kanban-card-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
  line-height: 1.4;
}

.kanban-card-labels {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}

.kanban-card-label {
  padding: 1px 8px;
  border-radius: var(--radius-full);
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.kanban-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  gap: 6px;
}

.kanban-card-date {
  font-size: 0.6875rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.kanban-card-date.overdue { color: var(--danger); }
.kanban-card-date.soon    { color: var(--warning); }

/* Kanban add column button */
.kanban-add-col {
  flex-shrink: 0;
  width: 240px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  padding: 20px;
}

.kanban-add-col:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}

/* ---- Client Card ------------------------------------------ */
.client-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all var(--transition-normal);
  cursor: pointer;
}

.client-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-lg);
  transform: translateY(-3px);
}

.client-card-photo {
  width: 100%;
  height: 140px;
  object-fit: cover;
  background: linear-gradient(135deg, var(--blue-900), var(--blue-700));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--blue-400);
  font-size: 2.5rem;
}

.client-card-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.client-card-body { padding: 16px; }

.client-card-name {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.client-card-meta {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.client-card-wa {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(37,211,102,0.1);
  color: #25d366;
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: background var(--transition-fast);
  width: 100%;
  justify-content: center;
}

.client-card-wa:hover { background: rgba(37,211,102,0.2); }

/* ---- Before / After --------------------------------------- */
.before-after-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.before-after-item {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  aspect-ratio: 4/3;
  display: flex;
  align-items: center;
  justify-content: center;
}

.before-after-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.before-after-label {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  backdrop-filter: blur(4px);
}

.before-after-upload {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
}

.before-after-upload:hover { color: var(--accent); }

/* ---- Notification Bell ------------------------------------ */
.notif-bell {
  position: relative;
  cursor: pointer;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.notif-bell:hover { border-color: var(--accent); color: var(--accent); }

.notif-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--danger);
  color: #fff;
  font-size: 0.5625rem;
  font-weight: 800;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg-base);
  animation: pulse-bell 2s infinite;
}

@keyframes pulse-bell {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.2); }
}

/* ---- Notification Dropdown -------------------------------- */
.notif-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 340px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  z-index: 90;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all var(--transition-normal);
}

.notif-dropdown.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.notif-dropdown-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.875rem;
  font-weight: 700;
}

.notif-item {
  padding: 12px 16px;
  display: flex;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--bg-surface); }
.notif-item.unread { background: var(--accent-light); }

.notif-item-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
}

.notif-item-time {
  font-size: 0.6875rem;
  color: var(--text-muted);
  margin-top: 3px;
}

/* ---- Dark Mode Toggle ------------------------------------ */
.theme-toggle {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }

/* ---- Progress Bar ---------------------------------------- */
.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--gradient-primary);
  border-radius: var(--radius-full);
  transition: width 0.6s ease;
}

/* ---- Search Results --------------------------------------- */
.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  z-index: 90;
  max-height: 360px;
  overflow-y: auto;
  display: none;
}

.search-results.open { display: block; }

.search-result-item {
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.875rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition-fast);
}

.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--bg-surface); }

.search-result-type {
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background: var(--accent-light);
  color: var(--accent);
  flex-shrink: 0;
}

/* ---- Delivery Library ------------------------------------ */
.delivered-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.delivered-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.delivered-item:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.delivered-item-thumb {
  height: 120px;
  background: linear-gradient(135deg, var(--blue-900), var(--blue-800));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}

.delivered-item-info { padding: 12px; }

.delivered-item-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.delivered-item-meta {
  font-size: 0.6875rem;
  color: var(--text-muted);
}

/* ---- Misc utils ------------------------------------------ */
.divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.text-gradient {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.glow-border {
  border: 1px solid rgba(59,130,246,0.3);
  box-shadow: 0 0 20px rgba(59,130,246,0.1);
}

.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Fade in animation */
@keyframes fade-in  { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slide-in { from { opacity: 0; transform: translateX(-12px); } to { opacity: 1; transform: translateX(0); } }

.animate-fade-in  { animation: fade-in  0.35s ease forwards; }
.animate-slide-in { animation: slide-in 0.3s ease forwards; }

/* Loading spinner */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Responsive ------------------------------------------ */
@media (max-width: 768px) {
  .page-body { padding: 16px; }
  .topbar    { padding: 12px 16px; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .before-after-grid { grid-template-columns: 1fr; }
  .delivered-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
  .delivered-grid { grid-template-columns: 1fr; }
  .kanban-board   { padding-bottom: 24px; }
}

/* ---- Print ------------------------------------------------ */
@media print {
  .sidebar, .topbar, .btn { display: none !important; }
  .main-content { display: block; }
  body { background: #fff; color: #000; }
}

/* ---- Dashboard Enhancements ------------------------------ */
.sales-card {
  position: relative;
  overflow: hidden;
}

.sales-card::after {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(59,130,246,0.1) 0%, transparent 70%);
  z-index: 0;
}

.delta-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 700;
}
.delta-up { background: rgba(16,185,129,0.1); color: var(--success); }
.delta-down { background: rgba(239,68,68,0.1); color: var(--danger); }

/* Donut Chart */
.chart-container {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 180px;
  height: 180px;
}

.donut-chart {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.donut-ring {
  fill: none;
  stroke: var(--border);
  stroke-width: 3;
}

.donut-segment {
  fill: none;
  stroke-width: 4;
  stroke-linecap: round;
  transition: stroke-dasharray 0.5s ease;
}

.chart-center-text {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

/* Board Gallery (Submenu) */
.board-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.board-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  transition: all var(--transition-normal);
  display: flex;
  flex-direction: column;
  border-top: 4px solid var(--accent);
}

.board-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-xl);
}

.board-card-header {
  padding: 20px;
  background: linear-gradient(180deg, rgba(255,255,255,0.03) 0%, transparent 100%);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.board-card-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
}

.board-card-stats {
  padding: 16px 20px;
  display: flex;
  gap: 16px;
  border-top: 1px solid var(--border);
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.board-placeholder {
  border: 2px dashed var(--border);
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-xl);
  transition: all var(--transition-fast);
}

.board-placeholder:hover {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent);
}

/* Animations */
@keyframes fadeInSlideUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-fade-in {
  animation: fadeInSlideUp 0.4s ease-out forwards;
}

/* Modal Styles */
#card-detail-modal .modal {
    border-radius: var(--radius-xl);
    height: 85vh;
    max-height: 85vh;
    box-shadow: var(--shadow-xl);
    width: 100%;
    margin: auto;
}

.loader-sm {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 40px auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

#card-chat-history::-webkit-scrollbar { width: 5px; }
#card-chat-history::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
