/* ActaMD — hoja de estilos. Dirección visual SPEC §5:
   sobria, densa, líneas de 1 px, sin degradados ni sombras difusas. */

/* --- Tipografías locales (public_html/assets/fonts, sin CDN) ---------- */

@font-face {
    font-family: "Space Grotesk";
    src: url("/assets/fonts/space-grotesk-500.woff2") format("woff2");
    font-weight: 500;
    font-display: swap;
}

@font-face {
    font-family: "Space Grotesk";
    src: url("/assets/fonts/space-grotesk-600.woff2") format("woff2");
    font-weight: 600;
    font-display: swap;
}

@font-face {
    font-family: "Space Grotesk";
    src: url("/assets/fonts/space-grotesk-700.woff2") format("woff2");
    font-weight: 700;
    font-display: swap;
}

@font-face {
    font-family: "Inter";
    src: url("/assets/fonts/inter-400.woff2") format("woff2");
    font-weight: 400;
    font-display: swap;
}

@font-face {
    font-family: "Inter";
    src: url("/assets/fonts/inter-500.woff2") format("woff2");
    font-weight: 500;
    font-display: swap;
}

@font-face {
    font-family: "JetBrains Mono";
    src: url("/assets/fonts/jetbrains-mono-400.woff2") format("woff2");
    font-weight: 400;
    font-display: swap;
}

@font-face {
    font-family: "JetBrains Mono";
    src: url("/assets/fonts/jetbrains-mono-500.woff2") format("woff2");
    font-weight: 500;
    font-display: swap;
}

/* --- Paleta (SPEC §5.2) ------------------------------------------------ */

:root {
    --paper: #F6F8F9;
    --surface: #FFFFFF;
    --surface-2: #F0F4F5;
    --ink: #10161A;
    --ink-soft: #5A676E;
    --rule: #DDE4E7;
    --accent: #0E6F73;
    --accent-soft: #D5EBEA;
    --signal: #B4541B;
    --ok: #2E7D4F;

    --font-ui: "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-text: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --paper: #10161A;
        --surface: #171F25;
        --surface-2: #1D262D;
        --ink: #E8EDEF;
        --ink-soft: #94A3AA;
        --rule: #26313A;
        --accent: #3FB6B2;
        --accent-soft: #123234;
        --signal: #E08A5B;
        --ok: #57B37E;
    }
}

:root[data-theme="dark"] {
    --paper: #10161A;
    --surface: #171F25;
    --surface-2: #1D262D;
    --ink: #E8EDEF;
    --ink-soft: #94A3AA;
    --rule: #26313A;
    --accent: #3FB6B2;
    --accent-soft: #123234;
    --signal: #E08A5B;
    --ok: #57B37E;
}

/* --- Base --------------------------------------------------------------- */

* {
    box-sizing: border-box;
}

html {
    color-scheme: light dark;
}

:root[data-theme="light"] {
    color-scheme: light;
}

:root[data-theme="dark"] {
    color-scheme: dark;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--paper);
    color: var(--ink);
    font: 400 15px/1.5 var(--font-text);
}

h1, h2, h3 {
    font-family: var(--font-ui);
    line-height: 1.2;
    margin: 0;
}

h1 { font-size: 32px; font-weight: 700; }
h2 { font-size: 24px; font-weight: 600; }
h3 { font-size: 18px; font-weight: 600; }

p { margin: 0; }

a { color: var(--accent); }

.mono { font-family: var(--font-mono); font-size: 13px; }
.muted { color: var(--ink-soft); font-size: 13px; }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}

/* --- Cabecera ------------------------------------------------------------ */

.topbar {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 12px 24px;
    border-bottom: 1px solid var(--rule);
    background: var(--surface);
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font: 600 18px/1 var(--font-ui);
    color: var(--ink);
    text-decoration: none;
}

.brand-mark {
    width: 18px;
    height: 22px;
    stroke-width: 1.5;
    color: var(--accent);
}

.topnav {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-left: auto;
    font-size: 13px;
}

.topnav a {
    color: var(--ink-soft);
    text-decoration: none;
}

.topnav a:hover { color: var(--ink); }

