/* ==============================================================================
   mdsabirali.com – Master Application 2.0
   Enterprise Design System Specification & Theme Architecture (DS-1)
   Inspired by Linear, Stripe, Attio & shadcn/ui
   ============================================================================== */

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

:root {
  /* 1. Surfaces & Canvases (Light) */
  --bg-canvas: #f8fafc;
  --bg-card: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-hover: #f1f5f9;
  --bg-active: #e2e8f0;

  /* 2. Typography Colors (Light) */
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-faint: #94a3b8;

  /* 3. Borders & Separators (Light) */
  --border-default: #e2e8f0;
  --border-subtle: #f1f5f9;
  --border-strong: #cbd5e1;

  /* 4. Brand & Primary Accents (Electric Blue / Linear Indigo) */
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-subtle: #eff6ff;
  --primary-text: #1d4ed8;

  /* 5. Semantic Status Colors */
  --emerald: #10b981;
  --emerald-subtle: #ecfdf5;
  --emerald-border: #a7f3d0;
  --emerald-text: #065f46;

  --amber: #f59e0b;
  --amber-subtle: #fffbeb;
  --amber-border: #fde68a;
  --amber-text: #92400e;

  --rose: #ef4444;
  --rose-subtle: #fef2f2;
  --rose-border: #fecaca;
  --rose-text: #991b1b;

  --sky: #0284c7;
  --sky-subtle: #f0f9ff;
  --sky-border: #bae6fd;
  --sky-text: #0369a1;

  /* 6. Sidebar (Default Dark Slate for Maximum Optical Contrast) */
  --sidebar-bg: #090d16;
  --sidebar-border: #1e293b;
  --sidebar-hover: #131b2e;
  --sidebar-active: #1e293b;
  --sidebar-text: #94a3b8;
  --sidebar-text-active: #ffffff;

  /* 7. Metric Radii & Shadows */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.07), 0 1px 2px -1px rgba(0 0 0 / 0.07);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0 0 0 / 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0 0 0 / 0.04);
  --shadow-modal: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

/* ==============================================================================
   DARK THEME TOKENS (Linear / Vercel Aesthetic)
   ============================================================================== */
.dark {
  --bg-canvas: #090d16;
  --bg-card: #0f172a;
  --bg-subtle: #131b2e;
  --bg-hover: #1e293b;
  --bg-active: #273549;

  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-faint: #64748b;

  --border-default: #1e293b;
  --border-subtle: #131b2e;
  --border-strong: #334155;

  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-subtle: rgba(59, 130, 246, 0.15);
  --primary-text: #93c5fd;

  --emerald: #10b981;
  --emerald-subtle: rgba(16, 185, 129, 0.15);
  --emerald-border: rgba(16, 185, 129, 0.3);
  --emerald-text: #6ee7b7;

  --amber: #f59e0b;
  --amber-subtle: rgba(245, 158, 11, 0.15);
  --amber-border: rgba(245, 158, 11, 0.3);
  --amber-text: #fcd34d;

  --rose: #ef4444;
  --rose-subtle: rgba(239, 68, 68, 0.15);
  --rose-border: rgba(239, 68, 68, 0.3);
  --rose-text: #fca5a5;

  --sky: #38bdf8;
  --sky-subtle: rgba(56, 189, 248, 0.15);
  --sky-border: rgba(56, 189, 248, 0.3);
  --sky-text: #7dd3fc;

  --sidebar-bg: #05080f;
  --sidebar-border: #131b2e;
  --sidebar-hover: #0d1424;
  --sidebar-active: #1e293b;

  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.5);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
}

/* Base Document Typography & Transitions */
html {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  letter-spacing: -0.011em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  margin: 0;
  padding: 0;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.font-mono {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace !important;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-faint);
}

/* ==============================================================================
   SIDEBAR & NAVIGATION ARCHITECTURE
   ============================================================================== */
.app-sidebar {
  background-color: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  color: #f8fafc;
  transition: width 0.22s cubic-bezier(0.4, 0, 0.2, 1), transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  width: 268px;
}

.app-sidebar.collapsed {
  width: 68px;
}

.app-sidebar.collapsed .sidebar-text,
.app-sidebar.collapsed .sidebar-section-title,
.app-sidebar.collapsed .sidebar-badge {
  display: none !important;
}

.app-sidebar.collapsed .sidebar-nav-item {
  justify-content: center;
  padding: 8px 0;
}

.app-sidebar.collapsed .sidebar-group-header {
  justify-content: center;
  padding: 6px 0;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.12s ease;
  position: relative;
}

.sidebar-nav-item:hover {
  background-color: var(--sidebar-hover);
  color: #ffffff;
}

