/* 
 * Mediklar.uz - UI Design System (v1.0.0)
 * Visual foundation for the entire Mediklar.uz product ecosystem.
 * Inspired by premium minimal SaaS design: operatora.ai, Linear, Stripe, Notion, Vercel.
 */

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

:root {
  /* ==========================================
     COLOR TOKENS (Brand, UI, Status, Gradients)
     ========================================== */
  --color-primary: #0F172A;        /* Slate Dark Navy */
  --color-primary-light: #1E293B;  
  --color-secondary: #2563EB;      /* Medical Royal Blue */
  --color-secondary-hover: #1D4ED8;
  --color-accent: #0D9488;         /* Soft Teal Accent */
  --color-accent-hover: #0F766E;
  
  --color-bg-main: #F1F5F9;        /* Soft Slate Canvas (Ko'zni qamashtirmaydi, eyecare palette) */
  --color-bg-card: #FFFFFF;        /* Elevated White Card */
  --color-bg-card-glass: rgba(255, 255, 255, 0.88);
  
  --color-border: #E2E8F0;         /* Soft Slate Border */
  --color-border-hover: #CBD5E1;   
  --color-border-focus: #2563EB;   

  /* UI Status Colors */
  --color-status-success: #059669;
  --color-status-success-bg: #ECFDF5;
  --color-status-warning: #D97706;
  --color-status-warning-bg: #FEF3C7;
  --color-status-danger: #DC2626;
  --color-status-danger-bg: #FEF2F2;
  --color-status-info: #2563EB;
  --color-status-info-bg: #EFF6FF;

  /* Typography / Text Colors */
  --color-text-main: #0F172A;      /* Deep Slate (Qop-qora emas, o'qishga o'ta qulay) */
  --color-text-muted: #475569;     /* Soft Muted Text */
  --color-text-light: #64748B;
  --color-text-white: #FFFFFF;

  /* Gradients */
  --grad-primary: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-light) 100%);
  --grad-medical: linear-gradient(135deg, var(--color-secondary) 0%, #3B82F6 100%);
  --grad-teal: linear-gradient(135deg, var(--color-accent) 0%, #2DD4BF 100%);
  --grad-glass: linear-gradient(135deg, rgba(255, 255, 255, 0.8) 0%, rgba(255, 255, 255, 0.3) 100%);
  --grad-glow: radial-gradient(circle, rgba(37,99,235,0.08) 0%, rgba(20,184,166,0.03) 70%, transparent 100%);

  /* ==========================================
     SPACING SYSTEM (Geometric scale: 4px base)
     ========================================== */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
  --space-20: 80px;
  --space-24: 96px;

  /* ==========================================
     BORDER RADIUS SYSTEM (Premium SaaS feel)
     ========================================== */
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;       /* Standard Card Radius (24px) */
  --radius-xxl: 32px;      /* Large layouts / Floating Elements */
  --radius-full: 9999px;

  /* ==========================================
     SHADOW SYSTEM (Layered clean shadows)
     ========================================== */
  --shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.05), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.04), 0 4px 6px -4px rgba(15, 23, 42, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, 0.05), 0 8px 10px -6px rgba(15, 23, 42, 0.05);
  --shadow-glow: 0 0 40px rgba(37, 99, 235, 0.1);
  --shadow-inset: inset 0 2px 4px 0 rgba(0, 0, 0, 0.06);

  /* ==========================================
     GLASSMORPHISM LEVELS
     ========================================== */
  --glass-blur-sm: blur(4px);
  --glass-blur-md: blur(12px);
  --glass-blur-lg: blur(24px);
  --glass-border: rgba(255, 255, 255, 0.4);

  /* ==========================================
     ELEVATION LEVELS (Z-Index Hierarchy)
     ========================================== */
  --z-base: 1;
  --z-sticky: 100;
  --z-drawer: 200;
  --z-modal: 300;
  --z-toast: 400;

  /* ==========================================
     MOTION & ANIMATION PRINCIPLES
     ========================================== */
  --ease-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  
  --dur-fast: 150ms;
  --dur-normal: 250ms;
  --dur-slow: 400ms;

  /* ==========================================
     TYPOGRAPHY SCALE (Base: 16px)
     ========================================== */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-display: 'Manrope', sans-serif;

  --fs-xs: 0.75rem;     /* 12px */
  --fs-sm: 0.875rem;    /* 14px */
  --fs-base: 1rem;      /* 16px */
  --fs-md: 1.125rem;    /* 18px */
  --fs-lg: 1.25rem;     /* 20px */
  --fs-xl: 1.5rem;      /* 24px */
  --fs-xxl: 2rem;       /* 32px */
  --fs-3xl: 2.5rem;     /* 40px */
  --fs-4xl: 3.5rem;     /* 56px */
  --fs-5xl: 4.5rem;     /* 72px */
}

