@import "tailwindcss";

/* Light theme tokens (future-ready) */
:root[data-theme="light"] {
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;

  --color-background-primary: #f2f3f5;
  --color-background-secondary: #f7f8f9;
  --color-background-card: #f7f8f9;
  --color-surface-elevated: #eceef1;

  --color-text-primary: #0f172a;
  --color-text-secondary: #475569;
  --color-text-muted: #64748b;

  --color-border: #d2dcec;
  --color-border-strong: #aec0de;

  --color-card-background: #f7f8f9;
  --color-card-foreground: #0f172a;
  --color-card-muted: #475569;
  --color-card-border: #d2dcec;

  --color-badge-default-bg: #edf3fb;
  --color-badge-default-fg: #1e293b;
  --color-badge-default-border: #c9d8ec;
  --color-badge-success-bg: #e6f7ef;
  --color-badge-success-fg: #14532d;
  --color-badge-success-border: #98d8b5;
  --color-badge-warning-bg: #fff4df;
  --color-badge-warning-fg: #92400e;
  --color-badge-warning-border: #f6c88b;
  --color-badge-danger-bg: #ffe8e8;
  --color-badge-danger-fg: #991b1b;
  --color-badge-danger-border: #f2b0b0;

  --color-purpose-consultation-bg: #f1eafe;
  --color-purpose-consultation-fg: #5b21b6;
  --color-purpose-consultation-border: #cfb8f7;
  --color-purpose-filling-bg: #fff1e5;
  --color-purpose-filling-fg: #9a3412;
  --color-purpose-filling-border: #f8c9a6;
  --color-purpose-endo-bg: #ffe9e9;
  --color-purpose-endo-fg: #991b1b;
  --color-purpose-endo-border: #f4b6b6;
  --color-purpose-visit-bg: #e7f4ff;
  --color-purpose-visit-fg: #0c4a6e;
  --color-purpose-visit-border: #abd8f3;
  --color-purpose-hygiene-bg: #effadf;
  --color-purpose-hygiene-fg: #3f6212;
  --color-purpose-hygiene-border: #cbe9a1;

  --color-primary: #009cae;
  --color-primary-contrast: #031014;
  --color-primary-soft: rgba(0, 156, 174, 0.16);
  --color-icon: #e1bc72;

  /* Realistic tooth: white–blue crown, soft pink root */
  --tooth-crown-hi: #ffffff;
  --tooth-crown-mid: #e0f2fe;
  --tooth-crown-shade: #93c5fd;
  --tooth-root-hi: #f6efe6;
  --tooth-root-mid: #e4d4bf;
  --tooth-root-shade: #c9b396;
  --tooth-stroke: #94a3b8;
  --tooth-hover: #cfe0f5;

  --web-opacity: 0.12;
  --web-line: rgba(0, 188, 255, 0.32);
  --web-glow: rgba(0, 188, 255, 0.42);
}

