@import url('m3.css');

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--md-sys-color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.top-app-bar,
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 64px;
  padding: 0 1.25rem 0 0.5rem;
  background: var(--md-sys-color-surface);
  border-bottom: 1px solid var(--md-sys-color-surface-container-highest);
  position: sticky;
  top: 0;
  z-index: 100;
}

.top-app-bar-start { display: flex; align-items: center; gap: 0.25rem; }

.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
  font-size: 1.35rem;
  color: var(--md-sys-color-on-surface);
  text-decoration: none;
  padding: 0.5rem 0.75rem;
  border-radius: 999px;
}

.logo:hover { background: color-mix(in srgb, var(--md-sys-color-on-surface) 8%, transparent); text-decoration: none; }

.nav { display: flex; align-items: center; gap: 0.25rem; flex-wrap: wrap; }

.nav a:not(.btn) {
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.5rem 0.75rem;
  border-radius: 999px;
  text-decoration: none;
}

.nav a:not(.btn):hover {
  color: var(--md-sys-color-on-surface);
  background: color-mix(in srgb, var(--md-sys-color-on-surface) 8%, transparent);
  text-decoration: none;
}

.nav-actions { display: flex; align-items: center; gap: 0.75rem; margin-left: 0.75rem; flex-shrink: 0; }

/* Botones M3 nativos (padding fiable en todos los navegadores) */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  min-height: 44px;
  border-radius: 999px;
  font-size: 0.9375rem;
  font-weight: 500;
  font-family: var(--font);
  line-height: 1.3;
  letter-spacing: 0.01em;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: filter 0.15s, background 0.15s, box-shadow 0.15s;
}

.btn-primary {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  box-shadow: 0 1px 2px color-mix(in srgb, var(--md-sys-color-on-surface) 25%, transparent);
}

.btn-primary:hover {
  filter: brightness(1.08);
  text-decoration: none;
  color: var(--md-sys-color-on-primary);
}

.btn-outlined,
.btn-ghost {
  background: transparent;
  color: var(--md-sys-color-primary);
  border-color: var(--md-sys-color-outline);
}

.btn-outlined:hover,
.btn-ghost:hover {
  background: color-mix(in srgb, var(--md-sys-color-primary) 10%, transparent);
  text-decoration: none;
  color: var(--md-sys-color-primary);
}

.btn-lg {
  padding: 0.875rem 2rem;
  min-height: 52px;
  font-size: 1rem;
}

.btn-block { width: 100%; }

.btn-sm {
  padding: 0.5rem 1.125rem;
  min-height: 36px;
  font-size: 0.8125rem;
}

/* Material Web — solo campos de texto */
md-outlined-text-field {
  width: 100%;
  display: block;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--md-sys-color-on-surface);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 999px;
}

.menu-toggle:hover { background: color-mix(in srgb, var(--md-sys-color-on-surface) 8%, transparent); }

.auth-form .btn { margin-top: 0.25rem; }

.hero { padding: 4rem 1.5rem 3rem; max-width: 960px; margin: 0 auto; text-align: center; }
.hero h1 { font-size: clamp(2.25rem, 5vw, 3.5rem); line-height: 1.12; margin-bottom: 1.25rem; font-weight: 400; }
.gradient { color: var(--md-sys-color-primary); }
.lead { font-size: 1.125rem; color: var(--md-sys-color-on-surface-variant); max-width: 640px; margin: 0 auto 2rem; line-height: 1.7; }
.label-large { font-size: 0.875rem; font-weight: 500; letter-spacing: 0.02em; }
.text-muted { color: var(--md-sys-color-on-surface-variant); }

.terminal {
  background: var(--md-sys-color-surface-container-high);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-large);
  padding: 1.25rem 1.5rem;
  text-align: left;
  margin: 0 auto 2rem;
  max-width: 560px;
}

.terminal code { display: block; font-family: var(--mono); font-size: 0.9rem; color: var(--md-sys-color-tertiary); }
.terminal code.dim { color: var(--md-sys-color-on-surface-variant); margin-top: 0.5rem; font-size: 0.85rem; }
.hero-actions { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; align-items: center; }

.section { max-width: 960px; margin: 0 auto; padding: 3rem 1.5rem; }
.section h2 { font-size: 1.75rem; font-weight: 400; margin-bottom: 1.5rem; }
.steps { padding-left: 1.25rem; }
.steps li { margin-bottom: 1.5rem; }
.steps pre, pre {
  background: var(--md-sys-color-surface-container-high);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-medium);
  padding: 1rem;
  overflow-x: auto;
  margin-top: 0.5rem;
  font-family: var(--mono);
  font-size: 0.85rem;
}

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.grid article, .card {
  background: var(--md-sys-color-surface-container);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-large);
  padding: 1.5rem;
}