.inline-form { display: inline; }

.link-button {
    background: none;
    border: none;
    padding: 0;
    color: var(--ink-soft);
    font: inherit;
    cursor: pointer;
}

.link-button:hover { color: var(--ink); }

.theme-switch {
    display: flex;
    border: 1px solid var(--rule);
    border-radius: 4px;
    overflow: hidden;
}

.theme-switch button {
    background: var(--surface);
    color: var(--ink-soft);
    border: none;
    padding: 5px 10px;
    font: 500 11px/1 var(--font-ui);
    cursor: pointer;
}

.theme-switch button + button { border-left: 1px solid var(--rule); }

.theme-switch button[aria-pressed="true"] {
    background: var(--accent-soft);
    color: var(--accent);
}

/* --- Pie ----------------------------------------------------------------- */

.footer {
    margin-top: auto;
    padding: 16px 24px;
    border-top: 1px solid var(--rule);
    color: var(--ink-soft);
    font-size: 11px;
}

/* --- Botones y formularios ------------------------------------------------ */

button, .button-link {
    display: inline-block;
    padding: 9px 16px;
    border: 1px solid var(--accent);
    border-radius: 4px;
    background: var(--accent);
    color: var(--paper);
    font: 500 14px/1.2 var(--font-ui);
    cursor: pointer;
    text-align: center;
    text-decoration: none;
}

button.secondary {
    background: transparent;
    color: var(--accent);
}

.quiet-link {
    padding: 9px 4px;
    font: 500 14px/1.2 var(--font-ui);
}

label {
    font-size: 13px;
    color: var(--ink-soft);
}

input[type="email"],
input[type="password"],
input[type="text"],
select {
    padding: 9px 12px;
    border: 1px solid var(--rule);
    border-radius: 4px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    width: 100%;
}

.alert {
    padding: 10px 14px;
    border: 1px solid var(--rule);
    border-radius: 4px;
    font-size: 14px;
    background: var(--surface);
}

.alert ul { margin: 0; padding-left: 18px; }
.alert-error { border-color: var(--signal); color: var(--signal); }
.alert-ok { border-color: var(--ok); color: var(--ok); }

/* --- Portada --------------------------------------------------------------- */

.hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 380px);
    gap: 48px;
    align-items: center;
    max-width: 960px;
    margin: 0 auto;
    padding: 64px 24px;
    width: 100%;
}

.hero-text {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.hero-text p { color: var(--ink-soft); max-width: 46ch; }

.hero-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 8px;
}

.format-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    list-style: none;
    margin: 16px 0 0;
    padding: 0;
}

.format-list li {
    font: 500 11px/1 var(--font-mono);
    color: var(--ink-soft);
    border: 1px solid var(--rule);
    border-radius: 3px;
    padding: 4px 7px;
    background: var(--surface);
}

/* --- La hoja (elemento distintivo) ------------------------------------------ */

.sheet {
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
    max-width: 300px;
    padding: 28px 24px;
    border: 1px solid var(--rule);
    border-radius: 3px;
    background: var(--surface);
    position: relative;
}

.sheet::after {
    content: "";
    position: absolute;
    top: 0;
    right: 16px;
    height: 100%;
    border-right: 1px solid var(--accent-soft);
}

.sheet-line {
    display: block;
    height: 1px;
    background: var(--rule);
    font: 500 13px/0 var(--font-mono);
    color: transparent;
    transition: color 240ms, background 240ms;
}

.sheet-line.short { width: 60%; }

.sheet-line.md {
    color: var(--accent);
    background: transparent;
    height: auto;
    line-height: 1;
}

/* --- Conversor ----------------------------------------------------------------- */

.converter {
    width: 100%;
    max-width: 860px;
    margin: 0 auto;
    padding: 40px 24px 64px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.page-title { font-size: 24px; }

.dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 32px 24px;
    border: 1px dashed var(--rule);
    border-radius: 4px;
    background: var(--surface);
    cursor: pointer;
    text-align: center;
}

.dropzone .sheet {
    max-width: 190px;
    padding: 18px 16px;
    gap: 10px;
    pointer-events: none;
}