/* ==========================================
   RESET & CORE DEFAULTS
   ========================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--color-bg-main);
  color: var(--color-text-main);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--color-text-main);
  line-height: 1.25;
}

a {
  color: var(--color-secondary);
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease-smooth);
}
a:hover {
  color: var(--color-secondary-hover);
}

img, svg {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ==========================================
   12-COLUMN RESPONSIVE GRID SYSTEM
   ========================================== */
.ds-container {
  width: 100%;
  max-width: 1280px;
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--space-6);
  padding-right: var(--space-6);
}

.ds-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: var(--space-6);
}

/* Column spans (Mobile-first defaults) */
.ds-col-1  { grid-column: span 1; }
.ds-col-2  { grid-column: span 2; }
.ds-col-3  { grid-column: span 3; }
.ds-col-4  { grid-column: span 4; }
.ds-col-5  { grid-column: span 5; }
.ds-col-6  { grid-column: span 6; }
.ds-col-7  { grid-column: span 7; }
.ds-col-8  { grid-column: span 8; }
.ds-col-9  { grid-column: span 9; }
.ds-col-10 { grid-column: span 10; }
.ds-col-11 { grid-column: span 11; }
.ds-col-12 { grid-column: span 12; }

/* Responsive Grid Breakpoints */

/* Medium Devices (Tablets, >= 768px) */
@media (min-width: 768px) {
  .md\:ds-col-1  { grid-column: span 1; }
  .md\:ds-col-2  { grid-column: span 2; }
  .md\:ds-col-3  { grid-column: span 3; }
  .md\:ds-col-4  { grid-column: span 4; }
  .md\:ds-col-5  { grid-column: span 5; }
  .md\:ds-col-6  { grid-column: span 6; }
  .md\:ds-col-7  { grid-column: span 7; }
  .md\:ds-col-8  { grid-column: span 8; }
  .md\:ds-col-9  { grid-column: span 9; }
  .md\:ds-col-10 { grid-column: span 10; }
  .md\:ds-col-11 { grid-column: span 11; }
  .md\:ds-col-12 { grid-column: span 12; }
}

/* Large Devices (Desktops, >= 1024px) */
@media (min-width: 1024px) {
  .lg\:ds-col-1  { grid-column: span 1; }
  .lg\:ds-col-2  { grid-column: span 2; }
  .lg\:ds-col-3  { grid-column: span 3; }
  .lg\:ds-col-4  { grid-column: span 4; }
  .lg\:ds-col-5  { grid-column: span 5; }
  .lg\:ds-col-6  { grid-column: span 6; }
  .lg\:ds-col-7  { grid-column: span 7; }
  .lg\:ds-col-8  { grid-column: span 8; }
  .lg\:ds-col-9  { grid-column: span 9; }
  .lg\:ds-col-10 { grid-column: span 10; }
  .lg\:ds-col-11 { grid-column: span 11; }
  .lg\:ds-col-12 { grid-column: span 12; }
}

/* Extra Large Devices (Large screens, >= 1200px) */
@media (min-width: 1200px) {
  .xl\:ds-col-1  { grid-column: span 1; }
  .xl\:ds-col-2  { grid-column: span 2; }
  .xl\:ds-col-3  { grid-column: span 3; }
  .xl\:ds-col-4  { grid-column: span 4; }
  .xl\:ds-col-5  { grid-column: span 5; }
  .xl\:ds-col-6  { grid-column: span 6; }
  .xl\:ds-col-7  { grid-column: span 7; }
  .xl\:ds-col-8  { grid-column: span 8; }
  .xl\:ds-col-9  { grid-column: span 9; }
  .xl\:ds-col-10 { grid-column: span 10; }
  .xl\:ds-col-11 { grid-column: span 11; }
  .xl\:ds-col-12 { grid-column: span 12; }
}

