@import "tailwindcss";

/* ============================================================
   DhanGenie Design System v1.0
   Inspired by Linear, Vercel, Stripe
   ============================================================ */

@theme {
  /* ---- Color Palette (Light) ---- */
  --color-surface-0: #ffffff;
  --color-surface-1: #f8f9fb;
  --color-surface-2: #f1f3f5;
  --color-surface-3: #e9ecef;
  --color-border: #dee2e6;
  --color-border-subtle: #edf0f2;
  --color-text-primary: #111827;
  --color-text-secondary: #6b7280;
  --color-text-tertiary: #9ca3af;
  --color-text-inverse: #ffffff;

  /* ---- Brand ---- */
  --color-brand-50: #eef2ff;
  --color-brand-100: #dce5fe;
  --color-brand-200: #bfcffe;
  --color-brand-300: #93acfd;
  --color-brand-400: #6580f9;
  --color-brand-500: #4f5ef5;
  --color-brand-600: #3b3de9;
  --color-brand-700: #3230d0;
  --color-brand-800: #2b29a8;
  --color-brand-900: #292884;

  /* ---- Semantic ---- */
  --color-success: #10b981;
  --color-success-bg: #ecfdf5;
  --color-warning: #f59e0b;
  --color-warning-bg: #fffbeb;
  --color-danger: #ef4444;
  --color-danger-bg: #fef2f2;
  --color-info: #3b82f6;
  --color-info-bg: #eff6ff;

  /* ---- Typography ---- */
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* ---- Spacing ---- */
  --spacing-px: 1px;
  --spacing-0: 0;
  --spacing-1: 0.25rem;
  --spacing-2: 0.5rem;
  --spacing-3: 0.75rem;
  --spacing-4: 1rem;
  --spacing-5: 1.25rem;
  --spacing-6: 1.5rem;
  --spacing-8: 2rem;
  --spacing-10: 2.5rem;
  --spacing-12: 3rem;
  --spacing-16: 4rem;
  --spacing-20: 5rem;

  /* ---- Radius ---- */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;

  /* ---- Shadows ---- */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 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.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);

  /* ---- Sidebar ---- */
  --sidebar-width: 260px;
  --sidebar-collapsed: 72px;
  --topbar-height: 56px;
}

/* ============================================================
   Dark Mode Overrides
   ============================================================ */
[data-theme="dark"] {
  --color-surface-0: #09090b;
  --color-surface-1: #111113;
  --color-surface-2: #18181b;
  --color-surface-3: #27272a;
  --color-border: #2e2e33;
  --color-border-subtle: #1e1e22;
  --color-text-primary: #fafafa;
  --color-text-secondary: #a1a1aa;
  --color-text-tertiary: #71717a;

  --color-success-bg: #052e16;
  --color-warning-bg: #422006;
  --color-danger-bg: #450a0a;
  --color-info-bg: #172554;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.5);
}

/* ============================================================
   Base Styles
   ============================================================ */
html {
  font-family: var(--font-sans);
  color: var(--color-text-primary);
  background: var(--color-surface-0);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--color-text-tertiary); }

/* ============================================================
   Layout
   ============================================================ */
.dg-layout {
  display: flex;
  min-height: 100vh;
}

.dg-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--color-surface-1);
  border-right: 1px solid var(--color-border-subtle);
  display: flex;
  flex-direction: column;
  z-index: 40;
  transition: width 0.2s ease, transform 0.2s ease;
}

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

.dg-main {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.2s ease;
}

.dg-sidebar.collapsed ~ .dg-main { margin-left: var(--sidebar-collapsed); }

.dg-topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-height);
  background: var(--color-surface-0);
  border-bottom: 1px solid var(--color-border-subtle);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  z-index: 30;
  backdrop-filter: blur(12px);
  background: rgba(255, 255, 255, 0.8);
}

[data-theme="dark"] .dg-topbar {
  background: rgba(9, 9, 11, 0.8);
}

.dg-content {
  flex: 1;
  padding: 1.5rem;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* ============================================================
   Components
   ============================================================ */

/* ---- Card ---- */
.dg-card {
  background: var(--color-surface-0);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-xs);
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.dg-card:hover {
  box-shadow: var(--shadow-sm);
  border-color: var(--color-border);
}

/* ---- Button ---- */
.dg-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.dg-btn-primary {
  background: var(--color-brand-500);
  color: white;
}
.dg-btn-primary:hover { background: var(--color-brand-600); }
.dg-btn-secondary {
  background: var(--color-surface-1);
  color: var(--color-text-primary);
  border-color: var(--color-border);
}
.dg-btn-secondary:hover { background: var(--color-surface-2); }
.dg-btn-danger {
  background: var(--color-danger);
  color: white;
}
.dg-btn-danger:hover { opacity: 0.9; }
.dg-btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
}
.dg-btn-ghost:hover {
  background: var(--color-surface-2);
  color: var(--color-text-primary);
}
.dg-btn-sm { padding: 0.375rem 0.75rem; font-size: 0.75rem; }
.dg-btn-lg { padding: 0.625rem 1.25rem; font-size: 0.875rem; }

