/* ============================================================
   PlaySurg — Design tokens & shared components
   Brand: teal #004B4B → #007773 → #4FC0BA, ink #0E2624, paper #F4F6F5
   ============================================================ */

:root {
  /* Brand */
  --teal-900: #002F2F;
  --teal-800: #004B4B;
  --teal-700: #006A66;
  --teal-600: #007773;
  --teal-500: #00A9A1;
  --teal-400: #4FC0BA;
  --teal-200: #B8DDDA;
  --teal-100: #D7EAE8;
  --teal-050: #EAF3F1;

  --ink-900: #0E2624;
  --ink-800: #1B3735;
  --ink-700: #2D4D4A;
  --ink-600: #4A6663;
  --ink-500: #6A827F;
  --ink-400: #8FA29F;
  --ink-300: #B7C5C2;
  --ink-200: #D9E3E0;
  --ink-100: #ECF2F0;
  --paper:   #F4F6F5;
  --white:   #FFFFFF;

  --danger:  #B43A2E;
  --warning: #C58A1C;
  --success: #2E7D5C;

  /* Brand-driven semantic */
  --color-primary: var(--teal-800);
  --color-primary-hover: var(--teal-700);
  --color-accent: var(--teal-500);
  --color-bg: var(--paper);
  --color-surface: var(--white);
  --color-text: var(--ink-900);
  --color-text-muted: var(--ink-500);
  --color-border: var(--ink-200);

  /* Type */
  --font-sans: 'Quicksand', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  /* Radii */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --r-2xl: 28px;

  /* Shadows */
  --s-1: 0 1px 2px rgba(14, 38, 36, .05), 0 1px 3px rgba(14, 38, 36, .04);
  --s-2: 0 4px 12px rgba(14, 38, 36, .06), 0 2px 4px rgba(14, 38, 36, .04);
  --s-3: 0 12px 32px rgba(14, 38, 36, .10), 0 4px 12px rgba(14, 38, 36, .05);
  --s-4: 0 24px 64px rgba(14, 38, 36, .14), 0 8px 24px rgba(14, 38, 36, .08);

  /* Layout */
  --hdr-h: 72px;
  --side-w: 280px;
  --content-max: 1280px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  font-feature-settings: "ss01";
  color: var(--color-text);
  background: var(--color-bg);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { font-weight: 600; letter-spacing: -0.02em; margin: 0; line-height: 1.15; text-wrap: balance; }
h1 { font-size: clamp(36px, 5vw, 64px); }
h2 { font-size: clamp(28px, 3.5vw, 42px); }
h3 { font-size: 22px; }
h4 { font-size: 17px; }
p { margin: 0; text-wrap: pretty; }

.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; letter-spacing: 0.18em; text-transform: uppercase;
  font-weight: 500; color: var(--teal-700);
}
.eyebrow::before {
  content: ''; width: 24px; height: 1px; background: currentColor;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: inherit; font-size: 14px; font-weight: 600;
  padding: 11px 20px; border-radius: 999px; border: 1px solid transparent;
  cursor: pointer; transition: all .15s ease;
  text-decoration: none; white-space: nowrap;
  letter-spacing: -0.01em;
}
.btn-primary {
  background: var(--color-primary); color: var(--paper);
}
.btn-primary:hover { background: var(--color-primary-hover); transform: translateY(-1px); box-shadow: var(--s-2); text-decoration: none; }
.btn-ghost {
  background: transparent; color: var(--color-text); border-color: var(--color-border);
}
.btn-ghost:hover { background: var(--color-surface); border-color: var(--ink-300); text-decoration: none; }
.btn-outline {
  background: transparent; color: var(--color-primary); border-color: var(--color-primary);
}
.btn-outline:hover { background: var(--teal-050); text-decoration: none; }
.btn-text { background: transparent; color: var(--color-primary); padding: 8px 12px; }
.btn-text:hover { background: var(--teal-050); text-decoration: none; }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--ink-200); }
.btn-danger:hover { background: #FBEEEC; border-color: var(--danger); text-decoration: none; }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-lg { padding: 14px 26px; font-size: 15px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }

/* ============================================================
   Forms
   ============================================================ */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .label {
  font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ink-700);
}
.input, .select, .textarea {
  font-family: inherit; font-size: 14px;
  padding: 11px 14px; background: var(--white);
  border: 1px solid var(--color-border); border-radius: var(--r-md);
  color: var(--color-text);
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--teal-500);
  box-shadow: 0 0 0 3px var(--teal-100);
}
.textarea { resize: vertical; min-height: 100px; line-height: 1.55; }
.select { appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='none' stroke='%234A6663' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M1 1.5l5 5 5-5'/></svg>"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 38px; }
.hint { font-size: 12px; color: var(--color-text-muted); }
.error { font-size: 13px; color: var(--danger); }

/* ============================================================
   Card / surface
   ============================================================ */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--r-lg);
  padding: 24px;
}
.card.tight { padding: 18px; }
.card.elev { box-shadow: var(--s-2); border-color: transparent; }

