/* ==========================================================================
   Landing Pages · Dashboard
   Estilos globales. Sin dependencias externas.
   ========================================================================== */

:root {
    --bg:            #f6f7f9;
    --surface:       #ffffff;
    --border:        #e3e6ea;
    --border-strong: #cfd4da;

    --text:          #16191d;
    --text-muted:    #6b7280;

    --accent:        #1f6feb;
    --accent-hover:  #1a5fd0;
    --accent-soft:   #e8f0fe;

    --ok:            #0f7a45;
    --ok-soft:       #e3f5eb;
    --warn:          #a35a00;
    --warn-soft:     #fdf0dd;

    --radius:        12px;
    --radius-sm:     8px;
    --shadow:        0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
    --shadow-hover:  0 4px 12px rgba(16, 24, 40, .10), 0 2px 4px rgba(16, 24, 40, .06);

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg:            #0f1216;
        --surface:       #171b21;
        --border:        #252b33;
        --border-strong: #333b45;

        --text:          #e8eaed;
        --text-muted:    #9aa4b2;

        --accent:        #4d90f0;
        --accent-hover:  #6ba4f5;
        --accent-soft:   #16233a;

        --ok:            #4ec98a;
        --ok-soft:       #12281d;
        --warn:          #e0a458;
        --warn-soft:     #2b2113;

        --shadow:        0 1px 2px rgba(0, 0, 0, .4);
        --shadow-hover:  0 4px 14px rgba(0, 0, 0, .5);
    }
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

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

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

.wrap {
    width: 100%;
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 24px;
}

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

.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 32px 0 28px;
    margin-bottom: 32px;
}

.header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
}

.site-title {
    margin: 0 0 4px;
    font-size: 24px;
    font-weight: 650;
    letter-spacing: -.02em;
}

.site-sub {
    margin: 0;
    color: var(--text-muted);
    font-size: 13.5px;
}

/* --- Migas de pan -------------------------------------------------------- */

.crumbs {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -.01em;
    margin-bottom: 4px;
}

.crumbs a { color: var(--text-muted); }
.crumbs a:hover { color: var(--accent); text-decoration: none; }
.crumb-sep { color: var(--border-strong); }
.crumb-current { color: var(--text); font-family: var(--mono); font-size: 16px; }

/* --- Selector de vista ---------------------------------------------------- */

.viewswitch {
    display: inline-flex;
    padding: 3px;
    gap: 2px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.viewswitch[hidden] { display: none; }

.viewswitch-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 12px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}

.viewswitch-btn:hover { color: var(--text); }

.viewswitch-btn[aria-pressed="true"] {
    background: var(--surface);
    color: var(--accent);
    box-shadow: var(--shadow);
}

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

.viewswitch-icon { display: inline-flex; }

/* --- Listado: vista tarjetas (por defecto) -------------------------------- */

/* 320px es el ancho mínimo para que Explorar + Visualizar + ZIP quepan
   en una sola fila dentro de la tarjeta. */
.items {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

/* Cabecera de columnas: sólo existe en la vista tabla. */
.items-head { display: none; }

.card {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: box-shadow .18s ease, transform .18s ease, border-color .18s ease;
}

.card:hover {
    box-shadow: var(--shadow-hover);
    border-color: var(--border-strong);
    transform: translateY(-2px);
}

.card-main {
    display: block;
    flex: 1;
    padding: 18px 18px 14px;
    color: inherit;
}

.card-main:hover { text-decoration: none; }

.card-title {
    margin: 0 0 6px;
    font-family: var(--mono);
    font-size: 15px;
    font-weight: 600;
    word-break: break-word;
}

.card:hover .card-title { color: var(--accent); }

.card-meta {
    margin: 0 0 2px;
    color: var(--text-muted);
    font-size: 13px;
}

.card-date {
    margin: 0;
    color: var(--text-muted);
    font-size: 12px;
    opacity: .8;
}

.card-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 6px;
    padding: 12px 18px;
    border-top: 1px solid var(--border);
    background: linear-gradient(0deg, rgba(0, 0, 0, .015), transparent);
}

/* --- Listado: vista tabla -------------------------------------------------
   Misma marcación que las tarjetas. `display: contents` disuelve .card-main y
   .card-actions para que sus hijos entren en la rejilla de columnas de .card.
   -------------------------------------------------------------------------- */

/* La última columna es fija: con `auto` la cabecera y las filas miden distinto
   (texto corto vs. grupo de botones) y las columnas dejan de cuadrar. */
:root[data-view="table"] {
    --cols: minmax(0, 1fr) 150px 140px 322px;
}

:root[data-view="table"] .items-head {
    display: grid;
    grid-template-columns: var(--cols);
    align-items: center;
    gap: 16px;
    padding: 0 18px 8px;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
}

