/* =====================================================================
   styles.css — Kietol Covers (covers.kietol.com)
   Copia independiente del estilo de Kietol Licencias (no la enlaza),
   con solo las piezas que usa este sitio + ajustes propios al final.
   Fuente: Rajdhani (cargar en <head>):
   <link rel="preconnect" href="https://fonts.googleapis.com">
   <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
   <link href="https://fonts.googleapis.com/css2?family=Rajdhani:wght@500;600;700&display=swap" rel="stylesheet">
   ===================================================================== */

:root {
    --bg:          #f4efe9;
    --surface:     #ffffff;
    --surface-2:   #faf7f3;
    --ink:         #1f1a17;
    --ink-2:       #574d45;
    --muted:       #8a7f76;
    --line:        #e6ddd3;

    --accent:      #f07415;
    --accent-hi:   #ff9440;
    --accent-deep: #b4540b;
    --accent-soft: #fdebdc;

    --dark:        #1c1917;
    --dark-2:      #2e2622;

    --ok:     #2e9d57;
    --danger: #d64036;
    --warn:   #e8920f;
    --info:   #2f74c0;
    --violet: #7a4fc4;
    --slate:  #3a332e;

    --edge-top: #fffdfb;
    --edge-bot: #cdbfb1;
    --radius:    14px;
    --radius-sm: 10px;
    --shadow: 0 1px 2px rgba(40,25,10,.06), 0 8px 24px rgba(40,25,10,.09);

    --font: "Rajdhani", "Segoe UI", "Noto Sans TC", sans-serif;
    --mono: ui-monospace, "Cascadia Mono", Consolas, "SF Mono", monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
    margin: 0;
    padding: 20px;
    background: var(--bg);
    color: var(--ink);
    font: 500 16px/1.45 var(--font);
    font-variant-numeric: tabular-nums;
}

h1, h2, h3 { margin: 0 0 14px; font-weight: 700; letter-spacing: .01em; }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.3rem; }
a  { color: var(--accent-deep); }
code { font-family: var(--mono); font-size: .88em; }
label { font-weight: 600; font-size: .92rem; color: var(--ink-2); }
.muted { color: var(--muted); }

/* ---------------------------------------------------------------------
   Superficies con relieve
   --------------------------------------------------------------------- */
.card,
.container,
.login-box,
.tile {
    background:
        linear-gradient(var(--surface), var(--surface)) padding-box,
        linear-gradient(180deg, var(--edge-top) 0%, var(--edge-bot) 100%) border-box;
    border: 1px solid transparent;
    border-radius: var(--radius);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.9), var(--shadow);
}
.card      { padding: 22px; margin-bottom: 20px; }
.container { max-width: 900px; margin: 0 auto; padding: 22px; }

/* ---------------------------------------------------------------------
   Barra superior
   --------------------------------------------------------------------- */