.divider { height: 1px; background: var(--color-border); border: 0; }

/* ============================================================
   Badge / chip
   ============================================================ */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em;
  background: var(--teal-050); color: var(--teal-800);
}
.badge.dot::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor;
}
.badge-warn   { background: #FAF1DE; color: #8A5F0F; }
.badge-danger { background: #FBEEEC; color: var(--danger); }
.badge-success{ background: #E5F1EB; color: var(--success); }
.badge-info   { background: var(--teal-050); color: var(--teal-800); }
.badge-neutral{ background: var(--ink-100); color: var(--ink-700); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 999px;
  font-size: 12px; font-weight: 500;
  background: var(--white); border: 1px solid var(--color-border);
  color: var(--ink-700);
}

/* ============================================================
   Header / topbar (logged-in app)
   ============================================================ */
.ps-topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(255,255,255,0.92);
  backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid var(--color-border);
  height: var(--hdr-h);
}
.ps-topbar .inner {
  max-width: var(--content-max); margin: 0 auto;
  height: 100%; padding: 0 28px;
  display: flex; align-items: center; gap: 28px;
}
.ps-logo {
  display: flex; align-items: center; gap: 10px;
  font-weight: 600; font-size: 18px; letter-spacing: -0.02em;
  color: var(--ink-900);
  text-decoration: none;
}
.ps-logo .mark {
  width: 36px; height: 36px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--teal-800), var(--teal-500));
  color: var(--paper);
  display: grid; place-items: center;
  font-weight: 700; font-size: 13px; letter-spacing: -1px;
}
.ps-logo .wm-light { font-weight: 500; }
.ps-logo .wm-bold  { font-weight: 700; }

.ps-nav { display: flex; align-items: center; gap: 4px; }
.ps-nav a {
  color: var(--ink-700); font-weight: 500; font-size: 14px;
  padding: 8px 14px; border-radius: 999px;
  text-decoration: none;
  transition: background .15s;
}
.ps-nav a:hover { background: var(--ink-100); text-decoration: none; }
.ps-nav a.active { background: var(--ink-900); color: var(--paper); }

.ps-spacer { flex: 1; }

.ps-tenant-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px 6px 6px;
  background: var(--ink-100); border-radius: 999px;
  font-size: 13px; font-weight: 500; color: var(--ink-800);
}
.ps-tenant-pill .dot {
  width: 24px; height: 24px; border-radius: 50%;
  background: linear-gradient(135deg, var(--teal-800), var(--teal-500));
  color: var(--paper); display: grid; place-items: center;
  font-size: 10px; font-weight: 700;
}

.ps-user-menu {
  position: relative;
}
.ps-user-trigger {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 6px 4px 4px; border-radius: 999px;
  cursor: pointer; border: 1px solid transparent; background: transparent;
  font-family: inherit;
}
.ps-user-trigger:hover { background: var(--ink-100); }
.ps-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--teal-800); color: var(--paper);
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
}
.ps-user-info { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; }
.ps-user-info .name { font-size: 13px; font-weight: 600; }
.ps-user-info .role { font-size: 11px; color: var(--color-text-muted); }

.dropdown {
  position: absolute; top: calc(100% + 8px); right: 0;
  min-width: 240px;
  background: var(--white);
  border: 1px solid var(--color-border);
  border-radius: var(--r-md);
  box-shadow: var(--s-3);
  padding: 6px;
  display: none;
  z-index: 50;
}
.dropdown.open { display: block; }
.dropdown a, .dropdown button {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--r-sm);
  font-size: 13px; color: var(--ink-800);
  text-decoration: none; cursor: pointer;
  border: 0; background: transparent;
  width: 100%; font-family: inherit; text-align: left;
}
.dropdown a:hover, .dropdown button:hover { background: var(--ink-100); text-decoration: none; }
.dropdown hr { border: 0; border-top: 1px solid var(--color-border); margin: 4px 0; }
.dropdown .label-mini {
  padding: 6px 12px; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--color-text-muted); font-weight: 600;
}

.lang-switch {
  display: inline-flex; background: var(--ink-100); border-radius: 999px; padding: 3px; gap: 0;
}
.lang-switch button {
  appearance: none; border: 0; background: transparent;
  padding: 4px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em;
  color: var(--ink-700); cursor: pointer; font-family: inherit;
}
.lang-switch button.active { background: var(--white); color: var(--ink-900); box-shadow: var(--s-1); }

/* ============================================================
   App shell (sidebar + content)
   ============================================================ */
