/* ===================================================================
   REVILA — estilos. Paleta corporativa extraída de revila.es
   =================================================================== */
:root {
    --bg:        #0a0a0f;
    --surface:   #1a1a2e;
    --surface-2: #21213a;
    --border:    rgba(255, 255, 255, 0.10);
    --text:      #ffffff;
    --muted:     rgba(255, 255, 255, 0.60);
    --accent:    #6366f1;
    --accent-2:  #8b5cf6;
    --accent-3:  #06b6d4;
    --gradient:  linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #06b6d4 100%);
    --ok:        #22c55e;
    --err:       #ef4444;
    --radius:    14px;
    --font:      "Inter", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-3); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Topbar ---- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 22px;
    border-bottom: 1px solid var(--border);
    background: rgba(10, 10, 15, 0.85);
    position: sticky;
    top: 0;
    backdrop-filter: blur(8px);
    z-index: 10;
}
.brand {
    font-weight: 800;
    font-size: 1.3rem;
    letter-spacing: -0.02em;
    background: var(--gradient);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.topnav { display: flex; align-items: center; gap: 16px; }
.topnav-user { color: var(--muted); font-size: 0.9rem; }

/* ---- Layout ---- */
.container { max-width: 760px; margin: 0 auto; padding: 28px 20px 60px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
h1 { font-size: 1.6rem; font-weight: 700; margin: 0 0 4px; }
h2 { font-size: 1.15rem; font-weight: 600; margin: 0 0 14px; }
.muted { color: var(--muted); font-size: 0.92rem; }
.gradient-text {
    background: var(--gradient);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* ---- Card ---- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    margin: 18px 0;
}

/* ---- Formularios ---- */
.form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span, legend { font-size: 0.92rem; font-weight: 500; }
input[type="text"], input[type="email"], input[type="password"],
input[type="file"], select, textarea {
    width: 100%;
    padding: 11px 13px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-family: inherit;
    font-size: 0.95rem;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
}
textarea { resize: vertical; }
fieldset { border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin: 0; }
legend { padding: 0 6px; }

.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; font-weight: 400; }
.check input { width: auto; }

.form-actions { display: flex; gap: 12px; justify-content: flex-end; flex-wrap: wrap; }

/* Campo de contraseña con botón "ojo" */
.pwd-wrap { position: relative; }
.pwd-wrap input { padding-right: 44px; }
.pwd-toggle {
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    width: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--muted);
    cursor: pointer;
    padding: 0;
}
.pwd-toggle:hover { color: var(--text); }
.pwd-toggle svg { width: 20px; height: 20px; }
.pwd-toggle .icon-hide { display: none; }
.pwd-wrap.is-shown .pwd-toggle .icon-show { display: none; }
.pwd-wrap.is-shown .pwd-toggle .icon-hide { display: inline; }

.hint { color: var(--muted); font-size: 0.82rem; }
.estado-acciones { display: flex; align-items: center; gap: 10px; }

/* Recuadro de ayuda del formulario de cliente */
.ayuda { border-left: 3px solid var(--accent-2); }
.ayuda h2 { font-size: 1.05rem; margin-bottom: 10px; }
.ayuda-lista { margin: 0; padding-left: 18px; }
.ayuda-lista li { margin-bottom: 8px; font-size: 0.92rem; }
.ayuda-lista li:last-child { margin-bottom: 0; }
.ayuda-lista strong { color: #fff; }
/* Pista a ancho completo bajo la fila del formulario (no descuadra las celdas) */
.hint-row { grid-column: 1 / -1; margin-top: -4px; }

/* ---- Botones ---- */
.btn {
    display: inline-block;
    padding: 11px 20px;
    border: none;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: filter 0.15s, transform 0.1s;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--gradient); color: #fff; }
.btn-primary:hover { filter: brightness(1.1); text-decoration: none; }
.btn-ghost {
    display: inline-block;
    padding: 9px 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: transparent;
    color: var(--text);
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
}
.btn-ghost:hover { background: var(--surface-2); text-decoration: none; }
.btn-del {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--err);
    border-radius: 8px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 0.85rem;
}
.btn-del:hover { background: rgba(239, 68, 68, 0.12); }

/* ---- Auth ---- */
.auth-wrap { min-height: 60vh; display: flex; align-items: center; justify-content: center; }
.auth-card { width: 100%; max-width: 380px; }

/* ---- Badges ---- */
.badge {
    display: inline-block;
    padding: 4px 11px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
}
.badge-ok    { background: rgba(34, 197, 94, 0.18);  color: #4ade80; }
.badge-draft { background: rgba(139, 92, 246, 0.18); color: #c4b5fd; }
.badge-none  { background: rgba(255, 255, 255, 0.10); color: var(--muted); }

/* ---- Flash ---- */
.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-size: 0.92rem; }
.flash-ok    { background: rgba(34, 197, 94, 0.15);  border: 1px solid rgba(34, 197, 94, 0.4); }
.flash-error { background: rgba(239, 68, 68, 0.15); border: 1px solid rgba(239, 68, 68, 0.4); }

/* ---- Tabla ---- */
.table-wrap { overflow-x: auto; }
.tabla { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.tabla th, .tabla td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--border); }
.tabla th { color: var(--muted); font-weight: 600; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.04em; }
.acciones { display: flex; gap: 8px; align-items: center; }

