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

:root {
  --color-primary: #6366f1;
  --color-secondary: #8b5cf6;
  --color-accent: #06b6d4;
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-danger: #ef4444;
  --color-bg: #0a0a14;
  --color-surface: #131323;
  --color-card: rgba(255, 255, 255, 0.04);
  --color-glass-border: rgba(255, 255, 255, 0.10);
  --color-text: #f1f5f9;
  --color-text-muted: #94a3b8;
  --sidebar-width: 240px;
}

* { box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--color-bg);
  color: var(--color-text);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ─── Glassmorphism ─────────────────────────────────────────── */
.glass {
  background: var(--color-card);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--color-glass-border);
  box-shadow: 0 4px 24px rgba(0,0,0,0.3);
}

.glass-dark {
  background: rgba(10,10,20,0.75);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(255,255,255,0.07);
}

/* ─── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  transition: transform 0.3s ease, left 0.3s ease;
  background: rgba(10, 10, 22, 0.92);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: calc(-1 * var(--sidebar-width));
    z-index: 50;
  }
  .sidebar.mobile-open {
    left: 0;
  }
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.sidebar-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.scrollbar-hide::-webkit-scrollbar { display: none; }
.scrollbar-hide { -ms-overflow-style: none; scrollbar-style: none; }

/* ─── KPI Cards ──────────────────────────────────────────────── */
.kpi-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 1rem;
  padding: 1.25rem;
  transition: border-color 0.2s, transform 0.2s;
}
.kpi-card:hover {
  border-color: rgba(99,102,241,0.35);
  transform: translateY(-2px);
}
.kpi-value {
  font-size: 1.875rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
}

/* ─── Chart Cards ────────────────────────────────────────────── */
.chart-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 1.25rem;
  padding: 1.5rem;
}
.chart-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: #e2e8f0;
  margin-bottom: 0.25rem;
}
.chart-subtitle {
  font-size: 0.7rem;
  color: #64748b;
  margin-bottom: 1rem;
}