.ps-shell { display: flex; min-height: calc(100vh - var(--hdr-h)); }
.ps-side {
  width: var(--side-w); flex-shrink: 0;
  background: var(--white);
  border-right: 1px solid var(--color-border);
  padding: 28px 18px;
  height: calc(100vh - var(--hdr-h));
  position: sticky; top: var(--hdr-h);
  overflow-y: auto;
}
.ps-side h4 {
  font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--color-text-muted); margin: 18px 12px 8px; font-weight: 600;
}
.ps-side h4:first-child { margin-top: 0; }
.ps-side .nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--r-md);
  font-size: 14px; color: var(--ink-800);
  text-decoration: none; cursor: pointer;
  border: 0; background: transparent;
  width: 100%; font-family: inherit; text-align: left;
}
.ps-side .nav-item:hover { background: var(--ink-100); text-decoration: none; }
.ps-side .nav-item.active { background: var(--teal-050); color: var(--teal-800); font-weight: 600; }
.ps-side .nav-item svg { width: 18px; height: 18px; flex-shrink: 0; color: var(--ink-500); }
.ps-side .nav-item.active svg { color: var(--teal-700); }

.ps-content { flex: 1; padding: 32px 40px 80px; min-width: 0; }
.ps-content .pagehead { margin-bottom: 28px; }
.ps-content .pagehead h1 { font-size: 32px; margin-bottom: 6px; }
.ps-content .pagehead p { color: var(--color-text-muted); }

.breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--color-text-muted); margin-bottom: 14px;
}
.breadcrumb a { color: inherit; }
.breadcrumb a:hover { color: var(--teal-700); }
.breadcrumb .sep { opacity: .5; }
.breadcrumb .current { color: var(--ink-900); font-weight: 500; }

/* ============================================================
   Tree (UO > Organi > Patologie)
   ============================================================ */
.tree { display: flex; flex-direction: column; gap: 2px; }
.tree-node { font-size: 14px; }
.tree-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: var(--r-sm);
  cursor: pointer; color: var(--ink-800);
  font-family: inherit; border: 0; background: transparent; width: 100%; text-align: left;
}
.tree-row:hover { background: var(--ink-100); }
.tree-row.active { background: var(--teal-050); color: var(--teal-800); font-weight: 600; }
.tree-row .caret {
  width: 14px; height: 14px; flex-shrink: 0;
  transition: transform .15s;
  color: var(--ink-500);
}
.tree-row.open .caret { transform: rotate(90deg); }
.tree-row .leaf-dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--ink-300); flex-shrink: 0;
}
.tree-row.active .leaf-dot { background: var(--teal-500); }
.tree-row .count { margin-left: auto; font-size: 11px; color: var(--color-text-muted); font-weight: 500; }
.tree-children { padding-left: 22px; display: none; }
.tree-children.open { display: flex; flex-direction: column; gap: 2px; }

/* ============================================================
   Video grid
   ============================================================ */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 22px;
}
.video-card {
  background: var(--white);
  border: 1px solid var(--color-border);
  border-radius: var(--r-lg);
  overflow: hidden;
  transition: all .2s;
  text-decoration: none;
  color: inherit;
  display: flex; flex-direction: column;
}
.video-card:hover {
  transform: translateY(-2px); box-shadow: var(--s-3);
  border-color: var(--teal-400);
  text-decoration: none;
}
.video-thumb {
  aspect-ratio: 16/9;
  position: relative; overflow: hidden;
  background: var(--ink-900);
}
.video-thumb .poster { position: absolute; inset: 0; }
.video-thumb .duration {
  position: absolute; bottom: 10px; right: 10px;
  background: rgba(14, 38, 36, .85); color: var(--paper);
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em;
  padding: 3px 8px; border-radius: 4px;
  font-feature-settings: "tnum";
}
.video-thumb .approach-badge {
  position: absolute; top: 10px; left: 10px;
  background: rgba(244, 246, 245, .92); color: var(--ink-900);
  font-size: 11px; font-weight: 600;
  padding: 4px 9px; border-radius: 999px;
}
.video-thumb .play-overlay {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background: linear-gradient(180deg, transparent 40%, rgba(14,38,36,0.5) 100%);
  opacity: 0; transition: opacity .2s;
}
.video-card:hover .play-overlay { opacity: 1; }
.play-overlay .play-btn {
  width: 64px; height: 64px; border-radius: 50%;
  background: rgba(244, 246, 245, .96);
  display: grid; place-items: center;
  box-shadow: 0 10px 40px rgba(0,0,0,.3);
  transform: scale(.9); transition: transform .2s;
}
.video-card:hover .play-overlay .play-btn { transform: scale(1); }
.play-overlay svg { width: 24px; height: 24px; color: var(--teal-800); margin-left: 3px; }