/* Dark theme tokens */
:root[data-theme="dark"] {
  --color-background-primary: #000c1c;
  --color-background-secondary: #0b1a2b;
  --color-background-card: #14253d;
  --color-surface-elevated: #1b2f4e;

  --color-text-primary: #f5f9ff;
  --color-text-secondary: #b6c6dd;
  --color-text-muted: #8ea3bf;

  --color-border: #29456a;
  --color-border-strong: #3b5f8f;

  --color-card-background: #14253d;
  --color-card-foreground: #f5f9ff;
  --color-card-muted: #b6c6dd;
  --color-card-border: #29456a;

  --color-badge-default-bg: rgba(27, 47, 78, 0.32);
  --color-badge-default-fg: #9eb1cb;
  --color-badge-default-border: rgba(59, 95, 143, 0.32);
  --color-badge-success-bg: rgba(6, 78, 59, 0.22);
  --color-badge-success-fg: #7dd3a8;
  --color-badge-success-border: rgba(34, 100, 68, 0.28);
  --color-badge-warning-bg: rgba(120, 53, 15, 0.22);
  --color-badge-warning-fg: #dfc06a;
  --color-badge-warning-border: rgba(146, 88, 20, 0.28);
  --color-badge-danger-bg: rgba(127, 29, 29, 0.22);
  --color-badge-danger-fg: #e4a6a6;
  --color-badge-danger-border: rgba(153, 50, 50, 0.28);

  --color-purpose-consultation-bg: rgba(139, 92, 246, 0.25);
  --color-purpose-consultation-fg: #ddd6fe;
  --color-purpose-consultation-border: rgba(167, 139, 250, 0.5);
  --color-purpose-filling-bg: rgba(249, 115, 22, 0.25);
  --color-purpose-filling-fg: #fed7aa;
  --color-purpose-filling-border: rgba(251, 146, 60, 0.5);
  --color-purpose-endo-bg: rgba(239, 68, 68, 0.25);
  --color-purpose-endo-fg: #fecaca;
  --color-purpose-endo-border: rgba(248, 113, 113, 0.5);
  --color-purpose-visit-bg: rgba(14, 165, 233, 0.25);
  --color-purpose-visit-fg: #bae6fd;
  --color-purpose-visit-border: rgba(56, 189, 248, 0.5);
  --color-purpose-hygiene-bg: rgba(132, 204, 22, 0.2);
  --color-purpose-hygiene-fg: #d9f99d;
  --color-purpose-hygiene-border: rgba(163, 230, 53, 0.45);

  --color-primary: #09a9bc;
  --color-primary-contrast: #001117;
  --color-primary-soft: rgba(9, 169, 188, 0.2);
  --color-icon: #e1bc72;

  --tooth-crown-hi: #ffffff;
  --tooth-crown-mid: #dbeafe;
  --tooth-crown-shade: #7dd3fc;
  --tooth-root-hi: #f3ebe0;
  --tooth-root-mid: #dcc9ae;
  --tooth-root-shade: #bba280;
  --tooth-stroke: #94a3b8;
  --tooth-hover: #bdd0e0;
}

/* Default theme = dark */
:root {
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --today-grid-unit: 5.75rem;
  --color-background-primary: #000c1c;
  --color-background-secondary: #0a1520;
  --color-background-card: #14253d;
  --color-surface-elevated: #1b2f4e;

  --color-text-primary: #f5f9ff;
  --color-text-secondary: #b6c6dd;
  --color-text-muted: #8ea3bf;

  --color-border: #29456a;
  --color-border-strong: #3b5f8f;

  --color-card-background: #14253d;
  --color-card-foreground: #f5f9ff;
  --color-card-muted: #b6c6dd;
  --color-card-border: #29456a;

  --color-badge-default-bg: rgba(27, 47, 78, 0.32);
  --color-badge-default-fg: #9eb1cb;
  --color-badge-default-border: rgba(59, 95, 143, 0.32);
  --color-badge-success-bg: rgba(6, 78, 59, 0.22);
  --color-badge-success-fg: #7dd3a8;
  --color-badge-success-border: rgba(34, 100, 68, 0.28);
  --color-badge-warning-bg: rgba(120, 53, 15, 0.22);
  --color-badge-warning-fg: #dfc06a;
  --color-badge-warning-border: rgba(146, 88, 20, 0.28);
  --color-badge-danger-bg: rgba(127, 29, 29, 0.22);
  --color-badge-danger-fg: #e4a6a6;
  --color-badge-danger-border: rgba(153, 50, 50, 0.28);

  --color-purpose-consultation-bg: rgba(139, 92, 246, 0.25);
  --color-purpose-consultation-fg: #ddd6fe;
  --color-purpose-consultation-border: rgba(167, 139, 250, 0.5);
  --color-purpose-filling-bg: rgba(249, 115, 22, 0.25);
  --color-purpose-filling-fg: #fed7aa;
  --color-purpose-filling-border: rgba(251, 146, 60, 0.5);
  --color-purpose-endo-bg: rgba(239, 68, 68, 0.25);
  --color-purpose-endo-fg: #fecaca;
  --color-purpose-endo-border: rgba(248, 113, 113, 0.5);
  --color-purpose-visit-bg: rgba(14, 165, 233, 0.25);
  --color-purpose-visit-fg: #bae6fd;
  --color-purpose-visit-border: rgba(56, 189, 248, 0.5);
  --color-purpose-hygiene-bg: rgba(132, 204, 22, 0.2);
  --color-purpose-hygiene-fg: #d9f99d;
  --color-purpose-hygiene-border: rgba(163, 230, 53, 0.45);

  --color-primary: #09a9bc;
  --color-primary-contrast: #001117;
  --color-primary-soft: rgba(9, 169, 188, 0.2);
  --color-icon: #f3bb4b;

  --tooth-crown-hi: #ffffff;
  --tooth-crown-mid: #dbeafe;
  --tooth-crown-shade: #7dd3fc;
  --tooth-root-hi: #f3ebe0;
  --tooth-root-mid: #dcc9ae;
  --tooth-root-shade: #bba280;
  --tooth-stroke: #94a3b8;
  --tooth-hover: #bdd0e0;

  --web-opacity: 0.14;
  --web-line: rgba(59, 153, 220, 0.34);
  --web-line-strong: rgba(73, 214, 255, 0.78);
  --web-glow: rgba(48, 204, 255, 0.55);
}

