/* Sistema visual transversal: Prieto Legal OS */
:root {
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-muted: #f2f5f7;
  --ink-soft: #38566a;
  --accent: #c59a57;
  --accent-soft: #fbf5eb;
  --display: 'Playfair Display', Georgia, serif;
  --mono: 'DM Mono', ui-monospace, monospace;
  --ease: cubic-bezier(.2,.8,.2,1);
}

body { line-height: 1.45; }
button, select, input, textarea { min-height: 36px; }
button:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible, a:focus-visible { outline: 3px solid #c59a57; outline-offset: 2px; }
.primary, .secondary, .ghost, .link-button, .agenda-filter, .month-switcher button { align-items: center; justify-content: center; }
.ghost { display: inline-flex; min-height: 34px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--ink); font-size: 12px; font-weight: 650; white-space: nowrap; }
.ghost:hover { border-color: var(--gold); background: var(--gold-soft); }

/* Sólo el encabezado principal es fijo. Evita invadir encabezados de módulos. */
#app-shell > .workspace > header { min-width: 0; }
.wa-hero { position: static; z-index: auto; height: auto; min-height: 0; background: transparent; padding: 8px 0 20px; backdrop-filter: none; }
.wa-hero h1, .wa-hero p { max-width: 100%; }
.wa-panel, .wa-panel-head, .wa-panel-head > *, .wa-grid > *, .agenda-layout > *, .agenda-calendar-head > *, .header-actions > * { min-width: 0; }
.wa-panel-head { align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.wa-panel-head > button { flex: 0 0 auto; }
.wa-panel h2 { overflow-wrap: anywhere; }
.wa-status { flex-wrap: wrap; justify-content: flex-end; }

/* Ritmo, controles y calendarios sin textos encimados. */
.content { width: 100%; }
.header-actions { flex-wrap: wrap; justify-content: flex-end; }
.theme-control { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; font-weight: 650; white-space: nowrap; }
.theme-control select { min-height: 34px; max-width: 128px; padding: 5px 27px 5px 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--ink); font-size: 12px; }
.agenda-calendar-head h3, .agenda-focus-head h3 { text-transform: none; }
.agenda-metric, .metric, .briefing-metric, .task-metric, .ops-metric { min-width: 0; overflow: hidden; }
.agenda-metric strong, .metric .value, .briefing-metric strong, .task-metric strong, .ops-metric strong { font-variant-numeric: lining-nums tabular-nums; }
.agenda-calendar-head { align-items: flex-start; }
.month-switcher { flex: 0 0 auto; }
.month-switcher button { display: inline-flex; min-width: 36px; min-height: 36px; padding: 0 9px; white-space: nowrap; }
.month-switcher #agenda-today { width: auto; font-size: 12px; }
.agenda-filter { min-height: 34px; white-space: nowrap; }
.list-title, .table-title, .agenda-focus-title, .wa-data p, .wa-note, .subtle { overflow-wrap: anywhere; }

