/**
 * Panel — acabado tipo Untitled UI (SaaS docs/dashboard).
 * Sobrescribe tokens M3 cuando html tiene data-ui="untitled".
 */

html[data-ui="untitled"] {
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'Roboto Mono', ui-monospace, 'Cascadia Code', Consolas, monospace;

  /* Gray scale (Untitled-like) */
  --ui-gray-25: #fcfcfd;
  --ui-gray-50: #f9fafb;
  --ui-gray-100: #f2f4f7;
  --ui-gray-200: #eaecf0;
  --ui-gray-300: #d0d5dd;
  --ui-gray-400: #98a2b3;
  --ui-gray-500: #667085;
  --ui-gray-600: #475467;
  --ui-gray-700: #344054;
  --ui-gray-800: #1d2939;
  --ui-gray-900: #101828;

  /* Brand purple */
  --ui-brand-50: #f4f3ff;
  --ui-brand-100: #ebe9fe;
  --ui-brand-600: #6941c6;
  --ui-brand-700: #5925dc;
  --ui-brand-800: #4a1fb8;

  --md-ref-typeface-brand: var(--font);
  --md-ref-typeface-plain: var(--font);
}

html[data-ui="untitled"][data-theme="light"],
html[data-ui="untitled"]:not([data-theme="dark"]) {
  color-scheme: light;

  --md-sys-color-primary: var(--ui-brand-600);
  --md-sys-color-on-primary: #ffffff;
  --md-sys-color-primary-container: var(--ui-brand-50);
  --md-sys-color-on-primary-container: var(--ui-brand-800);

  --md-sys-color-secondary: var(--ui-gray-600);
  --md-sys-color-on-secondary: #ffffff;
  --md-sys-color-secondary-container: var(--ui-gray-100);
  --md-sys-color-on-secondary-container: var(--ui-gray-800);

  --md-sys-color-surface: var(--ui-gray-50);
  --md-sys-color-on-surface: var(--ui-gray-900);
  --md-sys-color-on-surface-variant: var(--ui-gray-500);
  --md-sys-color-surface-container-lowest: #ffffff;
  --md-sys-color-surface-container-low: var(--ui-gray-50);
  --md-sys-color-surface-container: #ffffff;
  --md-sys-color-surface-container-high: var(--ui-gray-100);
  --md-sys-color-surface-container-highest: var(--ui-gray-200);
  --md-sys-color-outline: var(--ui-gray-400);
  --md-sys-color-outline-variant: var(--ui-gray-200);

  --md-sys-shape-corner-medium: 8px;
  --md-sys-shape-corner-large: 12px;
}

html[data-ui="untitled"][data-theme="dark"] {
  color-scheme: dark;

  --md-sys-color-primary: #b692f6;
  --md-sys-color-on-primary: #2a1066;
  --md-sys-color-primary-container: #3e1c96;
  --md-sys-color-on-primary-container: #ebe9fe;

  --md-sys-color-surface: #0c111d;
  --md-sys-color-on-surface: #f9fafb;
  --md-sys-color-on-surface-variant: #98a2b3;
  --md-sys-color-surface-container-lowest: #0c111d;
  --md-sys-color-surface-container-low: #101828;
  --md-sys-color-surface-container: #1d2939;
  --md-sys-color-surface-container-high: #344054;
  --md-sys-color-surface-container-highest: #475467;
  --md-sys-color-outline-variant: #344054;
}

html[data-ui="untitled"] body {
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --- Shell --- */
html[data-ui="untitled"] .ws-shell {
  background: var(--md-sys-color-surface);
}

html[data-ui="untitled"] .ws-sidebar {
  width: 280px;
  background: var(--md-sys-color-surface-container-lowest);
  border-right: 1px solid var(--md-sys-color-outline-variant);
  box-shadow: none;
}

html[data-ui="untitled"] .ws-sidebar-brand {
  min-height: 72px;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  gap: 0.75rem;
}

html[data-ui="untitled"] .ws-brand-mark {
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--ui-brand-600), var(--ui-brand-700));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  flex-shrink: 0;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06), inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

html[data-ui="untitled"] .ws-sidebar-brand strong {
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--md-sys-color-on-surface);
}

html[data-ui="untitled"] .ws-sidebar-brand small {
  font-size: 0.75rem;
  text-transform: none;
  letter-spacing: 0;
  color: var(--md-sys-color-on-surface-variant);
  font-weight: 400;
}

html[data-ui="untitled"] .ws-sidebar-search {
  position: relative;
  padding: 0.75rem 1rem 0.25rem;
}

html[data-ui="untitled"] .ws-sidebar-search .material-symbols-outlined {
  position: absolute;
  left: 1.65rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 18px;
  color: var(--ui-gray-400);
  pointer-events: none;
}