.sheet-symbols {
    display: flex;
    gap: 10px;
    justify-content: center;
    font: 500 13px/1 var(--font-mono);
    color: var(--rule);
    transition: color 240ms;
}

.sheet-symbols span {
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 240ms, transform 240ms;
}

.dropzone.dragging {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.dropzone.dragging .sheet-line {
    background: var(--accent);
}

.dropzone.dragging .sheet-symbols { color: var(--accent); }

.dropzone.dragging .sheet-symbols span {
    opacity: 1;
    transform: translateY(0);
}

.dropzone.dragging .sheet-symbols span:nth-child(2) { transition-delay: 60ms; }
.dropzone.dragging .sheet-symbols span:nth-child(3) { transition-delay: 120ms; }
.dropzone.dragging .sheet-symbols span:nth-child(4) { transition-delay: 180ms; }
.dropzone.dragging .sheet-symbols span:nth-child(5) { transition-delay: 240ms; }

@media (prefers-reduced-motion: reduce) {
    .dropzone.dragging .sheet-symbols span { transition-delay: 0ms; }
}

.dropzone-text { display: flex; flex-direction: column; gap: 4px; }
.dropzone-text strong { font-family: var(--font-ui); font-size: 15px; }

#file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.options {
    border: 1px solid var(--rule);
    border-radius: 4px;
    background: var(--surface);
}

.options summary {
    padding: 10px 14px;
    font: 500 13px/1 var(--font-ui);
    color: var(--ink-soft);
    cursor: pointer;
}

.options-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 16px 32px;
    padding: 4px 14px 14px;
    border-top: 1px solid var(--rule);
    align-items: center;
}

.options-grid .check {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--ink);
    font-size: 13px;
}

