/* ============================================================
   Gestor de Pantallas
   Sistema de diseño: papel + tinta marino + oro de sello,
   heredado del panel de Audioguía Sync. Fraunces para títulos,
   IBM Plex Sans para texto, IBM Plex Mono para IDs/URLs.
   ============================================================ */

:root {
    --bg: #f2ede1;
    --bg-line: rgba(20, 22, 44, 0.035);
    --bg-glow: rgba(169, 119, 63, 0.08);
    --surface: #fffdf8;
    --surface-2: #ece7d9;
    --input-bg: #ffffff;
    --text: #14162c;
    --text-soft: #4b4e66;
    --text-mute: #7b7d92;
    --border: #ddd2b8;
    --gold: #a9773f;
    --gold-soft: #d4b373;
    --error: #8c2f24;
    --error-bg: #f6e6e1;
    --ok: #2f6d4f;
    --ok-bg: #e5efe6;
    --shadow-card: 0 1px 2px rgba(20, 22, 44, 0.06), 0 12px 32px -16px rgba(20, 22, 44, 0.25);
    --radius: 6px;
    --font-display: "Fraunces", Georgia, "Times New Roman", serif;
    --font-body: "IBM Plex Sans", Arial, Helvetica, sans-serif;
    --font-mono: "IBM Plex Mono", "Courier New", monospace;
    color-scheme: light;
}

:root[data-theme="dark"] {
    --bg: #121319;
    --bg-line: rgba(255, 255, 255, 0.035);
    --bg-glow: rgba(169, 119, 63, 0.1);
    --surface: #1c1d26;
    --surface-2: #23242f;
    --input-bg: #14151c;
    --text: #ede9de;
    --text-soft: #9a9cb0;
    --text-mute: #6c6e83;
    --border: #2c2d3a;
    --gold: #b98a4f;
    --gold-soft: #d9b787;
    --error: #e5897a;
    --error-bg: rgba(217, 112, 95, 0.14);
    --ok: #4fae7a;
    --ok-bg: rgba(79, 174, 122, 0.16);
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.35), 0 12px 32px -16px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    transition: background-color 160ms ease, color 160ms ease;
}

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

button {
    font-family: inherit;
}

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

.paper-bg {
    min-height: 100dvh;
    background-color: var(--bg);
    background-image:
        repeating-linear-gradient(to bottom, transparent, transparent 27px, var(--bg-line) 28px),
        radial-gradient(circle at 12% 8%, var(--bg-glow), transparent 42%);
}

.shell {
    max-width: 1080px;
    margin: 0 auto;
    padding: 48px 24px 80px;
}

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

.top-bar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 40px;
}

.eyebrow {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--gold);
    margin: 0 0 10px;
    position: relative;
    display: inline-block;
}

.eyebrow::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: -6px;
    height: 1px;
    width: 100%;
    background: var(--gold-soft);
}

.top-bar h1 {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 32px;
    margin: 0 0 6px;
    color: var(--text);
}

.top-bar p {
    margin: 0;
    color: var(--text-soft);
    font-size: 14px;
    max-width: 46ch;
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 8px 8px;
    cursor: pointer;
    box-shadow: var(--shadow-card);
    flex-shrink: 0;
}

.theme-toggle__knob {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--surface-2);
    color: var(--gold);
}

.theme-toggle__icon {
    width: 16px;
    height: 16px;
}

.theme-toggle__icon--moon { display: none; }
:root[data-theme="dark"] .theme-toggle__icon--sun { display: none; }
:root[data-theme="dark"] .theme-toggle__icon--moon { display: block; }

/* ------------------------------------------------------------
   Tarjeta de formulario
   ------------------------------------------------------------ */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: 28px;
}

.card + .card {
    margin-top: 28px;
}

.card h2 {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 600;
    margin: 0 0 18px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1.4fr;
    gap: 16px;
}

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

.field--full {
    grid-column: 1 / -1;
}

.field label {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.03em;
    color: var(--text-soft);
    text-transform: uppercase;
}

.field input,
.field textarea {
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 10px 12px;
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--text);
    transition: border-color 120ms ease;
}

.field input:focus,
.field textarea:focus {
    border-color: var(--gold);
}

.field textarea {
    resize: vertical;
    min-height: 42px;
    font-family: var(--font-mono);
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 20px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border-radius: 4px;
    padding: 10px 18px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.01em;
    border: 1px solid transparent;
    cursor: pointer;
    transition: transform 100ms ease, opacity 120ms ease;
}

.btn:active {
    transform: translateY(1px);
}

.btn-primary {
    background: var(--text);
    color: var(--surface);
}

.btn-primary:hover {
    opacity: 0.88;
}

.btn-ghost {
    background: transparent;
    border-color: var(--border);
    color: var(--text-soft);
}

.btn-ghost:hover {
    border-color: var(--gold);
    color: var(--gold);
}

.btn-danger {
    background: transparent;
    color: var(--error);
}

.btn-danger:hover {
    background: var(--error-bg);
}

.btn-sm {
    padding: 6px 10px;
    font-size: 12px;
}

.form-msg {
    font-size: 13px;
    margin-top: 14px;
    display: none;
    padding: 10px 12px;
    border-radius: 4px;
}

.form-msg.is-error {
    display: block;
    background: var(--error-bg);
    color: var(--error);
}

.form-msg.is-ok {
    display: block;
    background: var(--ok-bg);
    color: var(--ok);
}

/* ------------------------------------------------------------
   Listado de pantallas
   ------------------------------------------------------------ */

.list-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin: 40px 0 16px;
}

.list-header h2 {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 600;
    margin: 0;
}

.list-count {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-mute);
}

.screens-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.screen-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.screen-card__head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
}

.screen-card__name {
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 600;
    margin: 0;
    word-break: break-word;
}

.screen-card__id {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--gold);
    background: var(--surface-2);
    border-radius: 999px;
    padding: 3px 9px;
    white-space: nowrap;
}

.screen-card__url {
    font-family: var(--font-mono);
    font-size: 12.5px;
    color: var(--text-soft);
    word-break: break-all;
}

.screen-card__notes {
    font-size: 13px;
    color: var(--text-mute);
    font-style: italic;
}

.screen-card__actions {
    margin-top: auto;
    padding-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    border-top: 1px dashed var(--border);
}

.empty-state {
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px 20px;
    text-align: center;
    color: var(--text-mute);
    font-size: 14px;
}

/* ------------------------------------------------------------
   Modal de edición
   ------------------------------------------------------------ */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 18, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 50;
}

.modal-backdrop.is-open {
    display: flex;
}

.modal {
    width: 100%;
    max-width: 480px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: 26px;
}

.modal h2 {
    font-family: var(--font-display);
    font-size: 19px;
    margin: 0 0 16px;
}

@media (max-width: 640px) {
    .form-grid {
        grid-template-columns: 1fr;
    }

    .top-bar {
        flex-direction: column;
    }
}