/* Helper flex layout wrappers */
.flex-row-center {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ==========================================
   BUTTON COMPONENT LIBRARY
   ========================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  font-weight: 600;
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--dur-normal) var(--ease-out);
  gap: var(--space-2);
  text-align: center;
}

.btn-primary {
  background-color: var(--color-primary);
  color: var(--color-text-white);
}
.btn-primary:hover {
  background-color: var(--color-primary-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background-color: var(--color-secondary);
  color: var(--color-text-white);
}
.btn-secondary:hover {
  background-color: var(--color-secondary-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-accent {
  background-color: var(--color-accent);
  color: var(--color-text-white);
}
.btn-accent:hover {
  background-color: var(--color-accent-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-ghost {
  background-color: transparent;
  color: var(--color-text-main);
  border-color: var(--color-border);
}
.btn-ghost:hover {
  background-color: var(--color-bg-main);
  border-color: var(--color-border-hover);
}

.btn-disabled, .btn:disabled {
  background-color: var(--color-border) !important;
  color: var(--color-text-light) !important;
  cursor: not-allowed !important;
  transform: none !important;
  box-shadow: none !important;
}

/* Button Loading State */
.btn-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}
.btn-loading::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  top: 50%;
  left: 50%;
  margin-top: -9px;
  margin-left: -9px;
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: var(--radius-full);
  border-top-color: currentColor;
  animation: ds-spin 0.6s linear infinite;
}
.btn-ghost.btn-loading::after {
  border-color: rgba(15, 23, 42, 0.1);
  border-top-color: var(--color-primary);
}

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

/* ==========================================
   FORM COMPONENT SYSTEM
   ========================================== */
.form-group {
  margin-bottom: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.form-label {
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
}

.form-input, .form-select, .form-textarea {
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background-color: var(--color-bg-card);
  color: var(--color-text-main);
  transition: all var(--dur-normal) var(--ease-smooth);
  width: 100%;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--color-border-focus);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.form-input::placeholder {
  color: var(--color-text-light);
}

/* Error/Success Visual Feedback */
.form-input.is-invalid {
  border-color: var(--color-status-danger);
  background-color: rgba(239, 68, 68, 0.01);
}
.form-input.is-invalid:focus {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}
.form-error-text {
  font-size: var(--fs-xs);
  color: var(--color-status-danger);
  margin-top: 2px;
}

.form-input.is-valid {
  border-color: var(--color-status-success);
}

/* Custom Checkbox & Toggle */
.custom-checkbox {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
  gap: var(--space-3);
  font-size: var(--fs-sm);
  color: var(--color-text-main);
}
.custom-checkbox input {
  display: none;
}
.checkbox-box {
  width: 20px;
  height: 20px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background-color: var(--color-bg-card);
  transition: all var(--dur-fast) var(--ease-smooth);
  position: relative;
  flex-shrink: 0;
}
.custom-checkbox input:checked + .checkbox-box {
  background-color: var(--color-secondary);
  border-color: var(--color-secondary);
}
.custom-checkbox input:checked + .checkbox-box::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 2px;
  width: 6px;
  height: 11px;
  border: solid var(--color-text-white);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* Premium Switch / Toggle */
.custom-toggle {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  gap: var(--space-3);
  font-size: var(--fs-sm);
  user-select: none;
}
.custom-toggle input {
  display: none;
}
.toggle-slider {
  width: 44px;
  height: 24px;
  border-radius: var(--radius-full);
  background-color: var(--color-border);
  position: relative;
  transition: background-color var(--dur-normal) var(--ease-smooth);
  flex-shrink: 0;
}
.toggle-slider::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  border-radius: var(--radius-full);
  background-color: var(--color-text-white);
  transition: transform var(--dur-normal) var(--ease-spring);
  box-shadow: var(--shadow-sm);
}
.custom-toggle input:checked + .toggle-slider {
  background-color: var(--color-secondary);
}
.custom-toggle input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

/* ==========================================
   FILE UPLOAD COMPONENT
   ========================================== */
.ds-upload-area {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  background-color: var(--color-bg-card-glass);
  text-align: center;
  cursor: pointer;
  transition: all var(--dur-normal) var(--ease-smooth);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
}
.ds-upload-area:hover, .ds-upload-area.is-dragover {
  border-color: var(--color-secondary);
  background-color: rgba(37, 99, 235, 0.02);
}

.ds-upload-progress {
  width: 100%;
  height: 6px;
  background-color: var(--color-border);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-top: var(--space-4);
  display: none;
}
.ds-upload-bar {
  height: 100%;
  width: 0%;
  background-color: var(--color-secondary);
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

/* ==========================================
   CARDS & WRAPPERS
   ========================================== */
.ds-card {
  background-color: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
  transition: all var(--dur-normal) var(--ease-smooth);
  overflow: hidden;
}

.ds-card-interactive {
  cursor: pointer;
}
.ds-card-interactive:hover {
  transform: translateY(-4px);
  border-color: var(--color-border-hover);
  box-shadow: var(--shadow-xl);
}

/* Glassmorphism Card style */
.ds-card-glass {
  background: var(--color-bg-card-glass);
  backdrop-filter: var(--glass-blur-md);
  -webkit-backdrop-filter: var(--glass-blur-md);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  box-shadow: var(--shadow-lg);
}

/* ==========================================
   TABLES & RESPONSIVE DATA LISTS
   ========================================== */
.ds-table-container {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  background-color: var(--color-bg-card);
  box-shadow: var(--shadow-sm);
}

.ds-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: var(--fs-sm);
}

.ds-table th {
  background-color: var(--color-bg-main);
  color: var(--color-text-muted);
  font-weight: 600;
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--color-border);
  text-transform: uppercase;
  font-size: var(--fs-xs);
  letter-spacing: 0.05em;
}

.ds-table td {
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text-main);
  transition: background-color var(--dur-fast) var(--ease-smooth);
}

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

.ds-table tr:hover td {
  background-color: var(--color-bg-main);
}

/* Mobile-first Table responsive folding (Wraps columns to card view) */
@media (max-width: 768px) {
  .ds-table, .ds-table tbody, .ds-table tr, .ds-table td {
    display: block;
    width: 100%;
  }
  .ds-table thead {
    display: none;
  }
  .ds-table tr {
    border-bottom: 1px solid var(--color-border);
    padding: var(--space-4) 0;
  }
  .ds-table td {
    border-bottom: none;
    padding: var(--space-2) var(--space-4);
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .ds-table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--color-text-muted);
    font-size: var(--fs-xs);
    text-transform: uppercase;
  }
}