@theme inline {
  --color-background-primary: var(--color-background-primary);
  --color-background-secondary: var(--color-background-secondary);
  --color-background-card: var(--color-background-card);
  --color-surface-elevated: var(--color-surface-elevated);

  --color-text-primary: var(--color-text-primary);
  --color-text-secondary: var(--color-text-secondary);
  --color-text-muted: var(--color-text-muted);

  --color-border: var(--color-border);
  --color-border-strong: var(--color-border-strong);
  --color-card: var(--color-card-background);
  --color-card-foreground: var(--color-card-foreground);
  --color-card-muted: var(--color-card-muted);
  --color-card-border: var(--color-card-border);
  --color-badge-default-bg: var(--color-badge-default-bg);
  --color-badge-default-fg: var(--color-badge-default-fg);
  --color-badge-default-border: var(--color-badge-default-border);
  --color-badge-success-bg: var(--color-badge-success-bg);
  --color-badge-success-fg: var(--color-badge-success-fg);
  --color-badge-success-border: var(--color-badge-success-border);
  --color-badge-warning-bg: var(--color-badge-warning-bg);
  --color-badge-warning-fg: var(--color-badge-warning-fg);
  --color-badge-warning-border: var(--color-badge-warning-border);
  --color-badge-danger-bg: var(--color-badge-danger-bg);
  --color-badge-danger-fg: var(--color-badge-danger-fg);
  --color-badge-danger-border: var(--color-badge-danger-border);
  --color-purpose-consultation-bg: var(--color-purpose-consultation-bg);
  --color-purpose-consultation-fg: var(--color-purpose-consultation-fg);
  --color-purpose-consultation-border: var(--color-purpose-consultation-border);
  --color-purpose-filling-bg: var(--color-purpose-filling-bg);
  --color-purpose-filling-fg: var(--color-purpose-filling-fg);
  --color-purpose-filling-border: var(--color-purpose-filling-border);
  --color-purpose-endo-bg: var(--color-purpose-endo-bg);
  --color-purpose-endo-fg: var(--color-purpose-endo-fg);
  --color-purpose-endo-border: var(--color-purpose-endo-border);
  --color-purpose-visit-bg: var(--color-purpose-visit-bg);
  --color-purpose-visit-fg: var(--color-purpose-visit-fg);
  --color-purpose-visit-border: var(--color-purpose-visit-border);
  --color-purpose-hygiene-bg: var(--color-purpose-hygiene-bg);
  --color-purpose-hygiene-fg: var(--color-purpose-hygiene-fg);
  --color-purpose-hygiene-border: var(--color-purpose-hygiene-border);
  --color-primary: var(--color-primary);
  --color-primary-contrast: var(--color-primary-contrast);
  --color-primary-soft: var(--color-primary-soft);
}