html[data-ui="untitled"] .ws-sidebar-search input {
  width: 100%;
  padding: 0.5rem 0.75rem 0.5rem 2.25rem;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: 8px;
  background: var(--md-sys-color-surface-container-lowest);
  font-family: var(--font);
  font-size: 0.875rem;
  color: var(--md-sys-color-on-surface);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
}

html[data-ui="untitled"] .ws-sidebar-search input:focus {
  outline: none;
  border-color: var(--ui-brand-600);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--ui-brand-600) 18%, transparent);
}

html[data-ui="untitled"] .ws-hub-switcher {
  padding: 0.5rem 1rem 0.75rem;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  max-height: none;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem;
}

html[data-ui="untitled"] .ws-hub-btn {
  padding: 0.45rem 0.55rem;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 500;
  border: 1px solid transparent;
}

html[data-ui="untitled"] .ws-hub-btn:hover {
  background: var(--ui-gray-100);
  color: var(--ui-gray-700);
}

html[data-ui="untitled"] .ws-hub-btn.active {
  background: var(--ui-brand-50);
  color: var(--ui-brand-700);
  border-color: color-mix(in srgb, var(--ui-brand-600) 22%, transparent);
}

html[data-ui="untitled"][data-theme="dark"] .ws-hub-btn.active {
  background: color-mix(in srgb, var(--ui-brand-600) 18%, transparent);
  color: #ebe9fe;
}

html[data-ui="untitled"] .ws-nav {
  padding: 0.75rem 0.75rem 1.5rem;
}

html[data-ui="untitled"] .ws-nav-label {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ui-gray-400);
  padding: 0.75rem 0.75rem 0.35rem;
}

html[data-ui="untitled"] .ws-nav-link {
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ui-gray-600);
  gap: 0.65rem;
}

html[data-ui="untitled"] .ws-nav-link .material-symbols-outlined {
  font-size: 18px;
  color: var(--ui-gray-400);
}

html[data-ui="untitled"] .ws-nav-link:hover {
  background: var(--ui-gray-100);
  color: var(--ui-gray-800);
}

html[data-ui="untitled"] .ws-nav-link.active {
  background: var(--ui-gray-100);
  color: var(--ui-gray-900);
  box-shadow: inset 2px 0 0 0 var(--ui-brand-600);
}

html[data-ui="untitled"] .ws-nav-link.active .material-symbols-outlined {
  color: var(--ui-brand-600);
}

html[data-ui="untitled"][data-theme="dark"] .ws-nav-link:hover,
html[data-ui="untitled"][data-theme="dark"] .ws-nav-link.active {
  background: var(--md-sys-color-surface-container-high);
}

html[data-ui="untitled"] .ws-sidebar-footer {
  padding: 1rem 1.25rem;
  font-size: 0.8125rem;
}

html[data-ui="untitled"] .ws-sidebar-footer a {
  color: var(--ui-gray-500);
  text-decoration: none;
}

html[data-ui="untitled"] .ws-sidebar-footer a:hover {
  color: var(--ui-brand-600);
}

/* --- Topbar --- */
html[data-ui="untitled"] .ws-topbar {
  min-height: 72px;
  padding: 0 1.5rem;
  background: var(--md-sys-color-surface-container-lowest);
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

html[data-ui="untitled"] .ws-breadcrumb {
  font-size: 0.875rem;
  color: var(--ui-gray-500);
  gap: 0.25rem;
}

html[data-ui="untitled"] .ws-breadcrumb strong {
  color: var(--ui-gray-700);
  font-weight: 600;
}

html[data-ui="untitled"] .ws-breadcrumb .material-symbols-outlined {
  font-size: 14px;
  color: var(--ui-gray-300);
}

html[data-ui="untitled"] .ws-global-search {
  width: min(20rem, 36vw);
  border-radius: 8px;
  border-color: var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-container-lowest);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
}

html[data-ui="untitled"] .ws-global-search:focus {
  outline: none;
  border-color: var(--ui-brand-600);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--ui-brand-600) 18%, transparent);
}

html[data-ui="untitled"] .ws-user-chip {
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-container-lowest);
  color: var(--ui-gray-600);
  font-weight: 500;
}

html[data-ui="untitled"] .ws-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: 8px;
  background: var(--md-sys-color-surface-container-lowest);
  color: var(--ui-gray-500);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

html[data-ui="untitled"] .ws-icon-btn:hover {
  background: var(--ui-gray-100);
  color: var(--ui-gray-700);
}

html[data-ui="untitled"] .ws-icon-btn .material-symbols-outlined {
  font-size: 20px;
}

