/* Inter (Latin subset) self-hosted from /static/fonts/inter — was a
   Google Fonts @import that pulled ~500KB on every page-load. The six
   weights total ~100KB and are byte-cached by the Service Worker. */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/inter/inter-400.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/static/fonts/inter/inter-500.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/static/fonts/inter/inter-600.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/static/fonts/inter/inter-700.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url("/static/fonts/inter/inter-800.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 900;
  font-display: swap;
  src: url("/static/fonts/inter/inter-900.woff2") format("woff2");
}
@import url("https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:wght,FILL@100..700,0..1&display=swap");

/* Yellow banner that <noscript> renders when JS is disabled. Was an
   inline style on every page; lifted here so a future strict CSP can
   drop 'unsafe-inline' from style-src-elem. */
.noscript-warning {
  background: #fef3c7;
  color: #78350f;
  padding: 12px 16px;
  border-radius: 8px;
  margin: 12px;
  text-align: center;
  font-family: system-ui, sans-serif;
}

/* Tiny spacing utilities introduced for the inline-style cleanup pass.
   Same naming as Tailwind so the migration to a built CSS bundle is
   trivial later. */
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.m-0 { margin: 0; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.w-full { width: 100%; }

:root {
  color-scheme: dark;
  /* Color Palette - Modern Dark */
  --primary-color: #2b6cee;
  /* Panel primary blue */
  --primary-hover: #1d4ed8;
  /* Blue 700 */
  --bg-page: #101622;
  /* Design background-dark */
  --bg-surface: rgba(30, 41, 59, 0.8);
  /* Slate 800/80 */
  --bg-item: rgba(15, 23, 42, 0.62);
  /* Semi-transparent Slate 800 */
  --bg-item-hover: rgba(51, 65, 85, 0.72);
  /* Slate hover */

  --text-main: #f8fafc;
  /* Slate 50 */
  --text-secondary: #94a3b8;
  /* Slate 400 */
  --text-on-primary: #ffffff;
  /* White text on primary button */

  --border-color: #334155;
  /* Slate 700 */
  --focus-ring: rgba(43, 108, 238, 0.28);

  --btn-hover-bg: #334155;
  /* Slate 700 */
  --btn-hover-border: #475569;
  /* Slate 600 */

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.18);
  --shadow-md: 0 8px 18px -8px rgb(0 0 0 / 0.42);
  --shadow-lg: 0 20px 45px -18px rgb(0 0 0 / 0.55);

  /* Radius */
  --radius-card: 12px;
  --radius-input: 8px;
  --radius-sm: 4px;
  --radius-lg: 12px;

  /* Spacing scale */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1.5rem;
  --spacing-lg: 2rem;
  --spacing-xl: 3rem;
  /* Fluid section spacing — between dashboard surface tiers */
  --space-section: clamp(1rem, 0.75rem + 1.5vw, 2rem);

  /* Semantic radius scale: pill = controls, surface = panels, input = fields */
  --radius-pill: 999px;
  --radius-surface: 16px;
  --radius-control: 10px;

  /* Typography scale */
  --text-xs: 12px;
  --text-sm: 13px;
  --text-base: 15px;
  --text-md: 17px;
  --text-lg: 20px;
  --text-xl: 24px;

  /* Status colors (semantic) */
  --color-success: #22c55e;
  --color-success-bg: rgba(34, 197, 94, 0.12);
  --color-warning: #f59e0b;
  --color-warning-bg: rgba(245, 158, 11, 0.12);
  --color-danger: #ef4444;
  --color-danger-bg: rgba(239, 68, 68, 0.12);
  --color-info: #3b82f6;
  --color-info-bg: rgba(59, 130, 246, 0.12);
  --color-muted: #9aa4af;

  /* Z-index layers */
  --z-base: 1;
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-overlay: 900;
  --z-notification: 1000;
  --z-modal: 1200;
  --z-toast: 1500;

  /* Breakpoints (reference only, use in media queries) */
  --bp-mobile: 640px;
  --bp-tablet: 1024px;
}

[data-theme="light"] {
  color-scheme: light;
  --primary-color: #2b6cee;
  /* Design primary */
  --primary-hover: #1d4ed8;
  /* Blue 700 */
  --bg-page: #f6f6f8;
  /* Design background-light */
  --bg-surface: #ffffff;
  /* White */
  --bg-item: #f8fafc;
  /* Slate 50 for cards inner content */
  --bg-item-hover: #ffffff;
  /* White on hover */

  --text-main: #0f172a;
  /* Slate 900 */
  --text-secondary: #475569;
  /* Slate 600 */
  --text-on-primary: #ffffff;

  --border-color: #e2e8f0;
  /* Slate 200 */
  --focus-ring: rgba(43, 108, 238, 0.2);

  --btn-hover-bg: #f8fafc;
  /* Slate 50 */
  --btn-hover-border: #94a3b8;
  /* Slate 400 */

  /* Light Mode optimized soft shadows */
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
}