html,
body {
  padding: 0;
  margin: 0;
}

html {
  color-scheme: light;
}

html[data-theme='light'] {
  color-scheme: light;
}

html[data-theme='dark'] {
  color-scheme: dark;
}

/* Minimal RTL layer — refine incrementally. */
html[dir='rtl'] body {
  direction: rtl;
}

/* Sidebar: don't rely on Tailwind rtl: variants. */
html[dir='rtl'] .app-sidebar {
  border-right: 0;
  border-left: 1px solid var(--color-border);
}

/* Mobile drawer only — desktop sidebar follows flex + document direction. */
@media (max-width: 1023px) {
  html[dir='rtl'] .app-sidebar {
    left: auto;
    right: 0;
  }
}

/* Treatment rail: align header text to the right in RTL. */
html[dir='rtl'] .treatment-rail-section > button {
  text-align: right;
}

body {
  background-color: var(--color-background-primary);
  color: var(--color-text-primary);
  font-family: var(--font-sans, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif);
}

select.form-select,
select {
  color: var(--color-text-primary);
  background-color: var(--color-background-card);
  font-size: 1rem;
}

/* Shared chevron for all `.form-select` — symmetric inset matches `ps-3` text padding. */
select.form-select:not(.form-select-no-chevron) {
  appearance: none;
  -webkit-appearance: none;
  text-align: start;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: 1rem 1rem;
  background-position: right 0.75rem center;
}

html[dir='rtl'] select.form-select:not(.form-select-no-chevron) {
  background-position: left 0.75rem center;
}

select.form-select.form-select-no-chevron {
  background-image: none;
}

@media (min-width: 640px) {
  select.form-select,
  select {
    font-size: 0.875rem;
  }
}

select option {
  color: var(--color-text-primary);
  background-color: var(--color-background-secondary);
}

:root[data-theme='dark'] select.form-select,
:root[data-theme='dark'] select {
  color-scheme: dark;
}

.surface-card {
  background: color-mix(in srgb, var(--color-card-background) 92%, transparent);
  border: 1px solid var(--color-card-border);
  color: var(--color-card-foreground);
  border-radius: var(--radius-lg);
}

@media (min-width: 1024px) {
  .today-dashboard-grid .today-dashboard-cell {
    grid-column: var(--today-gc);
    grid-row: var(--today-gr);
  }
}

:root[data-theme='dark'] .surface-card {
  background: color-mix(in srgb, var(--color-card-background) 82%, var(--color-background-primary));
}

.surface-panel {
  background: color-mix(in srgb, var(--color-background-secondary) 96%, transparent);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.icon-flat {
  stroke-width: 1.9;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Global icon color override (easy to revert) */
.lucide {
  color: var(--color-icon);
  stroke: currentColor;
}

/* Opt out when an icon sits on a primary/filled control (Send, etc.) */
.lucide.lucide-on-primary {
  color: #fff;
  stroke: currentColor;
}

/* Inherit the parent color (job-chip trash, catalog-tinted controls). */
.lucide.lucide-inherit {
  color: inherit;
  stroke: currentColor;
}

@keyframes picker-expand {
  from {
    opacity: 0;
    transform: translateY(4px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.picker-expand {
  transform-origin: top center;
  animation: picker-expand 180ms ease-out;
}

@media (prefers-reduced-motion: reduce) {
  .picker-expand {
    animation: none;
  }
}

@keyframes task-row-complete-exit {
  0% {
    opacity: 1;
    transform: translateX(0);
    max-height: 9rem;
  }
  40% {
    opacity: 1;
    transform: translateX(0);
    background-color: color-mix(in srgb, var(--color-badge-success-bg) 75%, transparent);
  }
  100% {
    opacity: 0;
    transform: translateX(0.75rem);
    max-height: 0;
    overflow: hidden;
  }
}

.task-row-complete-exit {
  animation: task-row-complete-exit 0.55s ease-in forwards;
  pointer-events: none;
  overflow: hidden;
}