/* ─── Stat Trend Pills ────────────────────────────────────────── */
.trend-up   { color: #34d399; font-size: 0.75rem; font-weight: 600; }
.trend-down { color: #f87171; font-size: 0.75rem; font-weight: 600; }
.trend-flat { color: #94a3b8; font-size: 0.75rem; font-weight: 600; }

/* ─── Status Badges ──────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.badge-new        { background: rgba(99,102,241,0.18); color: #a5b4fc; }
.badge-active     { background: rgba(6,182,212,0.18);  color: #67e8f9; }
.badge-won        { background: rgba(16,185,129,0.18); color: #6ee7b7; }
.badge-lost       { background: rgba(239,68,68,0.18);  color: #fca5a5; }
.badge-pending    { background: rgba(245,158,11,0.18); color: #fcd34d; }
.badge-confirmed  { background: rgba(99,102,241,0.18); color: #a5b4fc; }
.badge-completed  { background: rgba(16,185,129,0.18); color: #6ee7b7; }
.badge-overdue    { background: rgba(239,68,68,0.25);  color: #f87171; }
.badge-info       { background: rgba(6,182,212,0.18);  color: #67e8f9; }
.badge-sla        { background: rgba(245,158,11,0.18); color: #fcd34d; }

/* ─── Input / Form ───────────────────────────────────────────── */
.input-glass {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.14);
  color: #f1f5f9;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.input-glass::placeholder { color: #475569; }
.input-glass:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.2);
}
select.input-glass option { background: #131323; }

/* ─── Buttons ────────────────────────────────────────────────── */
.btn-gradient {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: white;
  border: none;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
}
.btn-gradient:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(99,102,241,0.4);
}
.btn-gradient:active { transform: translateY(0); opacity: 0.9; }

.btn-ghost {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.14);
  color: #94a3b8;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-ghost:hover { background: rgba(255,255,255,0.08); color: #f1f5f9; }

.btn-danger {
  background: rgba(239,68,68,0.15);
  border: 1px solid rgba(239,68,68,0.3);
  color: #f87171;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-danger:hover { background: rgba(239,68,68,0.25); }

/* ─── Table ──────────────────────────────────────────────────── */
.crm-table { width: 100%; border-collapse: collapse; }
.crm-table th {
  text-align: left;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.crm-table td {
  padding: 0.875rem 1rem;
  font-size: 0.825rem;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  color: #cbd5e1;
  transition: background 0.15s;
}
.crm-table tr:hover td { background: rgba(255,255,255,0.04); }

/* ─── SLA Timers ─────────────────────────────────────────────── */
.sla-green  { color: #34d399; }
.sla-yellow { color: #fbbf24; }
.sla-red    { color: #f87171; }
.sla-critical {
  color: #f87171;
  animation: pulse-red 1.5s infinite;
}

/* ─── Kanban ─────────────────────────────────────────────────── */
.kanban-col {
  min-width: 280px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 1rem;
}
.kanban-card {
  cursor: grab;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 0.75rem;
  transition: transform 0.15s, box-shadow 0.15s;
}
.kanban-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.kanban-card:active { cursor: grabbing; }

/* ─── Progress Bar ───────────────────────────────────────────── */
.progress-bar {
  height: 6px;
  border-radius: 9999px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 9999px;
  transition: width 0.6s ease;
}

/* ─── Auth Page ──────────────────────────────────────────────── */
.auth-bg {
  background: radial-gradient(ellipse at 20% 50%, rgba(99,102,241,0.15) 0%, transparent 60%),
              radial-gradient(ellipse at 80% 20%, rgba(139,92,246,0.15) 0%, transparent 60%),
              linear-gradient(135deg, #0a0a14 0%, #131323 100%);
}
#auth-canvas { position: absolute; inset: 0; z-index: 0; }
.auth-card { z-index: 10; }

/* ─── Animations ─────────────────────────────────────────────── */
@keyframes pulse-red {
  0%   { box-shadow: 0 0 0 0 rgba(239,68,68,0.6); }
  70%  { box-shadow: 0 0 0 8px rgba(239,68,68,0); }
  100% { box-shadow: 0 0 0 0 rgba(239,68,68,0); }
}
.overdue-pulse { animation: pulse-red 2s infinite; }

@keyframes shimmer {
  0%   { background-position: -1000px 0; }
  100% { background-position: 1000px 0; }
}
.loading-shimmer {
  animation: shimmer 2s infinite linear;
  background: linear-gradient(to right, #1a1a2e 4%, #2a2a3e 25%, #1a1a2e 36%);
  background-size: 1000px 100%;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-in-up { animation: fadeInUp 0.4s ease forwards; }

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-16px); }
  to   { opacity: 1; transform: translateX(0); }
}
.slide-in-left { animation: slideInLeft 0.3s ease forwards; }

@keyframes spin {
  to { transform: rotate(360deg); }
}
.spinner { animation: spin 0.8s linear infinite; }

/* ─── Toast ──────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}
.toast {
  padding: 0.875rem 1.25rem;
  border-radius: 0.875rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  animation: slideInLeft 0.3s ease;
  pointer-events: auto;
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid;
  backdrop-filter: blur(12px);
}
.toast-success { background: rgba(16,185,129,0.15); border-color: rgba(16,185,129,0.3); color: #6ee7b7; }
.toast-error   { background: rgba(239,68,68,0.15);  border-color: rgba(239,68,68,0.3);  color: #fca5a5; }
.toast-info    { background: rgba(99,102,241,0.15); border-color: rgba(99,102,241,0.3); color: #a5b4fc; }

/* ─── Lead Engine Specifics ──────────────────────────────────── */
.sla-countdown { font-variant-numeric: tabular-nums; font-weight: 700; }
.call-gate-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.8);
  backdrop-filter: blur(8px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ─── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #1e293b; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #334155; }

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed !important;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 50 !important;
    transform: translateX(-100%);
    transition: transform 0.3s ease-in-out;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.4);
    width: 260px !important;
    min-width: 260px !important;
  }
  .sidebar.mobile-open {
    transform: translateX(0) !important;
  }
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 45;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }
  .sidebar-backdrop.active {
    opacity: 1;
    pointer-events: auto;
  }
}

@media print {
  .no-print { display: none !important; }
  body { background: white; color: black; }
  .glass, .glass-dark { background: transparent; border: 1px solid #ccc; box-shadow: none; }
}

/* Fix date/time pickers on dark backgrounds */
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
  filter: invert(1);
  cursor: pointer;
  opacity: 0.6;
}
input[type="date"]::-webkit-calendar-picker-indicator:hover,
input[type="time"]::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
}

/* On mobile, make the entire input clickable for the native picker */
@media (max-width: 768px) {
  input[type="date"],
  input[type="time"] {
    position: relative;
    min-height: 2.5rem;
  }
  
  input[type="date"]::-webkit-calendar-picker-indicator,
  input[type="time"]::-webkit-calendar-picker-indicator {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    box-sizing: border-box;
  }
}