/* ==========================================
   BADGES & STATUS PILLS
   ========================================== */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: var(--fs-xs);
  font-weight: 600;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  gap: var(--space-1);
}

.badge-success {
  background-color: var(--color-status-success-bg);
  color: var(--color-status-success);
}
.badge-warning {
  background-color: var(--color-status-warning-bg);
  color: var(--color-status-warning);
}
.badge-danger {
  background-color: var(--color-status-danger-bg);
  color: var(--color-status-danger);
}
.badge-info {
  background-color: var(--color-status-info-bg);
  color: var(--color-status-info);
}
.badge-verified {
  background-color: rgba(20, 184, 166, 0.08);
  color: var(--color-accent);
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background-color: currentColor;
}

/* ==========================================
   BOOKING UI COMPONENTS
   ========================================== */
.ds-booking-calendar {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.calendar-days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: var(--space-2);
  text-align: center;
}
.calendar-day-header {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  padding-bottom: var(--space-2);
}
.calendar-day-btn {
  background: none;
  border: 1px solid transparent;
  padding: var(--space-3) 0;
  font-size: var(--fs-sm);
  font-weight: 500;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-smooth);
}
.calendar-day-btn:hover {
  background-color: var(--color-bg-main);
  border-color: var(--color-border);
}
.calendar-day-btn.is-selected {
  background-color: var(--color-secondary);
  color: var(--color-text-white);
  font-weight: 600;
}
.calendar-day-btn.is-disabled {
  color: var(--color-text-light);
  cursor: not-allowed;
  background: none;
  border-color: transparent;
}

