/* style.css — Intermega Transfer (light theme, alineado con gestor.intermega.es) */
@import url('https://fonts.googleapis.com/css2?family=Fira+Sans:wght@400;500;600;700&display=swap');

:root {
    --bg:        #f5f7fa;
    --surface:   #ffffff;
    --surface-2: #f1f5f9;
    --border:    #e2e8f0;
    --border-2:  #cbd5e1;
    --text:      #1e293b;
    --muted:     #64748b;
    --accent:    #046BD2;
    --accent-2:  #045cb4;
    --accent-50: #e6f0fb;
    --ok:        #16a34a;
    --warn:      #d97706;
    --err:       #dc2626;
    --radius:    8px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: 'Fira Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button {
    cursor: pointer;
    font: inherit;
    border-radius: var(--radius);
    border: 1px solid var(--border-2);
    background: var(--surface);
    color: var(--text);
    padding: .5rem 1rem;
    transition: background .15s, border-color .15s;
}
button:hover { background: var(--surface-2); border-color: var(--accent); }
button[disabled] { opacity: .55; cursor: not-allowed; }
button[disabled]:hover { background: var(--surface); border-color: var(--border-2); }

input[type=password], input[type=text] {
    width: 100%;
    padding: .65rem .85rem;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border-2);
    border-radius: var(--radius);
    font: inherit;
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }

main { padding: 1.5rem 2rem; max-width: 1500px; margin: 0 auto; }
.page-upload main { max-width: 1100px; }
h1 { margin-top: 0; font-size: 1.5rem; color: var(--text); }
.subtitle { color: var(--muted); margin: .25rem 0 1.5rem; }

/* ===== Login ===== */
.page-login { display: grid; place-items: center; }
.card {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem 2rem 2rem;
    margin: 4rem auto;
    box-shadow: 0 4px 24px rgba(15,23,42,.08);
}
.card h1 { margin: 0 0 .25rem; font-size: 1.375rem; }
.card form { display: flex; flex-direction: column; gap: .75rem; margin-top: 1.5rem; }
.card label { color: var(--muted); font-size: .875rem; font-weight: 500; }
.card button[type=submit] {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    padding: .7rem;
    font-weight: 500;
    margin-top: .5rem;
}
.card button[type=submit]:hover {
    background: var(--accent-2);
    border-color: var(--accent-2);
}
.msg { color: var(--err); margin: .25rem 0 0; font-size: .875rem; }
.back-link {
    text-align: center;
    margin: 1.25rem 0 0;
    font-size: .8125rem;
}
.back-link a { color: var(--muted); }
.back-link a:hover { color: var(--accent); }

/* ===== Topbar ===== */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(15,23,42,.05);
    margin: 0;
}
.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .85rem 2rem;
    max-width: 1500px;
    margin: 0 auto;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
}
.brand { display: inline-flex; align-items: center; }
.brand-logo {
    display: block;
    height: 48px;
    width: auto;
}
.topbar nav { display: flex; gap: 1.5rem; align-items: center; }
.topbar nav a {
    color: var(--muted);
    padding: .35rem .25rem;
    font-size: .9375rem;
    font-weight: 500;
    border-bottom: 2px solid transparent;
}
.topbar nav a.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}
.topbar nav a:hover { color: var(--accent); text-decoration: none; }

/* ===== Login banner (logo en card) ===== */
.login-banner {
    text-align: center;
    margin: -.5rem 0 1.25rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border);
}
.login-banner .brand-logo { height: 44px; margin: 0 auto; }

.dz-hint strong { color: var(--text); font-weight: 600; }

/* ===== Upload meta (nombre opcional del subidor) ===== */
.upload-meta {
    display: flex;
    align-items: center;
    gap: .65rem;
    margin: 0 0 1rem;
    padding: .65rem .85rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.upload-meta label {
    color: var(--muted);
    font-weight: 500;
    white-space: nowrap;
}
.upload-meta label .optional {
    color: var(--muted);
    font-weight: 400;
    font-size: .8125rem;
}
.upload-meta input[type=text] {
    flex: 1;
    padding: .45rem .65rem;
    border: 1px solid var(--border-2);
    border-radius: 4px;
}
.upload-meta input[type=text]:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
    border-color: var(--accent);
}
@media (max-width: 600px) {
    .upload-meta { flex-direction: column; align-items: stretch; }
}

.topbar nav a.nav-secondary {
    color: var(--muted);
    font-size: .8125rem;
    font-weight: 400;
}
.topbar nav a.nav-secondary:hover {
    color: var(--accent);
}