.material-symbols-outlined {
  font-family: "Material Symbols Outlined";
  font-weight: normal;
  font-style: normal;
  font-size: 1.25em;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-feature-settings: "liga";
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "liga";
}


/* Base Body Style for Modern Pages */
body.modern-body {
  background-color: var(--bg-page);
  background-image: none !important;
  /* Override legacy dashboard.css gradients */
  color: var(--text-main);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  line-height: 1.5;
}

.page {
  max-width: 1200px;
}

/* Modern Card */
.card-modern {
  background-color: var(--bg-surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-sm);
  padding: var(--spacing-md);
  border: 1px solid var(--border-color);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, border-left-color 0.2s ease;
  position: relative;
}

/* Priority Colors Support */
body.priority-colors-enabled .card-modern.priority-alta {
  border-left: 8px solid #ef4444;
  /* Red 500 */
  background: linear-gradient(to right, rgba(239, 68, 68, 0.1), var(--bg-surface) 15%);
}

body.priority-colors-enabled .card-modern.priority-media {
  border-left: 8px solid #f97316;
  /* Orange 500 */
  background: linear-gradient(to right, rgba(249, 115, 22, 0.1), var(--bg-surface) 15%);
}

body.priority-colors-enabled .card-modern.priority-baja {
  border-left: 8px solid #22c55e;
  /* Green 500 */
  background: linear-gradient(to right, rgba(34, 197, 94, 0.1), var(--bg-surface) 15%);
}

.card-modern:hover {
  transform: translateY(-2px);
  border-color: rgba(43, 108, 238, 0.5);
  box-shadow: var(--shadow-md);
}

.card-modern h3 {
  margin-top: 0;
  color: var(--text-main);
  font-size: 1.25rem;
  font-weight: 600;
}

.card-modern p {
  color: var(--text-secondary);
}

/* Modern Forms */
.form-control-modern {
  display: block;
  width: 100%;
  padding: 0.75rem 1rem;
  /* Finger friendly padding */
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text-main);
  background-color: var(--bg-item);
  border: 0;
  border-radius: var(--radius-input);
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-control-modern:focus {
  outline: 0;
  box-shadow: 0 0 0 3px var(--focus-ring);
}

/* Buttons */
.btn-modern {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  /* Finger friendly */
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius-input);
  cursor: pointer;
  transition: all 0.2s;
  background-color: var(--bg-item);
  border: 1px solid transparent;
  color: var(--text-main);
  text-decoration: none;
}

.btn-modern .material-symbols-outlined {
  font-size: 1.125rem;
  line-height: 1;
}

.btn-modern:hover {
  background-color: var(--btn-hover-bg);
  border-color: var(--btn-hover-border);
  transform: translateY(-1px);
}

.btn-modern-primary {
  background-color: rgba(43, 108, 238, 0.16);
  color: var(--primary-color);
  border: 1px solid transparent;
  font-weight: 700;
}

.btn-modern-primary:hover {
  background-color: rgba(43, 108, 238, 0.26);
  box-shadow: var(--shadow-md);
  color: var(--primary-color);
}

/* Utility for demonstrating grid layout */
.modern-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
  margin: 2rem;
}

/* ========== Semantic status utilities ========== */
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-danger  { color: var(--color-danger); }
.text-info    { color: var(--color-info); }
.text-muted   { color: var(--color-muted); }

.bg-success { background-color: var(--color-success-bg); color: var(--color-success); }
.bg-warning { background-color: var(--color-warning-bg); color: var(--color-warning); }
.bg-danger  { background-color: var(--color-danger-bg);  color: var(--color-danger); }
.bg-info    { background-color: var(--color-info-bg);    color: var(--color-info); }

.btn-success { background-color: var(--color-success); color: #fff; border: 1px solid transparent; }
.btn-success:hover { filter: brightness(1.1); }
.btn-danger  { background-color: var(--color-danger);  color: #fff; border: 1px solid transparent; }
.btn-danger:hover  { filter: brightness(1.1); }
.btn-warning { background-color: var(--color-warning); color: #0f172a; border: 1px solid transparent; }
.btn-warning:hover { filter: brightness(1.1); }

/* ========== Form error state ========== */
.form-control-modern[aria-invalid="true"],
.form-control-modern.is-invalid {
  border-color: var(--color-danger);
  box-shadow: 0 0 0 3px var(--color-danger-bg);
}
.form-error-msg {
  color: var(--color-danger);
  font-size: var(--text-xs);
  margin-top: var(--spacing-xs);
  display: block;
}

/* ========== Global focus-visible (a11y) ========== */
:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}
.btn-modern:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--focus-ring);
}
.form-control-modern:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 3px var(--focus-ring);
  border-color: var(--primary-color);
}