.ds-timeslot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: var(--space-2);
  margin-top: var(--space-4);
}
.ds-timeslot-item {
  background-color: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-1);
  text-align: center;
  font-size: var(--fs-xs);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-smooth);
}
.ds-timeslot-item:hover {
  border-color: var(--color-secondary);
  background-color: rgba(37,99,235,0.02);
}
.ds-timeslot-item.is-selected {
  background-color: var(--color-secondary);
  border-color: var(--color-secondary);
  color: var(--color-text-white);
}

/* ==========================================
   AI ASSISTANT CHAT COMPONENTS
   ========================================== */
.ds-chat-container {
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-xl);
  border: 1px solid var(--color-border);
  background-color: var(--color-bg-card);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  height: 480px;
}

.ds-chat-header {
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--color-border);
  background-color: var(--color-bg-main);
}

.ds-chat-messages {
  flex: 1;
  padding: var(--space-6);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.ds-chat-bubble {
  max-width: 80%;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  font-size: var(--fs-sm);
}

.ds-chat-bubble-bot {
  background-color: var(--color-bg-main);
  color: var(--color-text-main);
  align-self: flex-start;
  border-bottom-left-radius: var(--radius-xs);
}

.ds-chat-bubble-user {
  background-color: var(--color-secondary);
  color: var(--color-text-white);
  align-self: flex-end;
  border-bottom-right-radius: var(--radius-xs);
}

.ds-chat-quick-actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  padding: 0 var(--space-6) var(--space-4);
}
.ds-chat-chip {
  background-color: var(--color-bg-card);
  border: 1px solid var(--color-border);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  font-size: var(--fs-xs);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-smooth);
}
.ds-chat-chip:hover {
  border-color: var(--color-secondary);
  background-color: rgba(37,99,235,0.02);
}

.ds-chat-input-area {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--color-border);
  display: flex;
  gap: var(--space-3);
}

/* Typing indicator */
.ds-chat-typing {
  display: flex;
  gap: 4px;
  padding: var(--space-2) 0;
  align-self: flex-start;
}
.ds-chat-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background-color: var(--color-text-light);
  animation: ds-bounce 1.4s infinite ease-in-out both;
}
.ds-chat-dot:nth-child(1) { animation-delay: -0.32s; }
.ds-chat-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes ds-bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1.0); }
}

/* ==========================================
   DASHBOARD WIDGETS & LAYOUT BUILDER
   ========================================== */
.ds-dashboard-wrapper {
  display: flex;
  min-height: 100vh;
}

.ds-dashboard-sidebar {
  width: 260px;
  background-color: var(--color-primary);
  color: rgba(255,255,255,0.7);
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--color-primary-light);
  flex-shrink: 0;
}
@media (max-width: 1024px) {
  .ds-dashboard-sidebar {
    display: none; /* Collapsed state on responsive screens */
  }
}

.ds-sidebar-brand {
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: 800;
  color: var(--color-text-white);
  margin-bottom: var(--space-10);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.ds-sidebar-menu {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.ds-sidebar-item a {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  color: rgba(255,255,255,0.6);
  font-size: var(--fs-sm);
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: all var(--dur-normal) var(--ease-smooth);
}
.ds-sidebar-item.is-active a, .ds-sidebar-item a:hover {
  background-color: var(--color-primary-light);
  color: var(--color-text-white);
}

.ds-dashboard-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--color-bg-main);
  min-width: 0;
}

.ds-dashboard-header {
  height: 70px;
  background-color: var(--color-bg-card);
  border-bottom: 1px solid var(--color-border);
  padding: 0 var(--space-8);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ds-dashboard-content {
  padding: var(--space-8);
  flex: 1;
}

/* Analytics Widget Chart */
.ds-chart-widget {
  background-color: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.ds-chart-wrapper {
  position: relative;
  width: 100%;
  height: 140px;
  display: flex;
  align-items: flex-end;
}

/* ==========================================
   FEEDBACK SYSTEMS (Modals, Toasts, Drawers)
   ========================================== */
.ds-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-normal) var(--ease-smooth);
}
.ds-backdrop.is-active {
  opacity: 1;
  pointer-events: auto;
}