.features article {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.feature-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--md-sys-color-primary) 14%, transparent);
  color: var(--md-sys-color-primary);
  margin-bottom: 1rem;
  flex-shrink: 0;
}

.feature-icon .material-symbols-outlined {
  font-size: 28px;
  line-height: 1;
}

.features article h3 { margin-bottom: 0.5rem; }
.features article p { max-width: 22ch; }

/* Diagramas Mermaid */
.diagram-section { margin-top: 2rem; }
.diagram-section h3 {
  font-size: 1.15rem;
  font-weight: 500;
  margin-bottom: 1rem;
  color: var(--md-sys-color-on-surface);
}

.diagram-card {
  background: var(--md-sys-color-surface-container);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-large);
  padding: 1.25rem 1rem;
  margin-bottom: 2rem;
  overflow-x: auto;
}

.diagram-card .mermaid {
  display: flex;
  justify-content: center;
  min-width: min(100%, 640px);
  margin: 0 auto;
}

.diagram-card .mermaid svg {
  max-width: 100%;
  height: auto;
}

.flow-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin: 1.5rem 0 2rem;
  list-style: none;
  padding: 0;
  counter-reset: flow;
}

.flow-steps li {
  counter-increment: flow;
  background: var(--md-sys-color-surface-container-high);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-medium);
  padding: 1rem 0.75rem;
  text-align: center;
  font-size: 0.875rem;
  position: relative;
}

.flow-steps li::before {
  content: counter(flow);
  display: block;
  width: 28px;
  height: 28px;
  line-height: 28px;
  border-radius: 50%;
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  font-weight: 500;
  font-size: 0.8rem;
  margin: 0 auto 0.5rem;
}

.section-intro {
  color: var(--md-sys-color-on-surface-variant);
  max-width: 640px;
  margin-bottom: 2rem;
  line-height: 1.7;
}

.security-legend {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0 2rem;
}

.security-legend article {
  background: var(--md-sys-color-surface-container);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-large);
  padding: 1.25rem;
}

.security-legend p {
  margin-top: 0.75rem;
  font-size: 0.875rem;
  color: var(--md-sys-color-on-surface-variant);
  line-height: 1.5;
}

.security-badge {
  display: inline-block;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.security-badge-ok { background: color-mix(in srgb, var(--md-sys-color-tertiary) 25%, transparent); color: var(--md-sys-color-tertiary); }
.security-badge-warn { background: color-mix(in srgb, var(--md-sys-color-primary) 20%, transparent); color: var(--md-sys-color-primary); }
.security-badge-info { background: var(--md-sys-color-surface-container-highest); color: var(--md-sys-color-on-surface-variant); }
.security-badge-alert { background: color-mix(in srgb, var(--md-sys-color-error) 18%, transparent); color: var(--md-sys-color-error); }
.card-featured { border-color: var(--md-sys-color-primary); background: var(--md-sys-color-surface-container-high); }
.card h3, .grid article h3 { margin-bottom: 0.5rem; font-weight: 500; }
.price { font-size: 2rem; font-weight: 400; margin-bottom: 1rem; }
.card ul { list-style: none; margin-bottom: 1.5rem; }
.card li::before { content: "check "; font-family: 'Material Symbols Outlined'; font-size: 1rem; color: var(--md-sys-color-primary); }
.pricing-grid { max-width: 720px; }

.footer {
  text-align: center;
  padding: 2rem 1.5rem;
  border-top: 1px solid var(--md-sys-color-surface-container-highest);
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.875rem;
  background: var(--md-sys-color-surface-container-low);
}

.auth-page {
  max-width: 420px;
  margin: 3rem auto;
  padding: 2rem;
  background: var(--md-sys-color-surface-container);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-extra-large);
}
.auth-page h1 { margin-bottom: 1.5rem; font-size: 1.5rem; font-weight: 400; }
.auth-form { display: flex; flex-direction: column; gap: 1rem; }
.form-group label { display: block; margin-bottom: 0.35rem; color: var(--md-sys-color-on-surface-variant); font-size: 0.8rem; font-weight: 500; }
.form-group input, .admin-table select, .admin-form select, .admin-dialog select {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--md-sys-color-outline);
  border-radius: var(--md-sys-shape-corner-extra-small);
  background: var(--md-sys-color-surface-container-highest);
  color: var(--md-sys-color-on-surface);
  font-size: 1rem;
  font-family: var(--font);
}
md-outlined-text-field { width: 100%; }
.form-error { color: var(--md-sys-color-error); font-size: 0.875rem; }
.form-success { color: var(--md-sys-color-tertiary); font-size: 0.875rem; }