.options-grid .select {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.options-grid select { width: auto; }

.keep-notice {
    font-size: 13px;
    color: var(--ink-soft);
    border-left: 2px solid var(--accent);
    padding-left: 12px;
}

/* --- Cola ------------------------------------------------------------------------- */

.queue {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.queue:empty { display: none; }

.queue-item {
    display: flex;
    align-items: baseline;
    gap: 12px;
    padding: 10px 2px;
    border-bottom: 1px solid var(--rule);
    font-size: 13px;
}

.queue-name {
    font-family: var(--font-mono);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.queue-size { color: var(--ink-soft); }

.queue-status { margin-left: auto; color: var(--ink-soft); white-space: nowrap; }

.queue-item { flex-wrap: wrap; }

.ocr-offer {
    flex-basis: 100%;
    margin-top: 6px;
    align-self: flex-start;
    flex-basis: auto;
}

.queue-item[data-state="ok"] .queue-status { color: var(--ok); }
.queue-item[data-state="error"] .queue-status { color: var(--signal); }

/* --- Resultados --------------------------------------------------------------------- */

.result-card {
    border: 1px solid var(--rule);
    border-radius: 4px;
    background: var(--surface);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.result-head h2 {
    font-size: 15px;
    font-family: var(--font-mono);
    font-weight: 500;
}

.tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--rule);
}

.tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    color: var(--ink-soft);
    padding: 6px 12px;
    font: 500 13px/1.2 var(--font-ui);
    cursor: pointer;
}

.tab[aria-selected="true"] {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.result-pre {
    margin: 0;
    padding: 14px;
    background: var(--surface-2);
    border: 1px solid var(--rule);
    border-radius: 4px;
    overflow-x: auto;
    max-height: 420px;
    font: 400 13px/1.5 var(--font-mono);
}

.result-rendered {
    padding: 4px 8px;
    max-height: 420px;
    overflow: auto;
    font-size: 14px;
    line-height: 1.5;
}

.result-rendered h1 { font-size: 20px; margin: 12px 0 6px; }
.result-rendered h2 { font-size: 17px; margin: 12px 0 6px; }
.result-rendered h3 { font-size: 15px; margin: 10px 0 4px; }
.result-rendered p { margin: 6px 0; }
.result-rendered blockquote {
    margin: 8px 0;
    padding-left: 12px;
    border-left: 2px solid var(--rule);
    color: var(--ink-soft);
}
.result-rendered code { font-family: var(--font-mono); font-size: 12px; background: var(--surface-2); padding: 1px 4px; border-radius: 3px; }
.result-rendered pre { background: var(--surface-2); padding: 10px; border-radius: 4px; overflow-x: auto; }

.table-scroll { overflow-x: auto; }

.result-rendered table {
    border-collapse: collapse;
    font-size: 13px;
    margin: 8px 0;
}

.result-rendered th,
.result-rendered td {
    border: 1px solid var(--rule);
    padding: 4px 8px;
    text-align: left;
}

.result-rendered th { background: var(--surface-2); font-family: var(--font-ui); }

.result-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.action {
    padding: 6px 12px;
    font-size: 13px;
    background: transparent;
    color: var(--accent);
}

.action.danger {
    color: var(--signal);
    border-color: var(--signal);
}

/* --- Páginas de acceso --------------------------------------------------------------- */

main.auth {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    padding: 48px 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

main.auth form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

main.auth label { margin-top: 8px; }

main.auth h2 { font-size: 18px; margin-top: 16px; }

main.center {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 24px;
    text-align: center;
}

main.center p { color: var(--ink-soft); }

/* --- Panel de administración -------------------------------------------------------- */

main.admin {
    width: 100%;
    max-width: 1040px;
    margin: 0 auto;
    padding: 32px 24px 64px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.admin-nav {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--rule);
}

.admin-nav a {
    padding: 8px 14px;
    font: 500 13px/1.2 var(--font-ui);
    color: var(--ink-soft);
    text-decoration: none;
    border-bottom: 2px solid transparent;
}

.admin-nav a[aria-current="page"] {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}

.stat-card {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 12px 14px;
    border: 1px solid var(--rule);
    border-radius: 4px;
    background: var(--surface);
}

.stat-value { font-size: 24px; font-weight: 500; }
.stat-label { font-size: 11px; color: var(--ink-soft); }

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.filter-bar input[type="text"] { max-width: 260px; }
.filter-bar select { width: auto; }
.filter-bar button { padding: 9px 14px; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--rule);
    font-size: 13px;
}

.data-table caption {
    text-align: left;
    font: 600 13px/1.2 var(--font-ui);
    padding: 8px 0;
    color: var(--ink-soft);
}

.data-table th,
.data-table td {
    border-bottom: 1px solid var(--rule);
    padding: 8px 10px;
    text-align: left;
    vertical-align: top;
}

.data-table thead th {
    font: 500 11px/1.2 var(--font-ui);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ink-soft);
    background: var(--surface-2);
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    border: 1px solid var(--rule);
    font: 500 11px/1.4 var(--font-ui);
}

.badge-active { border-color: var(--ok); color: var(--ok); }
.badge-pending { border-color: var(--signal); color: var(--signal); }
.badge-suspended { border-color: var(--signal); color: var(--signal); background: var(--surface-2); }
.badge-accent { border-color: var(--accent); color: var(--accent); }

.row-actions summary {
    cursor: pointer;
    color: var(--accent);
    font: 500 13px/1.2 var(--font-ui);
}

.row-actions-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    margin-top: 6px;
    border: 1px solid var(--rule);
    border-radius: 4px;
    background: var(--surface-2);
    min-width: 240px;
}

.row-actions-panel form { display: flex; gap: 6px; }
.row-actions-panel form.stack { flex-direction: column; }
.row-actions-panel button { padding: 6px 10px; font-size: 12px; }
.row-actions-panel input[type="text"] { padding: 6px 8px; font-size: 12px; }

.danger-button {
    background: transparent;
    border-color: var(--signal);
    color: var(--signal);
}

.pagination {
    display: flex;
    gap: 16px;
    align-items: baseline;
    font-size: 13px;
}

.settings-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 640px;
}

.settings-form h2 { font-size: 15px; margin-top: 12px; }

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
}

.field { display: flex; flex-direction: column; gap: 4px; }

.check { display: flex; align-items: center; gap: 8px; color: var(--ink); }

.extension-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 8px;
}

.settings-form > button { align-self: flex-start; margin-top: 8px; }