.sidebar-nav-item.active {
  background-color: var(--sidebar-active);
  color: #ffffff;
  font-weight: 600;
}

.sidebar-nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 3px;
  border-radius: 0 2px 2px 0;
  background-color: var(--primary);
}

.sidebar-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #475569;
  padding: 0 10px;
  margin-bottom: 4px;
}

/* Mobile responsive drawer */
@media (max-width: 768px) {
  .app-sidebar {
    position: fixed !important;
    top: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 280px !important;
    max-width: 85vw !important;
    transform: translateX(-100%) !important;
    z-index: 50 !important;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
    overflow-y: auto !important;
  }
  .app-sidebar.mobile-open {
    transform: translateX(0) !important;
  }
  .app-sidebar.collapsed {
    width: 280px !important;
  }
  .app-sidebar.collapsed .sidebar-text,
  .app-sidebar.collapsed .sidebar-section-title,
  .app-sidebar.collapsed .sidebar-badge {
    display: inline !important;
  }
  .app-sidebar.collapsed .sidebar-group-header .sidebar-text {
    display: flex !important;
  }
  .app-sidebar.collapsed .chevron-icon {
    display: inline-block !important;
  }
  #sidebar-backdrop {
    z-index: 40 !important;
  }
}

/* ==============================================================================
   HEADER & BREADCRUMBS
   ============================================================================== */
.app-header {
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-default);
  height: 56px;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

/* ==============================================================================
   DATA TABLE DENSITY SYSTEM (Configurable Compact vs Comfortable)
   ============================================================================== */
.data-table-container {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background-color: var(--bg-card);
}

.enterprise-data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  text-align: left;
}

.enterprise-data-table thead th {
  background-color: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-default);
  position: sticky;
  top: 0;
  z-index: 10;
  user-select: none;
}

/* Density: Comfortable */
.table-comfortable thead th {
  padding: 11px 16px;
}
.table-comfortable tbody td {
  padding: 13px 16px;
  font-size: 13.5px;
}

/* Density: Compact (Stripe / Linear High Information Density) */
.table-compact thead th {
  padding: 7px 12px;
  font-size: 10.5px;
}
.table-compact tbody td {
  padding: 7px 12px;
  font-size: 12.5px;
}

.enterprise-data-table tbody tr {
  border-bottom: 1px solid var(--border-subtle);
  transition: background-color 0.1s ease;
}

.enterprise-data-table tbody tr:hover {
  background-color: var(--bg-hover);
}

/* ==============================================================================
   BUTTON DESIGN SYSTEM
   ============================================================================== */
.btn-enterprise {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 600;
  font-size: 12px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  transition: all 0.12s ease;
  cursor: pointer;
  border: 1px solid transparent;
  outline: none;
  white-space: nowrap;
}

.btn-enterprise:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
  box-shadow: var(--shadow-xs);
}
.btn-primary:hover:not(:disabled) {
  background-color: var(--primary-hover);
}

.btn-secondary {
  background-color: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border-default);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover:not(:disabled) {
  background-color: var(--bg-hover);
  border-color: var(--border-strong);
}

.btn-ghost {
  background-color: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover:not(:disabled) {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.btn-destructive {
  background-color: var(--rose-subtle);
  color: var(--rose-text);
  border-color: var(--rose-border);
}
.btn-destructive:hover:not(:disabled) {
  background-color: var(--rose);
  color: #ffffff;
}

/* ==============================================================================
   STATUS PILLS & BADGES
   ============================================================================== */
.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
}

.badge-emerald {
  background-color: var(--emerald-subtle);
  color: var(--emerald-text);
  border: 1px solid var(--emerald-border);
}

.badge-amber {
  background-color: var(--amber-subtle);
  color: var(--amber-text);
  border: 1px solid var(--amber-border);
}

.badge-rose {
  background-color: var(--rose-subtle);
  color: var(--rose-text);
  border: 1px solid var(--rose-border);
}

.badge-sky {
  background-color: var(--sky-subtle);
  color: var(--sky-text);
  border: 1px solid var(--sky-border);
}

.badge-slate {
  background-color: var(--bg-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
}

/* Pulse indicator dot */
.indicator-pulse {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  position: relative;
}
.indicator-pulse::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  background: inherit;
  opacity: 0.6;
  animation: pulseRing 1.8s cubic-bezier(0.24, 0, 0.38, 1) infinite;
}

@keyframes pulseRing {
  0% { transform: scale(0.9); opacity: 0.8; }
  70% { transform: scale(2.2); opacity: 0; }
  100% { transform: scale(2.2); opacity: 0; }
}

/* ==============================================================================
   CMD + K COMMAND PALETTE MODAL
   ============================================================================== */
.cmd-palette-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(9, 13, 22, 0.65);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
  padding-left: 16px;
  padding-right: 16px;
}