/* FAB — cambio de tema */
.theme-fab {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 200;
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  box-shadow: var(--theme-fab-shadow);
  transition: background 0.2s, box-shadow 0.2s, transform 0.15s;
}

.theme-fab:hover {
  box-shadow: var(--theme-fab-shadow-hover);
  filter: brightness(1.05);
}

.theme-fab:active { transform: scale(0.94); }

.theme-fab .material-symbols-outlined { font-size: 26px; }

@media (max-width: 768px) {
  .theme-fab {
    bottom: 1rem;
    right: 1rem;
    width: 52px;
    height: 52px;
  }
}

.docs pre {
  background: var(--md-sys-color-surface-container-high);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-medium);
  padding: 1rem;
  overflow-x: auto;
  margin: 1rem 0;
  font-size: 0.88rem;
}
.docs pre code { font-family: var(--mono); }

.docs-layout { display: grid; grid-template-columns: 240px 1fr; max-width: 1200px; margin: 0 auto; }
.docs-sidebar {
  position: sticky; top: 64px; padding: 1.5rem 1rem 2rem 1.5rem;
  border-right: 1px solid var(--md-sys-color-surface-container-highest);
  max-height: calc(100vh - 64px); overflow-y: auto;
  background: var(--md-sys-color-surface-container-low);
}
.docs-sidebar-title { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--md-sys-color-on-surface-variant); margin-bottom: 0.75rem; }
.docs-toc { display: flex; flex-direction: column; gap: 0.15rem; }
.docs-toc a { color: var(--md-sys-color-on-surface-variant); font-size: 0.875rem; padding: 0.45rem 0.75rem; border-radius: 999px; text-decoration: none; }
.docs-toc a:hover, .docs-toc a.active { color: var(--md-sys-color-on-surface); background: color-mix(in srgb, var(--md-sys-color-primary) 12%, transparent); }
.docs-main { padding: 1.5rem 2rem 4rem; }
.docs-section { margin-top: 2.5rem; padding-top: 1.5rem; border-top: 1px solid var(--md-sys-color-surface-container-highest); }
.docs-section:first-of-type { border-top: none; margin-top: 1rem; }
.docs-section h2 { font-size: 1.5rem; font-weight: 400; margin-bottom: 1rem; }
.docs-section h3 { margin: 1.5rem 0 0.75rem; font-size: 1.1rem; font-weight: 500; }
.docs-section h4 { margin: 1.25rem 0 0.5rem; font-size: 1rem; font-weight: 500; }
.legal-page h2 { margin: 1.5rem 0 0.75rem; font-size: 1.15rem; font-weight: 500; }
.legal-page p, .legal-page li { color: var(--md-sys-color-on-surface-variant); line-height: 1.6; }
.status-pill { display: inline-block; font-weight: 500; padding: 0.35rem 0.85rem; border-radius: 999px; font-size: 0.9rem; }
.status-ok { background: color-mix(in srgb, #2e7d32 20%, transparent); color: #81c784; }
.status-down { background: color-mix(in srgb, #c62828 25%, transparent); color: #ef9a9a; }
.card-warn { border-color: color-mix(in srgb, #c62828 40%, var(--md-sys-color-outline-variant)); }
.docs-list { margin: 0.75rem 0 1rem 1.25rem; color: var(--md-sys-color-on-surface-variant); }
.docs-table { width: 100%; border-collapse: collapse; margin: 1rem 0; font-size: 0.9rem; }
.docs-table th, .docs-table td { border: 1px solid var(--md-sys-color-outline-variant); padding: 0.75rem 1rem; }
.docs-table th { background: var(--md-sys-color-surface-container-high); font-weight: 500; }
.docs-callout { background: color-mix(in srgb, var(--md-sys-color-primary-container) 35%, transparent); border: 1px solid var(--md-sys-color-primary-container); border-radius: var(--md-sys-shape-corner-medium); padding: 1rem 1.25rem; margin: 1rem 0; }
.docs-callout-warn { background: color-mix(in srgb, var(--md-sys-color-tertiary-container) 25%, transparent); border-color: var(--md-sys-color-tertiary-container); }

.admin-badge { font-size: 0.65rem; font-weight: 500; color: var(--md-sys-color-on-primary-container); background: var(--md-sys-color-primary-container); padding: 0.15rem 0.5rem; border-radius: 999px; margin-left: 0.35rem; text-transform: uppercase; }
.admin-page { max-width: 1200px; margin: 0 auto; padding: 1.5rem; }
.admin-tabs { display: flex; flex-wrap: wrap; margin-bottom: 1.5rem; border-bottom: 1px solid var(--md-sys-color-surface-container-highest); }
.admin-tab { background: transparent; border: none; border-bottom: 3px solid transparent; color: var(--md-sys-color-on-surface-variant); padding: 0.75rem 1.25rem; cursor: pointer; font-family: var(--font); font-size: 0.875rem; font-weight: 500; margin-bottom: -1px; }
.admin-tab.active { color: var(--md-sys-color-primary); border-bottom-color: var(--md-sys-color-primary); }
.admin-panel { display: none; }
.admin-panel.active { display: block; }
.admin-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; }
.stat-card { background: var(--md-sys-color-surface-container); border: 1px solid var(--md-sys-color-outline-variant); border-radius: var(--md-sys-shape-corner-large); padding: 1.25rem; }
.stat-card strong { display: block; font-size: 2rem; font-weight: 400; }
.stat-label, .stat-card small, .admin-subtitle { color: var(--md-sys-color-on-surface-variant); }
.admin-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.table-wrap { overflow-x: auto; border: 1px solid var(--md-sys-color-outline-variant); border-radius: var(--md-sys-shape-corner-medium); }
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.admin-table th, .admin-table td { border-bottom: 1px solid var(--md-sys-color-outline-variant); padding: 0.85rem 1rem; }
.admin-table th { background: var(--md-sys-color-surface-container-high); color: var(--md-sys-color-on-surface-variant); font-weight: 500; }
.badge { display: inline-block; padding: 0.2rem 0.6rem; border-radius: 999px; font-size: 0.75rem; background: var(--md-sys-color-surface-container-highest); }
.badge-ok { background: color-mix(in srgb, var(--md-sys-color-tertiary) 20%, transparent); color: var(--md-sys-color-tertiary); }
.badge-warn { background: color-mix(in srgb, var(--md-sys-color-error) 15%, transparent); color: var(--md-sys-color-error); }
.badge-accent { background: var(--md-sys-color-primary-container); color: var(--md-sys-color-on-primary-container); }
.admin-form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
.admin-dialog {
  margin: auto;
  border: none;
  border-radius: var(--md-sys-shape-corner-extra-large);
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface);
  padding: 1.5rem;
  width: min(520px, 92vw);
  max-height: min(90vh, 640px);
  overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.admin-dialog::backdrop { background: rgba(0, 0, 0, 0.6); }

.admin-dialog h3 {
  margin-bottom: 1.25rem;
  font-size: 1.25rem;
  font-weight: 500;
}

.admin-dialog .form-group { margin-bottom: 0.85rem; }

.admin-dialog .admin-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.5rem 0;
  font-size: 0.9rem;
  cursor: pointer;
}
.dialog-actions { display: flex; justify-content: flex-end; gap: 0.75rem; margin-top: 1rem; flex-wrap: wrap; }

.changelog-page { max-width: 720px; margin: 0 auto; padding: 2rem 1.5rem 3rem; }
.changelog-entry { margin-bottom: 2.5rem; padding-bottom: 2rem; border-bottom: 1px solid var(--md-sys-color-outline-variant); }
.changelog-entry:last-child { border-bottom: none; }
.changelog-header { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.changelog-header h2 { margin: 0; font-size: 1.35rem; }
.changelog-header h2 a { color: inherit; text-decoration: none; }
.changelog-header time { color: var(--md-sys-color-on-surface-variant); font-size: 0.9rem; }
.changelog-entry h3 { font-size: 0.95rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--md-sys-color-on-surface-variant); margin: 1.25rem 0 0.5rem; }
.changelog-install { margin-top: 1rem; padding: 0.75rem 1rem; background: var(--md-sys-color-surface-container-high); border-radius: var(--md-sys-shape-corner-medium); font-size: 0.92rem; }

@media (max-width: 900px) {
  .docs-layout { grid-template-columns: 1fr; }
  .docs-sidebar { position: static; border-right: none; border-bottom: 1px solid var(--md-sys-color-surface-container-highest); max-height: none; }
  .docs-toc { flex-direction: row; flex-wrap: wrap; }
}
@media (max-width: 768px) {
  .nav { display: none; }
  .nav.open { display: flex; flex-direction: column; position: absolute; top: 100%; left: 0; right: 0; background: var(--md-sys-color-surface-container); padding: 0.75rem 1rem; border-bottom: 1px solid var(--md-sys-color-outline-variant); }
  .nav-actions { margin-left: 0; flex-direction: column; width: 100%; }
  .menu-toggle { display: inline-flex; }
}