.stats-tables {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    padding: 14px;
    border-top: 1px solid var(--rule);
}

.mail-test { display: flex; flex-direction: column; gap: 8px; }
.mail-test form { display: block; }

/* --- Manuales --------------------------------------------------------------- */

main.manual {
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
    padding: 40px 24px 64px;
    font-size: 15px;
    line-height: 1.6;
}

main.manual h1 { font-size: 28px; margin: 0 0 8px; }
main.manual h2 { font-size: 20px; margin: 28px 0 8px; }
main.manual h3 { font-size: 16px; margin: 20px 0 6px; }
main.manual p { margin: 8px 0; }
main.manual ul, main.manual ol { margin: 8px 0; padding-left: 22px; }
main.manual li { margin: 4px 0; }
main.manual hr { border: none; border-top: 1px solid var(--rule); margin: 24px 0; }

main.manual blockquote {
    margin: 12px 0;
    padding-left: 14px;
    border-left: 2px solid var(--accent);
    color: var(--ink-soft);
}

main.manual code {
    font-family: var(--font-mono);
    font-size: 13px;
    background: var(--surface-2);
    padding: 1px 5px;
    border-radius: 3px;
}

main.manual pre {
    background: var(--surface-2);
    border: 1px solid var(--rule);
    border-radius: 4px;
    padding: 12px;
    overflow-x: auto;
}

main.manual pre code { background: none; padding: 0; }

main.manual table {
    border-collapse: collapse;
    font-size: 14px;
    margin: 12px 0;
    background: var(--surface);
}

main.manual th,
main.manual td {
    border: 1px solid var(--rule);
    padding: 6px 10px;
    text-align: left;
    vertical-align: top;
}

main.manual th { background: var(--surface-2); font-family: var(--font-ui); }

/* --- Cuenta ---------------------------------------------------------------- */

main.account { max-width: 720px; }

.account-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px 0;
    border-top: 1px solid var(--rule);
}

.account-section h2 { font-size: 16px; }

.account-form {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-width: 360px;
}

.account-form button { align-self: flex-start; margin-top: 8px; }

.account-theme { align-self: flex-start; }

.danger-zone h2 { color: var(--signal); }

/* --- Responsive (cortes 600 y 1024 px, SPEC §5.6) --------------------------------------- */

@media (max-width: 1024px) {
    .hero { gap: 32px; padding: 48px 24px; }
}

@media (max-width: 600px) {
    h1 { font-size: 24px; }

    .topbar {
        flex-wrap: wrap;
        gap: 12px;
        padding: 10px 16px;
    }

    .topnav { gap: 12px; }

    .hero {
        grid-template-columns: 1fr;
        padding: 32px 16px;
    }

    .hero-sheet { display: none; }

    .converter { padding: 24px 16px 96px; }

    .dropzone .sheet { display: none; }

    .result-actions {
        position: sticky;
        bottom: 0;
        background: var(--surface);
        padding: 10px 0;
        border-top: 1px solid var(--rule);
    }

    .result-actions .action { min-height: 44px; min-width: 44px; flex: 1; }

    button, .button-link { min-height: 44px; }

    .theme-switch button { padding: 10px 12px; }

    /* tablas del panel convertidas en tarjetas */
    .users-table thead,
    main.admin .data-table thead { display: none; }

    .users-table tbody tr,
    main.admin .data-table tbody tr {
        display: block;
        border: 1px solid var(--rule);
        border-radius: 4px;
        margin-bottom: 10px;
        padding: 8px 10px;
        background: var(--surface);
    }

    .users-table tbody td,
    main.admin .data-table tbody td {
        display: flex;
        gap: 8px;
        border: none;
        padding: 3px 0;
    }

    main.admin .data-table tbody td[data-label]::before {
        content: attr(data-label) ": ";
        color: var(--ink-soft);
        font: 500 11px/1.6 var(--font-ui);
        min-width: 92px;
    }

    main.admin .data-table tbody th[scope="row"] {
        display: block;
        border: none;
        padding: 3px 0 0;
    }

    .stats-tables { grid-template-columns: 1fr; }
}