/* Modal centered */
.ds-modal {
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(28px) saturate(190%);
  -webkit-backdrop-filter: blur(28px) saturate(190%);
  border-radius: var(--radius-xl);
  width: 90%;
  max-width: 500px;
  box-shadow: 0 30px 60px -12px rgba(15, 23, 42, 0.25), 0 0 0 1px rgba(255, 255, 255, 0.6) inset;
  border: 1px solid rgba(255, 255, 255, 0.7);
  transform: translateY(20px) scale(0.97);
  transition: transform var(--dur-normal) var(--ease-spring);
  overflow: hidden;
}
.ds-backdrop.is-active .ds-modal {
  transform: translateY(0) scale(1);
}

.ds-modal-header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid rgba(226, 232, 240, 0.6);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.4);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.ds-modal-content {
  padding: var(--space-6);
}
.ds-modal-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid rgba(226, 232, 240, 0.6);
  background: rgba(255, 255, 255, 0.4);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
}

[data-theme="dark"] .ds-backdrop {
  background-color: rgba(2, 6, 23, 0.65);
}
[data-theme="dark"] .ds-modal {
  background: rgba(15, 23, 42, 0.82);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 30px 60px -12px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.08) inset;
}
[data-theme="dark"] .ds-modal-header,
[data-theme="dark"] .ds-modal-footer {
  background: rgba(15, 23, 42, 0.4);
  border-color: rgba(255, 255, 255, 0.08);
}

/* Slide-out Drawer (Responsive mobile alternative to Modals) */
.ds-drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  right: 0;
  width: 100%;
  max-width: 400px;
  background-color: var(--color-bg-card);
  box-shadow: var(--shadow-xl);
  border-left: 1px solid var(--color-border);
  z-index: var(--z-drawer);
  transform: translateX(100%);
  transition: transform var(--dur-normal) var(--ease-smooth);
  display: flex;
  flex-direction: column;
}
.ds-drawer.is-active {
  transform: translateX(0);
}

.ds-drawer-header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.ds-drawer-content {
  flex: 1;
  padding: var(--space-6);
  overflow-y: auto;
}

/* Toast Notifications */
.ds-toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  z-index: var(--z-toast);
  pointer-events: none;
}
.ds-toast {
  background-color: var(--color-primary);
  color: var(--color-text-white);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-lg);
  font-size: var(--fs-sm);
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  transform: translateY(20px);
  opacity: 0;
  animation: ds-toast-in var(--dur-normal) var(--ease-spring) forwards;
}

@keyframes ds-toast-in {
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.ds-toast-success { background-color: var(--color-status-success); }
.ds-toast-danger { background-color: var(--color-status-danger); }
.ds-toast-warning { background-color: var(--color-status-warning); }

/* ==========================================
   FEEDBACK STATES (Empty, Skeleton Loader)
   ========================================== */
/* Empty State Component */
.ds-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-12) var(--space-6);
  text-align: center;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-xl);
  background-color: var(--color-bg-card-glass);
}
.ds-empty-icon {
  width: 48px;
  height: 48px;
  color: var(--color-text-light);
  margin-bottom: var(--space-4);
}
.ds-empty-title {
  font-size: var(--fs-md);
  margin-bottom: var(--space-2);
}
.ds-empty-desc {
  color: var(--color-text-muted);
  font-size: var(--fs-sm);
  max-width: 320px;
  margin-bottom: var(--space-5);
}