.navbar {
    display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px;
    padding: 14px 20px; margin-bottom: 20px; color: #fff;
    background:
        linear-gradient(180deg, var(--dark-2), var(--dark)) padding-box,
        linear-gradient(180deg, #5a4c43, #0c0a09) border-box;
    border: 1px solid transparent;
    border-radius: var(--radius);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 6px 18px rgba(20,12,6,.25);
}
.navbar h2 { margin: 0; font-size: 1.45rem; }
.navbar h2 span { color: var(--accent); }

.nav-links { display: flex; flex-wrap: wrap; gap: 6px; }
.nav-links a {
    color: #e9e1da; text-decoration: none; font-weight: 600;
    padding: 6px 14px; border-radius: 999px; border: 1px solid transparent;
    transition: background .15s, color .15s;
}
.nav-links a:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-links a.current {
    color: #fff;
    background: linear-gradient(180deg, var(--accent-hi), var(--accent)) padding-box,
                linear-gradient(180deg, #ffc08a, var(--accent-deep)) border-box;
    box-shadow: 0 2px 6px rgba(240,116,21,.35);
}
.nav-links a.logout { color: #ffb3ad; }
.nav-links a.logout:hover { background: rgba(214,64,54,.18); }

/* ---------------------------------------------------------------------
   Formularios
   --------------------------------------------------------------------- */
input, select, textarea, button { font: inherit; }

input[type=text], input[type=email], input[type=password], input[type=search], select, textarea {
    padding: 8px 12px; margin: 5px 0;
    color: var(--ink);
    background: linear-gradient(180deg, #f6f1eb, #ffffff);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    box-shadow: inset 0 1px 2px rgba(40,25,10,.08);
    transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: inset 0 1px 2px rgba(40,25,10,.08), 0 0 0 3px rgba(240,116,21,.18);
}

/* ---------------------------------------------------------------------
   Botones 3D
   --------------------------------------------------------------------- */
button.primary, .btn-primary, button.cancel, .btn-secondary, .btn-chg {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 18px; margin: 5px 0;
    font-weight: 700; letter-spacing: .04em; color: #fff;
    border: 1px solid transparent; border-radius: var(--radius-sm);
    cursor: pointer; text-decoration: none;
    transition: transform .08s, filter .15s;
}
button.primary, .btn-primary {
    background: linear-gradient(180deg, var(--accent-hi), #e5680c) padding-box,
                linear-gradient(180deg, #ffc08a, var(--accent-deep)) border-box;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.3), 0 2px 6px rgba(180,84,11,.35);
}
button.cancel, .btn-secondary {
    background: linear-gradient(180deg, #8a7f76, #6a6058) padding-box,
                linear-gradient(180deg, #b9aea4, #4a423c) border-box;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 2px 5px rgba(40,25,10,.2);
}
.btn-chg {
    padding: 6px 12px; font-size: .85rem;
    background: linear-gradient(180deg, #4b8fd6, var(--info)) padding-box,
                linear-gradient(180deg, #a3c8ee, #1f5390) border-box;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.3), 0 2px 5px rgba(31,83,144,.3);
}
button.primary:hover, .btn-primary:hover, button.cancel:hover, .btn-secondary:hover, .btn-chg:hover { filter: brightness(1.06); }
button:active, .btn-chg:active { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: not-allowed; filter: none; }

/* ---------------------------------------------------------------------
   Login
   --------------------------------------------------------------------- */
body.login-page {
    display: flex; justify-content: center; align-items: center;
    min-height: 100vh; padding: 16px;
    background: radial-gradient(1200px 600px at 50% -10%, #3a2f29, var(--dark) 60%);
}
.login-box { width: 100%; max-width: 340px; padding: 36px 30px; text-align: center; }
.login-box h2 { color: var(--ink); }
.login-box h2 span { color: var(--accent); }
.login-box input { width: 100%; }
.login-box button { width: 100%; margin-top: 10px; padding: 11px; }
.error { display: block; color: var(--danger); font-weight: 600; font-size: .92rem; margin-bottom: 10px; }

/* ---------------------------------------------------------------------
   Mensajes
   --------------------------------------------------------------------- */
.msg {
    padding: 10px 14px; margin-bottom: 16px; border-radius: var(--radius-sm);
    font-weight: 600; border: 1px solid;
}
.msg.ok    { background: #e9f6ee; border-color: #bfe3cc; color: #1d6b3b; }
.msg.error { background: #fdecea; border-color: #f4c3be; color: #9b2b23; }
.msg.info  { background: var(--surface-2); border-color: var(--line); color: var(--ink-2); }

/* ---------------------------------------------------------------------
   Tablas
   --------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .95rem; }
th {
    padding: 10px 12px; text-align: left; color: #fff; font-weight: 700; letter-spacing: .03em;
    background: linear-gradient(180deg, var(--dark-2), var(--dark));
}
th:first-child { border-top-left-radius: var(--radius-sm); }
th:last-child  { border-top-right-radius: var(--radius-sm); }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:hover td { background: var(--surface-2); }

/* ---------------------------------------------------------------------
   Badges
   --------------------------------------------------------------------- */
.badge {
    --c: var(--slate);
    display: inline-block; margin-bottom: 4px; padding: 2px 10px;
    font-size: .78rem; font-weight: 700; letter-spacing: .05em; color: #fff;
    border-radius: 999px;
    background: linear-gradient(180deg, color-mix(in srgb, var(--c) 78%, #fff), var(--c));
    box-shadow: inset 0 1px 0 rgba(255,255,255,.3), 0 1px 2px rgba(0,0,0,.15);
}
.badge.active { --c: var(--ok); }
.badge.banned { --c: var(--danger); }

/* ---------------------------------------------------------------------
   Toast
   --------------------------------------------------------------------- */
.toast {
    position: fixed; left: 50%; bottom: 28px; z-index: 1000;
    transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
    padding: 10px 22px; border-radius: 999px;
    font-weight: 700; letter-spacing: .03em; color: #fff;
    background: linear-gradient(180deg, var(--accent-hi), #e5680c) padding-box,
                linear-gradient(180deg, #ffc08a, var(--accent-deep)) border-box;
    border: 1px solid transparent;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 8px 22px rgba(180,84,11,.4);
    transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err {
    background: linear-gradient(180deg, #e9665d, var(--danger)) padding-box,
                linear-gradient(180deg, #f6aaa4, #8f241d) border-box;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.3), 0 8px 22px rgba(143,36,29,.35);
}

/* ---------------------------------------------------------------------
   Rejilla de portadas
   --------------------------------------------------------------------- */
.vault-grid {
    display: grid; gap: 18px;
    grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
}
.tile { overflow: hidden; transition: transform .15s, box-shadow .15s; }
.tile:hover {
    transform: translateY(-3px);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.9), 0 2px 4px rgba(40,25,10,.08), 0 14px 30px rgba(40,25,10,.14);
}
.tile.selected { box-shadow: 0 0 0 3px rgba(240,116,21,.45), var(--shadow); }

.cover {
    position: relative; aspect-ratio: 3 / 4; margin: 6px 6px 0;
    border-radius: 10px; overflow: hidden;
    background: var(--surface-2);
    box-shadow: inset 0 0 0 1px rgba(0,0,0,.06);
}
/* Covers: contain (no recortar) — muchas portadas son caja abierta, CD o formatos anchos */
.cover img { width: 100%; height: 100%; object-fit: contain; display: block; }
.tile-body { padding: 10px 12px 12px; }
.tile-name { font-weight: 700; font-size: 1.05rem; line-height: 1.2; margin-bottom: 2px; overflow-wrap: anywhere; }
.tile-type { font-size: .82rem; color: var(--muted); margin-bottom: 6px; overflow-wrap: anywhere; }

/* Piezas de licencias que también usa Covers */
.btn-danger {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 18px; margin: 5px 0;
    font-weight: 700; letter-spacing: .04em; color: #fff; text-decoration: none; cursor: pointer;
    border: 1px solid transparent; border-radius: var(--radius-sm);
    background: linear-gradient(180deg, #e9665d, var(--danger)) padding-box,
                linear-gradient(180deg, #f6aaa4, #8f241d) border-box;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.3), 0 2px 5px rgba(143,36,29,.3);
    transition: transform .08s, filter .15s;
}
.btn-danger:hover { filter: brightness(1.06); }
.btn-sm { padding: 5px 12px !important; font-size: .85rem; margin: 0 !important; }

.icon-btn {
    width: 34px; height: 34px; display: inline-grid; place-items: center; padding: 0;
    font-size: 1.1rem; font-weight: 700; cursor: pointer; color: var(--ink-2);
    background: linear-gradient(180deg, #ffffff, #efe8e0) padding-box,
                linear-gradient(180deg, var(--edge-top), var(--edge-bot)) border-box;
    border: 1px solid transparent; border-radius: 9px;
    box-shadow: 0 1px 3px rgba(40,25,10,.12);
}
.icon-btn:hover { color: var(--accent-deep); }

.vault-empty {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    padding: 40px 16px; text-align: center; color: var(--ink-2);
    border: 1px dashed var(--line); border-radius: var(--radius-sm); background: var(--surface-2);
}
.vault-empty b { color: var(--ink); font-size: 1.1rem; }

/* ---------------------------------------------------------------------
   Propio de Covers
   --------------------------------------------------------------------- */
.form-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* Barras de herramientas */
.cov-toolbar { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: flex-end; }
.cov-toolbar .field { display: flex; flex-direction: column; }
.cov-toolbar .field-grow { flex: 1 1 260px; }
.cov-toolbar .field-grow input { width: 100%; }
.cov-toolbar .field-btns { flex-direction: row; gap: 8px; }
.cov-toolbar label .muted { font-weight: 500; }
.cov-selbar { flex-direction: row !important; flex-wrap: wrap; align-items: center; gap: 8px; padding-bottom: 6px; }
.cov-selbar .badge { margin: 0; }

.cov-progress {
    height: 8px; margin-top: 12px; overflow: hidden;
    background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px;
    box-shadow: inset 0 1px 2px rgba(40,25,10,.08);
}
.cov-progress span {
    display: block; height: 100%; width: 0;
    background: linear-gradient(180deg, var(--accent-hi), var(--accent));
    transition: width .3s;
}
.cov-status { margin-top: 10px; color: var(--ink-2); font-weight: 600; }
.cov-count { margin: 6px 0 14px; font-size: .92rem; }

/* Fichas */
.cov-tile { position: relative; cursor: pointer; }
.cov-tile:focus-visible { outline: 3px solid rgba(240,116,21,.55); outline-offset: 2px; }
.cov-pick {
    position: absolute; top: 12px; left: 12px; z-index: 2;
    display: grid; place-items: center; width: 30px; height: 30px; cursor: pointer;
    background: rgba(255,255,255,.92); border-radius: 8px;
    box-shadow: 0 1px 4px rgba(40,25,10,.25);
}
.cov-pick input { width: 18px; height: 18px; margin: 0; cursor: pointer; accent-color: var(--accent); }

.cover .cov-ph {
    position: absolute; inset: 0; display: grid; place-items: center;
    color: var(--muted); font-weight: 600; font-size: .9rem;
}
.cov-tile .cover img { opacity: 0; transition: opacity .2s; position: relative; z-index: 1; }
.cov-tile .cover.is-loaded img { opacity: 1; }
.cov-tile .cover.is-loaded .cov-ph { display: none; }
.cov-tile .cover.is-failed img { display: none; }

/* Paginación */
.cov-pager { display: flex; justify-content: center; align-items: center; gap: 14px; margin-top: 20px; font-weight: 600; }

/* Previa grande */
.cov-dialog {
    width: min(1000px, 94vw); max-height: 92vh; padding: 0;
    border: 1px solid transparent; border-radius: var(--radius);
    background:
        linear-gradient(var(--surface), var(--surface)) padding-box,
        linear-gradient(180deg, var(--edge-top), var(--edge-bot)) border-box;
    box-shadow: 0 20px 60px rgba(20,12,6,.45);
    color: var(--ink);
}
.cov-dialog::backdrop { background: rgba(28,25,23,.72); }
.cov-dlg-body { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(220px, 1fr); gap: 20px; padding: 20px; }
.cov-dlg-img {
    position: relative; display: grid; place-items: center; min-height: 300px; max-height: calc(92vh - 40px);
    background: var(--surface-2); border-radius: var(--radius-sm); overflow: hidden;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,.06);
}
.cov-dlg-img img { max-width: 100%; max-height: calc(92vh - 40px); object-fit: contain; display: block; opacity: 0; transition: opacity .2s; }
.cov-dlg-img img.is-loaded { opacity: 1; }
.cov-dlg-loading { position: absolute; color: var(--muted); font-weight: 600; }
.cov-dlg-info { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.cov-dlg-info h3 { margin: 0; overflow-wrap: anywhere; }
.cov-dlg-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.cov-dlg-actions > * { width: 100%; margin: 0; }
.cov-dlg-nav { display: flex; align-items: center; gap: 10px; margin-top: auto; padding-top: 14px; }
.cov-dlg-nav .cov-dlg-close { margin-left: auto; }
.icon-btn:disabled { opacity: .4; cursor: not-allowed; }

@media (prefers-reduced-motion: reduce) {
    .tile, .toast, button, .cov-tile .cover img, .cov-progress span, .cov-dlg-img img { transition: none; }
    .tile:hover { transform: none; }
}

@media (max-width: 700px) {
    body { padding: 12px; }
    .navbar { padding: 12px 14px; }
    .vault-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
    .cov-dlg-body { grid-template-columns: 1fr; padding: 14px; }
    .cov-dlg-img { min-height: 220px; max-height: 55vh; }
    .cov-dlg-img img { max-height: 55vh; }
    .cov-selbar .btn-sm { flex: 1 1 auto; }
}