/* ---- Badge ---- */
.dg-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.025em;
}
.dg-badge-success { background: var(--color-success-bg); color: var(--color-success); }
.dg-badge-warning { background: var(--color-warning-bg); color: var(--color-warning); }
.dg-badge-danger { background: var(--color-danger-bg); color: var(--color-danger); }
.dg-badge-info { background: var(--color-info-bg); color: var(--color-info); }

/* ---- Table ---- */
.dg-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.8125rem;
}
.dg-table th {
  text-align: left;
  font-weight: 500;
  color: var(--color-text-secondary);
  padding: 0.625rem 1rem;
  border-bottom: 1px solid var(--color-border-subtle);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.dg-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-border-subtle);
  color: var(--color-text-primary);
}
.dg-table tr:hover td { background: var(--color-surface-1); }

/* ---- Form ---- */
.dg-input {
  display: block;
  width: 100%;
  font-size: 0.8125rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-0);
  color: var(--color-text-primary);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.dg-input:focus {
  outline: none;
  border-color: var(--color-brand-400);
  box-shadow: 0 0 0 3px var(--color-brand-100);
}
[data-theme="dark"] .dg-input:focus {
  box-shadow: 0 0 0 3px rgba(79, 94, 245, 0.2);
}
.dg-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  margin-bottom: 0.375rem;
  color: var(--color-text-primary);
}

/* ---- Nav Item ---- */
.dg-nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all 0.1s ease;
  text-decoration: none;
}
.dg-nav-item:hover {
  background: var(--color-surface-2);
  color: var(--color-text-primary);
}
.dg-nav-item.active {
  background: var(--color-brand-50);
  color: var(--color-brand-600);
  font-weight: 500;
}
[data-theme="dark"] .dg-nav-item.active {
  background: rgba(79, 94, 245, 0.12);
  color: var(--color-brand-400);
}

/* ---- Skeleton ---- */
.dg-skeleton {
  background: linear-gradient(90deg, var(--color-surface-2) 25%, var(--color-surface-3) 50%, var(--color-surface-2) 75%);
  background-size: 200% 100%;
  animation: dg-shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}
@keyframes dg-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---- Command Palette ---- */
.dg-command-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 20vh;
}
.dg-command-overlay.open { display: flex; }
.dg-command-box {
  width: 100%;
  max-width: 560px;
  background: var(--color-surface-0);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
}
.dg-command-input {
  width: 100%;
  padding: 1rem 1.25rem;
  border: none;
  background: transparent;
  font-size: 0.9375rem;
  color: var(--color-text-primary);
  outline: none;
  border-bottom: 1px solid var(--color-border-subtle);
}
.dg-command-results {
  max-height: 320px;
  overflow-y: auto;
  padding: 0.5rem;
}
.dg-command-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.75rem;
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
  cursor: pointer;
}
.dg-command-item:hover, .dg-command-item.selected {
  background: var(--color-surface-2);
  color: var(--color-text-primary);
}

/* ---- Modal ---- */
.dg-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 90;
  display: none;
  align-items: center;
  justify-content: center;
}
.dg-modal-overlay.open { display: flex; }
.dg-modal {
  background: var(--color-surface-0);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
}

/* ---- Empty State ---- */
.dg-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--color-text-tertiary);
}

/* ---- Toast ---- */
.dg-toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 110;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.dg-toast {
  background: var(--color-surface-0);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 0.75rem 1rem;
  box-shadow: var(--shadow-lg);
  font-size: 0.8125rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: dg-slide-up 0.2s ease;
}
@keyframes dg-slide-up {
  from { transform: translateY(1rem); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1024px) {
  .dg-sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width);
  }
  .dg-sidebar.mobile-open { transform: translateX(0); }
  .dg-main { margin-left: 0; }
}

@media (max-width: 640px) {
  .dg-content { padding: 1rem; }
  .dg-table { font-size: 0.75rem; }
  .dg-table th, .dg-table td { padding: 0.5rem; }
}