:root[data-view="table"] .items {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

:root[data-view="table"] .card {
    display: grid;
    grid-template-columns: var(--cols);
    align-items: center;
    gap: 16px;
    padding: 9px 18px;
    border: 0;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    box-shadow: none;
}

:root[data-view="table"] .card:last-child { border-bottom: 0; }

:root[data-view="table"] .card:hover {
    background: var(--accent-soft);
    box-shadow: none;
    transform: none;
}

:root[data-view="table"] .card-main {
    display: contents;
}

/* Las acciones ocupan una sola celda, alineadas a la derecha. */
:root[data-view="table"] .card-actions {
    justify-content: flex-end;
    padding: 0;
    border: 0;
    background: none;
}

:root[data-view="table"] .card-title {
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

:root[data-view="table"] .card-meta,
:root[data-view="table"] .card-date {
    margin: 0;
    font-size: 12.5px;
    font-variant-numeric: tabular-nums;
    opacity: 1;
    white-space: nowrap;
}

/* "Modificado" sólo aporta contexto en las tarjetas; en tabla ya hay cabecera. */
:root[data-view="table"] .lbl { display: none; }

:root[data-view="table"] .items-head .th-actions { text-align: right; }

/* --- Botones ------------------------------------------------------------- */

.btn {
    display: inline-block;
    padding: 8px 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease, transform .1s ease;
}

.btn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.btn:active { transform: translateY(1px); }

/* Acciones de la cabecera del explorador: sin el marco de .card-actions. */
.header-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

/* Botón con icono: el icono se tiñe y se desplaza un pelo al pasar el ratón. */
.btn-icon {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 10px;
}

.btn-icon .ico {
    flex: none;
    color: var(--text-muted);
    transition: color .15s ease, transform .15s ease;
}

.btn-icon:hover .ico {
    color: var(--accent);
    transform: scale(1.12);
}

.btn-icon.is-disabled {
    background: var(--bg);
    border-color: var(--border);
    color: var(--text-muted);
    opacity: .55;
    cursor: not-allowed;
}

/* Sin :hover ni cambios de color: el botón inactivo no debe parecer pulsable. */
.btn-icon.is-disabled:hover {
    border-color: var(--border);
    color: var(--text-muted);
}

.btn-icon.is-disabled:hover .ico {
    color: var(--text-muted);
    transform: none;
}

.btn-download {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    box-shadow: 0 1px 2px rgba(31, 111, 235, .25);
}

.btn-download:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: #fff;
}

.btn-download .ico,
.btn-download:hover .ico { color: #fff; }

.btn-download:hover .ico { transform: translateY(1px); }

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

/* --- Listado de archivos -------------------------------------------------- */

.filelist {
    list-style: none;
    margin: 0;
    padding: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.file-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 16px;
    padding: 10px 18px;
    border-bottom: 1px solid var(--border);
    transition: background .12s ease;
}

.file-row:last-child { border-bottom: 0; }
.file-row:hover { background: var(--accent-soft); }

.file-link {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    color: inherit;
}

.file-link:hover { text-decoration: none; color: var(--accent); }

.file-icon {
    flex: none;
    box-sizing: border-box;
    width: 46px;
    min-width: 46px;
    padding: 3px 0;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--bg);
    color: var(--text-muted);
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 700;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: .04em;
    overflow: hidden;
}

/* Las carpetas llevan icono en lugar de extensión: hay que centrar el SVG
   dentro de la misma caja de 46px que usan las etiquetas de texto. */
.file-icon-dir {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 0;
    background: var(--accent-soft);
    border-color: transparent;
    color: var(--accent);
}

.file-icon-dir .ico {
    width: 15px;
    height: 15px;
}

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

.file-size,
.file-date {
    color: var(--text-muted);
    font-size: 12.5px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.file-size { min-width: 72px; text-align: right; }

/* --- Estados ------------------------------------------------------------- */

.empty {
    padding: 48px 24px;
    background: var(--surface);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
    color: var(--text-muted);
    text-align: center;
}

.error-box {
    max-width: 420px;
    margin: 96px auto;
    padding: 40px 32px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: center;
}

.error-code {
    margin: 0;
    font-size: 48px;
    font-weight: 700;
    letter-spacing: -.03em;
    color: var(--accent);
}

.error-msg { margin: 8px 0 24px; color: var(--text-muted); }

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

.site-footer {
    margin: 48px auto 32px;
    color: var(--text-muted);
    font-size: 12.5px;
    text-align: center;
}

/* --- Responsive ---------------------------------------------------------- */

/* En pantallas estrechas la tabla no cabe: se degrada a tarjetas. */
@media (max-width: 720px) {
    :root[data-view="table"] .items-head { display: none; }

    :root[data-view="table"] .items {
        display: grid;
        grid-template-columns: 1fr;
        gap: 16px;
        background: none;
        border: 0;
        border-radius: 0;
        box-shadow: none;
        overflow: visible;
    }

    :root[data-view="table"] .card {
        display: flex;
        flex-direction: column;
        /* Hay que deshacer también align-items/gap de la vista tabla: si no,
           los hijos se encogen a su contenido y quedan centrados. */
        align-items: stretch;
        gap: 0;
        padding: 0;
        border: 1px solid var(--border);
        border-radius: var(--radius);
        box-shadow: var(--shadow);
    }

    :root[data-view="table"] .card-main    { display: block; }
    :root[data-view="table"] .card-actions { display: flex; }
    :root[data-view="table"] .lbl          { display: inline; }
}

@media (max-width: 640px) {
    .wrap { padding: 0 16px; }
    .site-header { padding: 24px 0 20px; margin-bottom: 24px; }
    .items { grid-template-columns: 1fr; }
    .file-row { grid-template-columns: 1fr auto; row-gap: 4px; }
    .file-date { display: none; }
    .header-row .btn-download { width: 100%; text-align: center; }
    .viewswitch { width: 100%; }
    .viewswitch-btn { flex: 1; justify-content: center; }
}