/* --- Content --- */
html[data-ui="untitled"] .ws-content {
  padding: 2rem 2rem 2.5rem;
  background: var(--md-sys-color-surface);
}

html[data-ui="untitled"] .ws-page-header h1 {
  font-size: 1.875rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--ui-gray-900);
}

html[data-ui="untitled"] .ws-page-header p {
  font-size: 1rem;
  color: var(--ui-gray-500);
  max-width: 42rem;
}

/* --- Cards & stats --- */
html[data-ui="untitled"] .ws-card,
html[data-ui="untitled"] .ws-stat,
html[data-ui="untitled"] .ws-stat-card,
html[data-ui="untitled"] .hub-launcher-card {
  background: var(--md-sys-color-surface-container-lowest);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
}

html[data-ui="untitled"] .hub-launcher-card:hover {
  border-color: color-mix(in srgb, var(--ui-brand-600) 35%, var(--ui-gray-200));
  box-shadow: 0 4px 8px -2px rgba(16, 24, 40, 0.08), 0 2px 4px -2px rgba(16, 24, 40, 0.06);
}

html[data-ui="untitled"] .hub-launcher-icon {
  border-radius: 10px;
  background: var(--ui-brand-50);
  color: var(--ui-brand-700);
}

html[data-ui="untitled"] .ws-stat-value {
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ui-gray-900);
}

/* --- Buttons --- */
html[data-ui="untitled"] .btn {
  border-radius: 8px;
  min-height: 40px;
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0;
  box-shadow: none;
}

html[data-ui="untitled"] .btn-primary {
  background: var(--ui-brand-600);
  color: #fff;
  border-color: var(--ui-brand-600);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
}

html[data-ui="untitled"] .btn-primary:hover {
  background: var(--ui-brand-700);
  border-color: var(--ui-brand-700);
  filter: none;
}

html[data-ui="untitled"] .btn-outlined,
html[data-ui="untitled"] .btn-ghost {
  border-radius: 8px;
  border-color: var(--md-sys-color-outline-variant);
  color: var(--ui-gray-700);
  background: var(--md-sys-color-surface-container-lowest);
}

html[data-ui="untitled"] .btn-outlined:hover,
html[data-ui="untitled"] .btn-ghost:hover {
  background: var(--ui-gray-100);
  color: var(--ui-gray-800);
}

html[data-ui="untitled"] .btn-sm {
  min-height: 36px;
  padding: 0.5rem 0.875rem;
  font-size: 0.8125rem;
}

/* --- Forms & tables --- */
html[data-ui="untitled"] .admin-search,
html[data-ui="untitled"] .admin-select,
html[data-ui="untitled"] input[type="text"],
html[data-ui="untitled"] input[type="email"],
html[data-ui="untitled"] input[type="password"],
html[data-ui="untitled"] input[type="search"],
html[data-ui="untitled"] select,
html[data-ui="untitled"] textarea {
  border-radius: 8px;
  border-color: var(--md-sys-color-outline-variant);
  font-family: var(--font);
}

html[data-ui="untitled"] .admin-table-wrap,
html[data-ui="untitled"] .ws-table-wrap {
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: 12px;
  overflow: hidden;
  background: var(--md-sys-color-surface-container-lowest);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
}

html[data-ui="untitled"] table.admin-table thead th {
  background: var(--ui-gray-50);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ui-gray-500);
}

html[data-ui="untitled"][data-theme="dark"] table.admin-table thead th {
  background: var(--md-sys-color-surface-container-high);
}

/* --- Auth (login) --- */
html[data-ui="untitled"] .top-app-bar,
html[data-ui="untitled"] .header {
  background: var(--md-sys-color-surface-container-lowest);
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

html[data-ui="untitled"] .auth-page {
  max-width: 400px;
}

html[data-ui="untitled"] .auth-form {
  background: var(--md-sys-color-surface-container-lowest);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 4px 8px -2px rgba(16, 24, 40, 0.08);
}

html[data-ui="untitled"] .form-group label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ui-gray-700);
}

html[data-ui="untitled"] .form-group input {
  border-radius: 8px;
}

/* Hide floating FAB — theme toggle lives in topbar */
html[data-ui="untitled"] .theme-fab {
  display: none !important;
}

/* Modo embed dentro del shell React */
html[data-panel-embed="1"] .ws-sidebar,
html[data-panel-embed="1"] .ws-topbar,
html[data-panel-embed="1"] .ws-sidebar-footer {
  display: none !important;
}

html[data-panel-embed="1"] .ws-shell {
  display: block;
}

html[data-panel-embed="1"] .ws-main {
  width: 100%;
  min-height: 100vh;
}

html[data-panel-embed="1"] .ws-content {
  padding: 1rem;
}