body[data-theme="dark"] {
  --ink: #edf4f7;
  --ink-2: #c7d8e0;
  --paper: #0c1720;
  --panel: #132430;
  --surface: #132430;
  --surface-raised: #1a2d3a;
  --surface-muted: #203846;
  --line: #315061;
  --muted: #aabcc7;
  --gold: #e5bc72;
  --gold-soft: #332b1e;
  --blue: #8bc9ec;
  --red: #ff9e98;
  --green: #82d3ab;
  --shadow: 0 16px 38px rgba(0,0,0,.32);
}
body[data-theme="dark"] header,
body[data-theme="dark"] .modal,
body[data-theme="dark"] .wa-panel,
body[data-theme="dark"] .assistant-catalog,
body[data-theme="dark"] .assistant-selected,
body[data-theme="dark"] .assistant-chat,
body[data-theme="dark"] .assistant-questions,
body[data-theme="dark"] .assistant-process,
body[data-theme="dark"] .agenda-calendar-card,
body[data-theme="dark"] .agenda-focus,
body[data-theme="dark"] .briefing-panel,
body[data-theme="dark"] .task-lane,
body[data-theme="dark"] .ops-panel,
body[data-theme="dark"] .research-box,
body[data-theme="dark"] .client-portal-modal { background: var(--surface) !important; color: var(--ink); }
body[data-theme="dark"] .card,
body[data-theme="dark"] .metric,
body[data-theme="dark"] .agenda-metric,
body[data-theme="dark"] .briefing-metric,
body[data-theme="dark"] .task-metric,
body[data-theme="dark"] .ops-metric,
body[data-theme="dark"] .wa-data,
body[data-theme="dark"] .wa-thread,
body[data-theme="dark"] .agenda-day,
body[data-theme="dark"] .data-table th,
body[data-theme="dark"] .data-table tr:hover td { background: var(--surface-raised) !important; color: var(--ink); }
body[data-theme="dark"] input,
body[data-theme="dark"] select,
body[data-theme="dark"] textarea,
body[data-theme="dark"] .secondary,
body[data-theme="dark"] .ghost,
body[data-theme="dark"] .theme-control select,
body[data-theme="dark"] .month-switcher button { background: #10202b !important; color: var(--ink) !important; border-color: var(--line) !important; }
body[data-theme="dark"] .agenda-day.is-outside { background: #101e28 !important; color: #78909d; }
body[data-theme="dark"] .agenda-day:hover { background: #1c3340 !important; }
body[data-theme="dark"] .wa-lead,
body[data-theme="dark"] .wa-filter,
body[data-theme="dark"] .assistant-skill { background: var(--surface) !important; color: var(--ink); border-color: var(--line); }
body[data-theme="dark"] .wa-lead:hover,
body[data-theme="dark"] .wa-lead:focus,
body[data-theme="dark"] .wa-lead.is-active { background: #203946 !important; }

body[data-theme="contrast"] {
  --ink: #ffffff;
  --ink-2: #ffffff;
  --paper: #000000;
  --panel: #000000;
  --surface: #000000;
  --surface-raised: #000000;
  --surface-muted: #121212;
  --line: #ffffff;
  --muted: #ffffff;
  --gold: #ffe600;
  --gold-soft: #262200;
  --blue: #78d9ff;
  --red: #ffaba5;
  --green: #a3ffb6;
}
body[data-theme="contrast"] *, body[data-theme="contrast"] *::before, body[data-theme="contrast"] *::after { box-shadow: none !important; }
body[data-theme="contrast"] header,
body[data-theme="contrast"] .card,
body[data-theme="contrast"] .metric,
body[data-theme="contrast"] .modal,
body[data-theme="contrast"] .wa-panel,
body[data-theme="contrast"] .agenda-calendar-card,
body[data-theme="contrast"] .agenda-focus,
body[data-theme="contrast"] .agenda-metric,
body[data-theme="contrast"] .assistant-catalog,
body[data-theme="contrast"] .assistant-selected,
body[data-theme="contrast"] .assistant-chat,
body[data-theme="contrast"] .assistant-questions,
body[data-theme="contrast"] .assistant-process { background: #000 !important; color: #fff !important; border-color: #fff !important; }
body[data-theme="contrast"] input,
body[data-theme="contrast"] select,
body[data-theme="contrast"] textarea,
body[data-theme="contrast"] .secondary,
body[data-theme="contrast"] .ghost,
body[data-theme="contrast"] .theme-control select { background: #000 !important; color: #fff !important; border: 2px solid #fff !important; }
body[data-theme="contrast"] .primary { background: #ffe600 !important; color: #000 !important; border: 2px solid #fff !important; }
body[data-theme="contrast"] a, body[data-theme="contrast"] .link-button { color: #78d9ff !important; text-decoration: underline; }

@media (max-width: 1080px) { .theme-control span { display: none; } }
@media (max-width: 760px) {
  #app-shell > .workspace > header { height: auto; min-height: 68px; align-items: center; gap: 10px; padding-top: 10px; padding-bottom: 10px; }
  .header-actions { gap: 7px; }
  .theme-control select { max-width: 105px; }
  .wa-grid { gap: 12px; }
  .wa-hero h1 { font-size: clamp(2rem, 11vw, 3rem); line-height: 1.02; }
  .agenda-calendar-head { flex-direction: column; }
  .month-switcher { width: 100%; }
  .month-switcher button { flex: 0 0 auto; }
  .month-switcher #agenda-today { flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; } }

/* La navegación conserva la identidad institucional en todas las apariencias. */
body[data-theme] .sidebar { background: #112a40 !important; color: #d8e1e7 !important; border-right: 1px solid rgba(197,154,87,.22); }
body[data-theme] .side-brand strong { color: #ffffff !important; }
body[data-theme] .side-brand span { color: #91a8b7 !important; }
body[data-theme] .side-logo { color: #e7ca9a !important; border-color: #c59a57 !important; background: transparent !important; }
body[data-theme] .nav-item { color: #c5d1d9 !important; background: transparent !important; }
body[data-theme] .nav-item span { color: #88a5b6 !important; }
body[data-theme] .nav-item:hover, body[data-theme] .nav-item:focus-visible, body[data-theme] .nav-item.active { color: #ffffff !important; background: #204258 !important; outline-color: #e1bd82; }
body[data-theme] .nav-item.active span { color: #e1bd82 !important; }
body[data-theme] .secure { border-top-color: rgba(255,255,255,.12) !important; }
body[data-theme] .secure strong { color: #e0e6e9 !important; }
body[data-theme] .secure small, body[data-theme] .logout { color: #96aab7 !important; }
body[data-theme] .secure span { color: #71b592 !important; }

/* Logo institucional: conserva el azul profundo y el dorado original en toda apariencia. */
.monogram, .side-logo { overflow: hidden; background: #071a2b; }
.monogram img, .side-logo img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: center; }
.monogram { border-color: #d0aa70; }
.side-logo { border-color: #c59a57 !important; }