.files-table .uploader {
    color: var(--text);
    font-weight: 500;
    white-space: nowrap;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== Quota footer card ===== */
.quota-card {
    margin-top: 2.5rem;
    padding: .85rem 1.1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--muted);
    font-size: .8125rem;
}
.quota-card .quota-title {
    display: block;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    font-size: .6875rem;
    margin-bottom: .65rem;
}
.quota-card .quota-info {
    color: var(--accent);
    font-weight: 500;
}
.quota-bar {
    display: grid;
    grid-template-columns: 110px 1fr 130px;
    align-items: center;
    gap: .75rem;
    padding: .25rem 0;
}
.quota-bar .quota-label { color: var(--muted); }
.quota-bar .quota-track {
    height: 5px;
    background: var(--surface-2);
    border-radius: 3px;
    overflow: hidden;
}
.quota-bar .quota-fill {
    height: 100%;
    background: var(--accent);
    transition: width .3s;
    border-radius: 3px;
}
.quota-bar.warn   .quota-fill { background: var(--warn); }
.quota-bar.danger .quota-fill { background: var(--err); }
.quota-bar .quota-val {
    text-align: right;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    font-size: .8125rem;
}
@media (max-width: 600px) {
    .quota-bar {
        grid-template-columns: 1fr 1fr;
        gap: .15rem .75rem;
    }
    .quota-bar .quota-track { grid-column: 1 / -1; order: 2; }
    .quota-bar .quota-val { text-align: right; order: 1; }
    .quota-bar .quota-label { order: 0; }
}

/* ===== Retention chip (post-upload edit) ===== */
.retention-chip {
    background: var(--accent-50);
    color: var(--accent);
    border: 1px solid transparent;
    padding: .1rem .55rem;
    border-radius: 999px;
    font: inherit;
    font-size: .8125rem;
    cursor: pointer;
    margin-left: .15rem;
    transition: background .15s, border-color .15s;
}
.retention-chip:hover {
    border-color: var(--accent);
    text-decoration: none;
}
.retention-chip::after {
    content: ' ▾';
    font-size: .7rem;
    opacity: .7;
}
.retention-select {
    padding: .15rem .35rem;
    border: 1px solid var(--accent);
    border-radius: 4px;
    font: inherit;
    font-size: .8125rem;
    background: var(--surface);
    color: var(--text);
    margin-left: .15rem;
}
.retention-select:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

/* ===== Dropzone ===== */
.dropzone {
    border: 2px dashed var(--border-2);
    border-radius: var(--radius);
    background: var(--surface);
    padding: 3rem 1.5rem;
    text-align: center;
    transition: border-color .15s, background .15s;
    cursor: pointer;
}
.dropzone:hover, .dropzone:focus, .dropzone.drag {
    border-color: var(--accent);
    background: var(--accent-50);
    outline: none;
}
.dz-title { font-size: 1.125rem; margin: 0 0 .5rem; color: var(--text); }
.dz-hint  { color: var(--muted); margin: 0; font-size: .875rem; }
.link-btn {
    background: none;
    border: none;
    color: var(--accent);
    padding: 0;
    font: inherit;
    text-decoration: underline;
    cursor: pointer;
}

/* ===== Upload items ===== */
.uploads {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: .75rem;
}
.upload-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .85rem 1rem;
    box-shadow: 0 1px 2px rgba(15,23,42,.04);
}
.upload-item header {
    display: flex; justify-content: space-between; gap: 1rem;
    font-size: .9375rem;
}
.upload-item .name { font-weight: 500; word-break: break-all; color: var(--text); }
.upload-item .size { color: var(--muted); white-space: nowrap; }
.upload-item .bar {
    height: 6px;
    background: var(--surface-2);
    border-radius: 3px;
    overflow: hidden;
    margin: .65rem 0;
}
.bar-fill {
    height: 100%;
    width: 0%;
    background: var(--accent);
    transition: width .25s;
}
.upload-item[data-state=done] .bar-fill { background: var(--ok); }
.upload-item[data-state=error] .bar-fill { background: var(--err); }
.upload-item[data-state=cancelled] .bar-fill { background: var(--muted); }
.upload-item footer {
    display: flex; justify-content: space-between; gap: .5rem; align-items: center;
    font-size: .8125rem; color: var(--muted);
}
.upload-item .actions {
    display: flex; gap: .5rem; align-items: center;
}
.upload-item .actions button { padding: .35rem .65rem; font-size: .8125rem; }
.upload-item .copy-link {
    width: 280px; max-width: 60vw;
    padding: .35rem .5rem;
    font-size: .8125rem;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 4px;
}

/* ===== Files table ===== */
.table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow-x: auto;
    box-shadow: 0 1px 3px rgba(15,23,42,.04);
    -webkit-overflow-scrolling: touch;
}
.files-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
}
.files-table th, .files-table td {
    padding: .55rem .75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: .875rem;
    vertical-align: middle;
    white-space: nowrap;
}
.files-table th {
    background: var(--surface-2);
    color: var(--muted);
    font-weight: 600;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .05em;
}
.files-table tr:last-child td { border-bottom: none; }
.files-table tr:hover td { background: var(--accent-50); }
.files-table .name { color: var(--text); }
.files-table td.actions { display: flex; gap: .35rem; }

/* Ocultar columnas secundarias sólo cuando el viewport es realmente estrecho */
@media (max-width: 1100px) {
    .files-table .col-secondary { display: none; }
}
.btn-sm { padding: .3rem .55rem; font-size: .75rem; border-radius: 4px; }
a.btn-sm {
    display: inline-block;
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}
a.btn-sm:hover { background: var(--accent-2); border-color: var(--accent-2); text-decoration: none; }
.btn-sm.danger { background: var(--surface); color: var(--err); border-color: var(--err); }
.btn-sm.danger:hover { background: rgba(220,38,38,.08); }