.cmd-palette-modal {
  width: 100%;
  max-width: 600px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
  overflow: hidden;
  animation: cmdAppear 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes cmdAppear {
  from { opacity: 0; transform: scale(0.97) translateY(-8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.cmd-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  transition: background-color 0.1s ease;
}

.cmd-item:hover,
.cmd-item.selected {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.cmd-item.selected .cmd-shortcut {
  border-color: var(--border-strong);
}

/* ==============================================================================
   MICRO-INTERACTIONS & ACCESSIBILITY
   ============================================================================== */
.skeleton-shimmer {
  background: linear-gradient(
    90deg,
    var(--bg-subtle) 25%,
    var(--bg-hover) 37%,
    var(--bg-subtle) 63%
  );
  background-size: 400% 100%;
  animation: skeletonShimmer 1.4s ease infinite;
}

@keyframes skeletonShimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

/* Toast Notifications Container */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  padding: 10px 16px;
  border-radius: var(--radius-md);
  color: #ffffff;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  animation: slideToastIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast.success { background-color: #059669; }
.toast.error { background-color: #dc2626; }
.toast.info { background-color: #2563eb; }

@keyframes slideToastIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ==============================================================================
   SIDEBAR COLLAPSIBLE GROUPS & NAVIGATION DYNAMICS
   ============================================================================== */
.sidebar-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: transparent;
  border: none;
  color: var(--sidebar-text);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  transition: all 0.12s ease;
  user-select: none;
  text-align: left;
}

.sidebar-group-header:hover {
  color: #ffffff;
  background-color: var(--sidebar-hover);
}

.sidebar-group-header .chevron-icon {
  font-size: 9px;
  transition: transform 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  color: #64748b;
}

.sidebar-group.collapsed .chevron-icon {
  transform: rotate(-90deg);
}

.sidebar-group.collapsed .sidebar-group-content {
  display: none !important;
}

.sidebar-group-content {
  margin-top: 2px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

/* Theme Toggle Visibility */
.dark .dark-hidden {
  display: none !important;
}
html:not(.dark) .light-hidden {
  display: none !important;
}

/* Table Density Global Overrides */
[data-table-density="compact"] .enterprise-data-table thead th,
[data-table-density="compact"] table thead th {
  padding: 6px 10px !important;
  font-size: 10.5px !important;
}
[data-table-density="compact"] .enterprise-data-table tbody td,
[data-table-density="compact"] table tbody td {
  padding: 6px 10px !important;
  font-size: 12px !important;
  line-height: 1.3 !important;
}

[data-table-density="comfortable"] .enterprise-data-table thead th,
[data-table-density="comfortable"] table thead th {
  padding: 11px 16px !important;
  font-size: 11px !important;
}
[data-table-density="comfortable"] .enterprise-data-table tbody td,
[data-table-density="comfortable"] table tbody td {
  padding: 12px 16px !important;
  font-size: 13.5px !important;
}

/* Breadcrumb Styles */
.breadcrumb-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  transition: color 0.12s ease;
}
.breadcrumb-item:hover {
  color: var(--text-primary);
}
.breadcrumb-separator {
  color: var(--border-strong);
  font-size: 9px;
}
.breadcrumb-current {
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
}

/* Global Dark Mode Tailwind Bridge */
.dark .bg-white {
  background-color: var(--bg-card) !important;
}
.dark .bg-slate-50 {
  background-color: var(--bg-canvas) !important;
}
.dark .bg-slate-100 {
  background-color: var(--bg-subtle) !important;
}
.dark .bg-slate-200 {
  background-color: var(--bg-hover) !important;
}
.dark .text-slate-900, .dark .text-slate-800 {
  color: var(--text-primary) !important;
}
.dark .text-slate-700, .dark .text-slate-600 {
  color: var(--text-secondary) !important;
}
.dark .text-slate-500, .dark .text-slate-400 {
  color: var(--text-muted) !important;
}
.dark .border-slate-100, .dark .border-slate-200, .dark .border-slate-300 {
  border-color: var(--border-default) !important;
}
.dark .hover\:bg-slate-50:hover {
  background-color: var(--bg-hover) !important;
}
.dark .hover\:bg-slate-100:hover {
  background-color: var(--bg-hover) !important;
}
.dark input:not([type="checkbox"]):not([type="radio"]),
.dark select,
.dark textarea {
  background-color: var(--bg-subtle) !important;
  color: var(--text-primary) !important;
  border-color: var(--border-default) !important;
}
.dark input:focus, .dark select:focus, .dark textarea:focus {
  border-color: var(--primary) !important;
  background-color: var(--bg-card) !important;
}

@media (prefers-reduced-motion: reduce) {
  *, ::before, ::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