/* ---- Listado de ficheros ---- */
.file-list { list-style: none; padding: 0; margin: 14px 0 0; }
.file-list li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.upload-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.inline { display: inline; margin: 0; }

/* ---- Inline create form ---- */
.form-inline { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 12px; align-items: end; }

/* ---- Definición (detalle) ---- */
.datos { display: grid; grid-template-columns: 200px 1fr; gap: 10px 18px; margin: 0; }
.datos dt { color: var(--muted); font-size: 0.9rem; }
.datos dd { margin: 0; }

/* ---- Pie ---- */
.pie { display: flex; align-items: center; justify-content: center; gap: 12px; color: var(--muted); font-size: 0.82rem; padding: 24px; border-top: 1px solid var(--border); }
.ver-badge { background: transparent; border: 1px solid var(--border); color: var(--muted); border-radius: 999px; padding: 2px 10px; font-size: 0.78rem; font-family: inherit; }
button.ver-badge { cursor: pointer; }
button.ver-badge:hover { color: var(--text); border-color: var(--accent); }

/* Chip de versión en la barra superior (admin): visible y clicable */
.ver-chip {
    font-family: inherit; font-size: 0.78rem; font-weight: 600;
    color: #fff;
    background: rgba(99, 102, 241, 0.16);
    border: 1px solid rgba(139, 92, 246, 0.55);
    border-radius: 999px; padding: 3px 11px;
    cursor: pointer; line-height: 1;
}
.ver-chip:hover { background: rgba(99, 102, 241, 0.28); border-color: var(--accent); }

/* ---- Modal ---- */
.modal { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; z-index: 1000; }
.modal.open { display: flex; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.6); }
.modal-box { position: relative; width: 92%; max-width: 520px; max-height: 80vh; overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
.modal-head h3 { margin: 0; font-size: 1.1rem; }
.modal-x { background: transparent; border: none; color: var(--muted); font-size: 1.6rem; line-height: 1; cursor: pointer; padding: 0 4px; }
.modal-x:hover { color: var(--text); }
.modal-body { padding: 16px 20px; }
.rel { margin-bottom: 18px; }
.rel:last-child { margin-bottom: 0; }
.rel-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.rel ul { margin: 0; padding-left: 18px; }
.rel li { margin-bottom: 4px; font-size: 0.92rem; }

/* Contenido de la ayuda del admin */
.ayuda-doc > p:first-child {
    font-size: 0.95rem;
    color: var(--text);
    background: rgba(99, 102, 241, 0.10);
    border-left: 3px solid var(--accent);
    border-radius: 8px;
    padding: 10px 14px;
    margin: 0 0 6px;
}
.ayuda-doc h4 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 20px 0 6px;
    padding-bottom: 6px;
    font-size: 0.98rem;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid var(--border);
}
.ayuda-doc h4:first-of-type { margin-top: 8px; }
/* Numerito de cada sección: detecta el "N." al inicio del título */
.ayuda-doc h4::before {
    content: counter(ayuda-sec);
    counter-increment: ayuda-sec;
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 800;
    color: #fff;
    background: var(--gradient);
    border-radius: 6px;
}
.ayuda-doc { counter-reset: ayuda-sec; }
.ayuda-doc p { font-size: 0.9rem; margin: 4px 0; color: var(--muted); }
.ayuda-doc ul { margin: 6px 0; padding-left: 4px; list-style: none; }
.ayuda-doc li {
    position: relative;
    font-size: 0.9rem;
    margin-bottom: 6px;
    padding-left: 18px;
    color: var(--muted);
}
.ayuda-doc li::before {
    content: "";
    position: absolute;
    left: 2px;
    top: 0.55em;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-2);
}
.ayuda-doc strong { color: #fff; font-weight: 600; }
/* Etiquetas de estado, con el mismo color que los badges de la tabla */
.ayuda-doc .est {
    display: inline-block;
    font-weight: 600;
    font-size: 0.82rem;
    padding: 1px 9px;
    border-radius: 999px;
}
.ayuda-doc .est-none  { background: rgba(255, 255, 255, 0.10); color: var(--muted); }
.ayuda-doc .est-draft { background: rgba(139, 92, 246, 0.18); color: #c4b5fd; }
.ayuda-doc .est-ok    { background: rgba(34, 197, 94, 0.18);  color: #4ade80; }
/* Nota de cierre */
.ayuda-doc p.muted {
    margin-top: 18px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    font-style: italic;
}

/* ---- Responsive ---- */
@media (max-width: 640px) {
    .checks { grid-template-columns: 1fr; }
    .form-inline { grid-template-columns: 1fr; }
    .datos { grid-template-columns: 1fr; gap: 2px 0; }
    .datos dd { margin-bottom: 10px; }
}
