/* ================================================================
   BIONICKS DRIVE - Tema dark rock
   ================================================================ */

:root {
    --bg: #0d0f14;
    --surface: #141821;
    --surface-2: #1a2030;
    --border: #262d3f;
    --text: #e9ebf2;
    --muted: #8b93a7;
    --accent: #e11d48;
    --accent-hover: #f43f5e;
    --ok: #34d399;
    --warn: #fbbf24;
    --err: #f87171;
    --radius: 10px;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

/* Garante que elementos com o atributo hidden fiquem realmente invisíveis
   (o display:flex das modais/dock sobrepõe o hidden padrão do navegador) */
.modal-backdrop[hidden],
#dock[hidden],
[hidden] {
    display: none !important;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
}

body { min-height: 100vh; }

/* ---------------------------------------------------------------- */
/* Botões e campos                                                   */
/* ---------------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 9px 14px;
    font-size: 14px;
    font-family: var(--font);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: #222a3e; border-color: #34405e; }
.btn:active { transform: translateY(1px); }
.btn.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    font-weight: 600;
}
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--surface-2); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.danger { color: var(--err); }
.btn.danger:hover { border-color: var(--err); background: rgba(248, 113, 113, .08); }
.btn.full { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

input[type="text"], input[type="password"], input[type="search"], select {
    width: 100%;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius);
    padding: 10px 12px;
    font-size: 14px;
    font-family: var(--font);
    outline: none;
}
input:focus, select:focus { border-color: var(--accent); }
label {
    display: block;
    font-size: 13px;
    color: var(--muted);
    margin: 14px 0 6px;
}

/* ---------------------------------------------------------------- */
/* Páginas de autenticação (login / instalação)                      */
/* ---------------------------------------------------------------- */

.center-page {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(1200px 500px at 80% -10%, rgba(225, 29, 72, .12), transparent 60%),
        radial-gradient(900px 400px at 10% 110%, rgba(225, 29, 72, .07), transparent 60%),
        var(--bg);
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 32px 28px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
}
.auth-card h1 { margin: 18px 0 6px; font-size: 22px; }
.auth-card .btn.full { margin-top: 18px; }
.auth-card form { margin-bottom: 0; }
.auth-card form .btn.full { margin-top: 22px; }

.logo {
    font-weight: 900;
    letter-spacing: 2px;
    font-size: 20px;
    color: var(--text);
    user-select: none;
}
.logo span { color: var(--accent); }

.tagline { color: var(--muted); margin: 6px 0 0; font-size: 14px; }

.alert {
    border-radius: var(--radius);
    padding: 10px 12px;
    font-size: 14px;
    margin: 14px 0 0;
    border: 1px solid transparent;
}
.alert.ok { background: rgba(52, 211, 153, .1); border-color: rgba(52, 211, 153, .35); color: var(--ok); }
.alert.err { background: rgba(248, 113, 113, .1); border-color: rgba(248, 113, 113, .35); color: var(--err); }

.checks { list-style: none; padding: 0; margin: 16px 0 0; font-size: 14px; }
.checks li { padding: 5px 0; color: var(--muted); }
.checks li.ok { color: var(--ok); }
.checks li.bad { color: var(--err); }

.hint { color: var(--muted); font-size: 13px; margin-top: 14px; }

/* ---------------------------------------------------------------- */
/* Barra superior                                                    */
/* ---------------------------------------------------------------- */

.topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
    flex-wrap: wrap;
}
.top-stats {
    flex: 1;
    min-width: 180px;
    color: var(--muted);
    font-size: 13px;
}
.top-stats .bar {
    display: block;
    height: 5px;
    border-radius: 3px;
    background: var(--surface-2);
    margin-top: 5px;
    overflow: hidden;
    max-width: 320px;
}
.top-stats .bar i {
    display: block;
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
}
.top-user {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}
.who { color: var(--text); font-weight: 600; font-size: 14px; }
.badge {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 3px 8px;
    border-radius: 20px;
    border: 1px solid var(--border);
    color: var(--muted);
}
.badge.admin { color: var(--accent); border-color: rgba(225, 29, 72, .5); }

/* ---------------------------------------------------------------- */
/* Barra de ferramentas e navegação                                  */
/* ---------------------------------------------------------------- */

.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px 0;
    flex-wrap: wrap;
}
.toolbar .spacer { flex: 1; }
.search { width: 240px; }

.crumbs {
    padding: 12px 20px;
    font-size: 14px;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}
.crumbs a {
    color: var(--muted);
    text-decoration: none;
    padding: 3px 7px;
    border-radius: 6px;
}
.crumbs a:hover { color: var(--text); background: var(--surface-2); }
.crumbs .sep { color: #3a4258; }
.crumbs .here { color: var(--text); font-weight: 600; padding: 3px 7px; }

/* ---------------------------------------------------------------- */
/* Lista de arquivos                                                 */
/* ---------------------------------------------------------------- */

.listwrap {
    margin: 0 20px 90px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    overflow: hidden;
}
.listwrap.dragover { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(225, 29, 72, .25) inset; }

table.files { width: 100%; border-collapse: collapse; }
table.files thead th {
    text-align: left;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--muted);
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, .02);
}
table.files td {
    padding: 10px 14px;
    border-bottom: 1px solid rgba(38, 45, 63, .55);
    vertical-align: middle;
}
table.files tbody tr:hover { background: rgba(255, 255, 255, .028); }
table.files tbody tr:last-child td { border-bottom: none; }