.badge {
    display: inline-block;
    padding: .125rem .55rem;
    border-radius: 999px;
    font-size: .6875rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    font-weight: 600;
}
.badge-ready     { background: rgba(22,163,74,.12);  color: var(--ok); }
.badge-uploading { background: rgba(217,119,6,.12);  color: var(--warn); }
.badge-deleted   { background: var(--surface-2); color: var(--muted); }

/* ===== Search form ===== */
.search-form {
    display: flex;
    gap: .5rem;
    align-items: center;
    margin: 0 0 1rem;
    max-width: 520px;
}
.search-form input[type=search] {
    flex: 1;
    padding: .55rem .85rem;
}
.search-form button {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    padding: .55rem 1.1rem;
}
.search-form button:hover { background: var(--accent-2); border-color: var(--accent-2); }
.search-form .search-clear {
    color: var(--muted);
    font-size: .875rem;
    padding: 0 .25rem;
}
.search-form .search-clear:hover { color: var(--err); text-decoration: none; }

.subtitle strong { color: var(--text); font-weight: 600; }

.empty {
    padding: 3rem;
    text-align: center;
    color: var(--muted);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

/* ===== Modal ===== */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity .15s;
}
.modal.open { opacity: 1; }
.modal[hidden] { display: none; }
.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15,23,42,.4);
}
.modal-dialog {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    min-width: 320px;
    max-width: min(92vw, 480px);
    box-shadow: 0 20px 60px rgba(15,23,42,.18);
    transform: scale(.96);
    transition: transform .15s;
}
.modal.open .modal-dialog { transform: scale(1); }
.modal-title {
    margin: 0 0 .5rem;
    font-size: 1.0625rem;
    color: var(--text);
    font-weight: 600;
}
.modal-message {
    margin: 0 0 1.25rem;
    color: var(--text);
    line-height: 1.45;
    word-break: break-word;
}
.modal-input { margin: 0 0 1.25rem; }
.modal-input[readonly] {
    background: var(--surface-2);
    color: var(--text);
    user-select: all;
}
.modal-actions {
    display: flex;
    gap: .5rem;
    justify-content: flex-end;
}
.modal-actions button { padding: .5rem 1rem; min-width: 90px; }
.modal-actions .modal-ok {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}
.modal-actions .modal-ok:hover { background: var(--accent-2); border-color: var(--accent-2); }
.modal-actions .modal-ok.danger {
    background: var(--err);
    border-color: var(--err);
}
.modal-actions .modal-ok.danger:hover { background: #b91c1c; border-color: #b91c1c; }
.modal-actions .modal-cancel { background: var(--surface); color: var(--text); }
.modal-actions .modal-cancel:hover { background: var(--surface-2); }

/* ===== Header responsive ===== */
@media (max-width: 900px) {
    .topbar-inner { padding: .75rem 1.25rem; }
    main { padding: 1.25rem 1.25rem; }
}
@media (max-width: 600px) {
    .topbar-inner { padding: .65rem .85rem; }
    main { padding: 1rem .85rem; }
    .brand-logo { height: 36px; }
    .topbar nav { gap: .85rem; }
    .topbar nav a { font-size: .8125rem; padding: .25rem .15rem; }
}
@media (max-width: 380px) {
    .brand-logo { height: 30px; }
    .topbar nav { gap: .65rem; }
}

/* ===== Files table en móvil — convertir filas en tarjetas ===== */
@media (max-width: 720px) {
    .table-wrap {
        background: transparent;
        border: none;
        box-shadow: none;
        overflow-x: visible;
    }
    .files-table {
        background: transparent;
        display: block;
    }
    .files-table thead { display: none; }
    .files-table tbody { display: block; }
    .files-table tr {
        display: block;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        margin-bottom: .65rem;
        padding: .85rem 1rem;
        box-shadow: 0 1px 2px rgba(15,23,42,.04);
    }
    .files-table tr:hover td { background: transparent; }
    .files-table td {
        display: flex;
        align-items: center;
        gap: .65rem;
        padding: .2rem 0;
        border: none;
        white-space: normal;
        font-size: .875rem;
    }
    .files-table td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: .75rem;
        font-weight: 500;
        text-transform: uppercase;
        letter-spacing: .03em;
        min-width: 92px;
        flex: 0 0 auto;
    }
    .files-table .name {
        font-weight: 600;
        font-size: 1rem;
        margin-bottom: .25rem;
        padding-bottom: .35rem;
        border-bottom: 1px solid var(--border);
    }
    .files-table .name::before { display: none; }
    .files-table td.col-secondary { display: flex; }
    .files-table td.actions {
        margin-top: .65rem;
        padding-top: .5rem;
        border-top: 1px solid var(--border);
        flex-wrap: wrap;
        gap: .4rem;
    }
    .files-table td.actions::before { display: none; }
    .files-table td.actions .btn-sm { flex: 1 1 auto; text-align: center; }
}