/* ========== Skip link (a11y) ========== */
.skip-link {
  position: absolute;
  top: -100px;
  left: 0;
  background: var(--primary-color);
  color: var(--text-on-primary);
  padding: 0.5rem 1rem;
  z-index: var(--z-toast);
  text-decoration: none;
  border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus { top: 0; }

/* ========== Visually hidden (screen reader only) ========== */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ========== Skeleton loaders ========== */
.skeleton {
  display: inline-block;
  background: linear-gradient(
    90deg,
    var(--border-color) 0%,
    var(--bg-item-hover) 50%,
    var(--border-color) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
  border-radius: var(--radius-sm, 6px);
  color: transparent;
  user-select: none;
  pointer-events: none;
}
.skeleton--text { height: 1em; width: 100%; margin: 4px 0; }
.skeleton--title { height: 1.5em; width: 60%; }
.skeleton--avatar { width: 40px; height: 40px; border-radius: 50%; }
.skeleton--card { height: 80px; width: 100%; border-radius: var(--radius-md, 12px); }
.skeleton--row { height: 24px; width: 100%; margin: 6px 0; }
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; opacity: 0.7; }
}

/* ========== Spinner (loading) ========== */
.spinner-modern {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-color);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spinner-rotate 0.8s linear infinite;
  vertical-align: middle;
}
.spinner-modern--lg { width: 32px; height: 32px; border-width: 3px; }
@keyframes spinner-rotate { to { transform: rotate(360deg); } }

/* Empty state */
.empty-state {
  text-align: center;
  padding: var(--spacing-xl, 32px) var(--spacing-md, 16px);
  color: var(--text-secondary);
}
.empty-state__icon {
  font-size: 2.5rem;
  opacity: 0.5;
  margin-bottom: var(--spacing-sm, 8px);
}
.empty-state__title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-main);
  margin: 0 0 4px;
}
.empty-state__message {
  font-size: 0.875rem;
  margin: 0 0 var(--spacing-md, 16px);
}

/* ========== Reduced motion ========== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ========== Print styles ========== */
@media print {
  body { background: #fff !important; color: #000 !important; }
  .nav-header, .skip-link, .toast-container, .modal, [role="dialog"],
  button, .btn-modern, #colOpts, .form-control-modern,
  .actions-cell { display: none !important; }
  .card-modern { box-shadow: none !important; border: 1px solid #ccc !important; page-break-inside: avoid; }
  table { page-break-inside: auto; }
  tr { page-break-inside: avoid; page-break-after: auto; }
  thead { display: table-header-group; }
  a { color: inherit; text-decoration: none; }
  a[href]::after { content: " (" attr(href) ")"; font-size: 0.8em; color: #555; }
  a[href^="#"]::after, a[href^="javascript"]::after { content: ""; }
}

/* ========== Toast notifications ========== */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: calc(100vw - 32px);
}
.toast {
  pointer-events: auto;
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--primary-color);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
  font-size: var(--text-sm);
  min-width: 240px;
  max-width: 360px;
  animation: toast-in 0.18s ease-out;
}
.toast--success { border-left-color: var(--color-success); }
.toast--danger  { border-left-color: var(--color-danger); }
.toast--warning { border-left-color: var(--color-warning); }
.toast--info    { border-left-color: var(--primary-color); }
.toast.toast--leaving { animation: toast-out 0.18s ease-in forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toast-out { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(20px); } }

/* ========== Responsive table wrapper ========== */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 640px) {
  /* Card-stack tables: opt-in via .table-stack class */
  .table-stack thead { display: none; }
  .table-stack, .table-stack tbody, .table-stack tr, .table-stack td {
    display: block;
    width: 100%;
  }
  .table-stack tr {
    margin-bottom: var(--spacing-sm);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: var(--spacing-sm);
    background: var(--bg-item);
  }
  .table-stack td {
    display: flex;
    justify-content: space-between;
    gap: var(--spacing-sm);
    padding: 0.25rem 0;
    border: 0;
  }
  .table-stack td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: var(--text-xs);
  }
}

/* ========== Modal baseline (a11y) ========== */
[role="dialog"][aria-modal="true"] {
  z-index: var(--z-modal);
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: var(--z-overlay);
}