/* Skeleton Loader Component */
.skeleton {
  background: linear-gradient(90deg, #F1F5F9 25%, #E2E8F0 50%, #F1F5F9 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite ease-in-out;
  border-radius: var(--radius-sm);
}

.skeleton-text {
  height: 14px;
  margin-bottom: var(--space-2);
  width: 100%;
}
.skeleton-text.short { width: 60%; }
.skeleton-text.title { height: 24px; margin-bottom: var(--space-4); }

.skeleton-avatar {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ==========================================================================
   DARK THEME (operatora.ai-inspired deep navy) — token overrides
   Applied via <html data-theme="dark">. Light stays the default :root.
   ========================================================================== */
[data-theme="dark"] {
  /* --color-primary flips light so all TEXT uses of it read on dark;
     background uses of it are overridden explicitly below. */
  --color-primary: #F1F5F9;
  --color-primary-light: #CBD5E1;

  --color-secondary: #3B82F6;      /* brighter medical blue on dark */
  --color-secondary-hover: #2563EB;
  --color-accent: #2DD4BF;         /* brighter teal on dark */
  --color-accent-hover: #14B8A6;

  --color-bg-main: #0A0F1E;        /* deep navy-black canvas */
  --color-bg-card: #111A2E;        /* raised panel */
  --color-bg-card-glass: rgba(17, 26, 46, 0.55);

  --color-border: #1F2A40;
  --color-border-hover: #33415A;
  --color-border-focus: #3B82F6;

  --color-text-main: #F1F5F9;
  --color-text-muted: #94A3B8;
  --color-text-light: #64748B;

  --color-status-success-bg: rgba(16, 185, 129, 0.12);
  --color-status-warning-bg: rgba(245, 158, 11, 0.12);
  --color-status-danger-bg: rgba(239, 68, 68, 0.12);
  --color-status-info-bg: rgba(59, 130, 246, 0.12);

  --grad-glass: linear-gradient(135deg, rgba(45, 212, 191, 0.10) 0%, rgba(59, 130, 246, 0.04) 100%);
  --grad-glow: radial-gradient(circle, rgba(45,212,191,0.14) 0%, rgba(59,130,246,0.05) 70%, transparent 100%);

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 8px -2px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 12px 24px -6px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 24px 48px -12px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 48px rgba(45, 212, 191, 0.18);

  --glass-border: rgba(255, 255, 255, 0.08);
  color-scheme: dark;
}

/* Smooth cross-fade when switching themes */
body, .sticky-nav, .ds-modal, .ds-card, .form-input, .btn,
.footer, .final-cta-card, .ds-toast {
  transition: background-color var(--dur-normal) var(--ease-smooth),
              border-color var(--dur-normal) var(--ease-smooth),
              color var(--dur-normal) var(--ease-smooth);
}

/* --- Dark: background uses of --color-primary must stay dark (it now flips light) --- */
[data-theme="dark"] .btn-primary {
  background-color: var(--color-secondary);
  color: #fff;
}
[data-theme="dark"] .btn-primary:hover {
  background-color: var(--color-secondary-hover);
}
[data-theme="dark"] .ds-toast {
  background-color: #111A2E;
  border: 1px solid var(--color-border);
  color: var(--color-text-main);
}
[data-theme="dark"] .ds-dashboard-sidebar,
[data-theme="dark"] .mock-sidebar {
  background-color: #0D1424;
}
[data-theme="dark"] .btn-ghost {
  color: var(--color-text-main);
}
[data-theme="dark"] .skeleton {
  background: linear-gradient(90deg, #131C31 25%, #1B2540 50%, #131C31 75%);
  background-size: 200% 100%;
}

/* ==========================================================================
   PIN / OTP INPUT (6-digit numeric password) — shared auth component
   ========================================================================== */
.pin-group {
  display: flex;
  gap: var(--space-3);
  justify-content: space-between;
}
.pin-box {
  flex: 1;
  min-width: 0;
  aspect-ratio: 1 / 1;
  max-width: 56px;
  text-align: center;
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: 700;
  color: var(--color-text-main);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  background-color: var(--color-bg-card);
  transition: all var(--dur-fast) var(--ease-smooth);
  -moz-appearance: textfield;
}
.pin-box::-webkit-outer-spin-button,
.pin-box::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.pin-box:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.18);
  transform: translateY(-1px);
}
.pin-box.is-filled {
  border-color: var(--color-accent);
}
.pin-box.is-invalid {
  border-color: var(--color-status-danger);
  animation: pin-shake 0.32s var(--ease-smooth);
}
@keyframes pin-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}