.video-meta { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; }
.video-meta .vtitle { font-weight: 600; font-size: 15px; line-height: 1.35; color: var(--ink-900); }
.video-meta .vsub { font-size: 12px; color: var(--color-text-muted); display: flex; align-items: center; gap: 8px; }
.video-meta .vsub .sep { width: 3px; height: 3px; border-radius: 50%; background: var(--ink-300); }

/* ============================================================
   Tables
   ============================================================ */
.table-wrap { background: var(--white); border: 1px solid var(--color-border); border-radius: var(--r-lg); overflow: hidden; }
table.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 14px 18px; text-align: left; font-size: 14px; }
.table th {
  background: var(--ink-100); color: var(--ink-700);
  font-weight: 600; font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase;
  border-bottom: 1px solid var(--color-border);
}
.table tbody tr { border-bottom: 1px solid var(--color-border); }
.table tbody tr:last-child { border-bottom: 0; }
.table tbody tr:hover { background: var(--ink-100); }
.table .actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ============================================================
   Modal
   ============================================================ */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(14, 38, 36, .55);
  display: none; align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
  backdrop-filter: blur(4px);
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--white); border-radius: var(--r-lg);
  width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto;
  box-shadow: var(--s-4);
}
.modal.lg { max-width: 720px; }
.modal-head { padding: 22px 26px 0; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.modal-head h3 { font-size: 20px; }
.modal-body { padding: 18px 26px; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { padding: 18px 26px 22px; display: flex; gap: 10px; justify-content: flex-end; border-top: 1px solid var(--color-border); margin-top: 8px; }
.modal-close {
  appearance: none; border: 0; background: transparent;
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer; color: var(--ink-500);
}
.modal-close:hover { background: var(--ink-100); color: var(--ink-900); }

/* ============================================================
   Empty state
   ============================================================ */
.empty {
  text-align: center; padding: 60px 20px;
  background: var(--white); border: 1px dashed var(--color-border); border-radius: var(--r-lg);
}
.empty .ico { width: 56px; height: 56px; margin: 0 auto 14px; color: var(--ink-300); }
.empty h4 { margin-bottom: 6px; font-weight: 600; font-size: 17px; }
.empty p { color: var(--color-text-muted); margin-bottom: 16px; }

/* ============================================================
   Stat cards
   ============================================================ */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.stat {
  background: var(--white); border: 1px solid var(--color-border);
  border-radius: var(--r-md); padding: 16px 18px;
  display: flex; flex-direction: column; gap: 4px;
}
.stat .num { font-size: 28px; font-weight: 700; color: var(--ink-900); letter-spacing: -0.02em; font-feature-settings: "tnum"; }
.stat .lab { font-size: 12px; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }

/* ============================================================
   Utilities
   ============================================================ */
.admin-side { background: var(--white); }
.admin-content { padding: 32px 40px 80px; }
.admin-content .pagehead {
  display: flex; justify-content: space-between; align-items: flex-end;
  margin-bottom: 28px; gap: 18px; flex-wrap: wrap;
}
.admin-content .pagehead h1 { font-size: 28px; margin-bottom: 4px; }
.admin-content .pagehead p { color: var(--ink-500); font-size: 14px; }

.kpi-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px; margin-bottom: 28px;
}
.kpi {
  background: var(--white); border: 1px solid var(--color-border);
  border-radius: var(--r-md); padding: 18px 20px;
  display: flex; flex-direction: column; gap: 6px;
  position: relative; overflow: hidden;
}
.kpi .lab { font-size: 11px; color: var(--ink-500); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }
.kpi .num { font-size: 30px; font-weight: 700; color: var(--ink-900); letter-spacing: -0.02em; font-feature-settings: "tnum"; line-height: 1; margin-top: 2px; }
.kpi .delta { font-size: 12px; color: var(--success); font-weight: 600; }
.kpi .delta.negative { color: var(--danger); }
.kpi.featured { background: linear-gradient(135deg, var(--teal-800), var(--teal-600)); color: var(--paper); border-color: transparent; }
.kpi.featured .lab { color: var(--teal-200); }
.kpi.featured .num { color: var(--paper); }

.row { display: flex; gap: 14px; align-items: center; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack-lg { gap: 24px; }
.muted { color: var(--color-text-muted); }
.center { text-align: center; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.hide-sm { }
@media (max-width: 720px) {
  .hide-sm { display: none !important; }
  .ps-content { padding: 22px 16px 60px; }
  .grid-2 { grid-template-columns: 1fr; }
  .ps-side { display: none; }
}

/* Toast */
.toast-stack { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast {
  background: var(--ink-900); color: var(--paper);
  padding: 12px 18px; border-radius: var(--r-md);
  font-size: 13px; font-weight: 500;
  box-shadow: var(--s-3);
  animation: toastIn .25s ease;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