.c-name { display: flex; align-items: center; gap: 11px; min-width: 0; }
.ficon { flex: 0 0 auto; display: inline-flex; color: var(--muted); }
.ficon svg { width: 20px; height: 20px; }
.fname {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 46vw;
}
tr.dir .fname { font-weight: 600; cursor: pointer; }
tr.dir .fname:hover { color: var(--accent-hover); }
tr.dir .ficon { color: var(--warn); }
tr.file.audio .ficon, tr.file.video .ficon { color: var(--accent-hover); }
tr.file.image .ficon { color: var(--ok); }

.fname.link { cursor: pointer; }
.fname.link:hover { color: var(--accent-hover); }

.col-size, td.col-size { width: 100px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.col-date, td.col-date { width: 160px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.col-acts, td.col-acts { width: 150px; text-align: right; white-space: nowrap; }
td.col-acts .btn { padding: 4px 8px; font-size: 12.5px; }

.empty {
    text-align: center;
    padding: 70px 20px;
    color: var(--muted);
}
.empty strong { color: var(--text); font-size: 16px; }

/* ---------------------------------------------------------------- */
/* Painel de upload (dock)                                           */
/* ---------------------------------------------------------------- */

#dock {
    position: fixed;
    right: 20px;
    bottom: 20px;
    width: 380px;
    max-width: calc(100vw - 40px);
    max-height: 55vh;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, .55);
    z-index: 90;
    overflow: hidden;
}
.dock-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, .02);
}
#dockList { overflow-y: auto; padding: 8px 14px 14px; }
.up-item { padding: 10px 0; border-bottom: 1px solid rgba(38, 45, 63, .5); }
.up-item:last-child { border-bottom: none; }
.up-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    font-size: 13.5px;
}
.up-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-info { color: var(--muted); font-size: 12px; margin-top: 3px; }
.up-bar {
    height: 6px;
    background: var(--surface-2);
    border-radius: 3px;
    margin-top: 7px;
    overflow: hidden;
}
.up-bar i {
    display: block;
    height: 100%;
    width: 0;
    background: var(--accent);
    border-radius: 3px;
    transition: width .2s;
}
.up-item.done .up-bar i { background: var(--ok); }
.up-item.error .up-bar i { background: var(--err); }
.up-status { font-size: 12px; margin-top: 5px; }
.up-item.done .up-status { color: var(--ok); }
.up-item.error .up-status { color: var(--err); }

/* ---------------------------------------------------------------- */
/* Modais                                                            */
/* ---------------------------------------------------------------- */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(5, 7, 12, .7);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}
.modal {
    width: 100%;
    max-width: 430px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, .6);
}
.modal.wide { max-width: 680px; }
.modal h3 { margin: 0 0 6px; font-size: 18px; }
.modal h4 { margin: 22px 0 8px; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.modal .btn.full { margin-top: 20px; }
.modal-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}
.modal-acts {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}
.modal form { margin: 0; }

.preview-body { margin-top: 8px; }
.preview-body video, .preview-body img {
    width: 100%;
    max-height: 60vh;
    border-radius: 10px;
    background: #000;
}
.preview-body audio { width: 100%; margin-top: 8px; }
.preview-body iframe {
    width: 100%;
    height: 65vh;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
}
.preview-fallback { color: var(--muted); font-size: 14px; }

/* ---------------------------------------------------------------- */
/* Admin                                                             */
/* ---------------------------------------------------------------- */

.inline-form {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.inline-form input, .inline-form select { width: auto; flex: 1; min-width: 120px; }
.inline-form .btn { flex: 0 0 auto; }

.table-scroll { max-height: 260px; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; }
table.mini { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.mini thead th {
    text-align: left;
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--surface);
}
table.mini td { padding: 8px 10px; border-bottom: 1px solid rgba(38, 45, 63, .5); }
table.mini tr:last-child td { border-bottom: none; }
.logbox td { color: var(--muted); }
.logbox td b { color: var(--text); font-weight: 600; }

/* ---------------------------------------------------------------- */
/* Toasts                                                            */
/* ---------------------------------------------------------------- */

#toasts {
    position: fixed;
    top: 66px;
    right: 20px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 340px;
}
.toast {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    color: var(--text);
    border-radius: 10px;
    padding: 11px 14px;
    font-size: 14px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
    animation: slidein .18s ease-out;
}
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--err); }
@keyframes slidein {
    from { transform: translateX(20px); opacity: 0; }
    to   { transform: none; opacity: 1; }
}

/* ---------------------------------------------------------------- */
/* Responsivo                                                        */
/* ---------------------------------------------------------------- */

@media (max-width: 720px) {
    .col-date { display: none; }
    table.files thead .col-date { display: none; }
    .fname { max-width: 52vw; }
    .search { width: 100%; order: 10; }
    .top-stats .bar { max-width: none; }
    td.col-acts .btn span.lbl { display: none; }
}
