/* ==========================================================================
   Nginx File Browser — tema
   Cores em variáveis: edite o bloco :root (escuro) e o bloco do tema claro.
   ========================================================================== */

:root {
    --bg: #0e1116;
    --bg-glow: rgba(79, 195, 247, 0.07);
    --surface: #161b22;
    --surface-2: #1c222b;
    --row-hover: rgba(79, 195, 247, 0.06);
    --border: #262d37;
    --border-soft: #1f252e;
    --text: #e6edf3;
    --text-muted: #8b96a5;
    --accent: #4fc3f7;
    --accent-soft: rgba(79, 195, 247, 0.16);
    --shadow: 0 10px 40px rgba(0, 0, 0, 0.55);

    /* Cores por tipo de arquivo */
    --t-folder: var(--accent);
    --t-file: #8b96a5;
    --t-image: #c084fc;
    --t-video: #f87171;
    --t-audio: #fb923c;
    --t-archive: #facc15;
    --t-disk: #a5b4fc;
    --t-pdf: #f43f5e;
    --t-doc: #60a5fa;
    --t-sheet: #4ade80;
    --t-code: #2dd4bf;
    --t-key: #fbbf24;

    color-scheme: dark;
}

:root[data-theme="light"] {
    --bg: #f3f5f8;
    --bg-glow: rgba(2, 136, 209, 0.06);
    --surface: #ffffff;
    --surface-2: #f6f8fa;
    --row-hover: rgba(2, 136, 209, 0.06);
    --border: #dde2e8;
    --border-soft: #edf0f3;
    --text: #1f2328;
    --text-muted: #5f6b7a;
    --accent: #0288d1;
    --accent-soft: rgba(2, 136, 209, 0.14);
    --shadow: 0 8px 30px rgba(15, 23, 42, 0.08);
    --t-file: #6b7785;
    --t-image: #9333ea;
    --t-video: #dc2626;
    --t-audio: #ea580c;
    --t-archive: #ca8a04;
    --t-disk: #4f46e5;
    --t-pdf: #e11d48;
    --t-doc: #2563eb;
    --t-sheet: #16a34a;
    --t-code: #0d9488;
    --t-key: #d97706;
    color-scheme: light;
}

@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) {
        --bg: #f3f5f8;
        --bg-glow: rgba(2, 136, 209, 0.06);
        --surface: #ffffff;
        --surface-2: #f6f8fa;
        --row-hover: rgba(2, 136, 209, 0.06);
        --border: #dde2e8;
        --border-soft: #edf0f3;
        --text: #1f2328;
        --text-muted: #5f6b7a;
        --accent: #0288d1;
        --accent-soft: rgba(2, 136, 209, 0.14);
        --shadow: 0 8px 30px rgba(15, 23, 42, 0.08);
        --t-file: #6b7785;
        --t-image: #9333ea;
        --t-video: #dc2626;
        --t-audio: #ea580c;
        --t-archive: #ca8a04;
        --t-disk: #4f46e5;
        --t-pdf: #e11d48;
        --t-doc: #2563eb;
        --t-sheet: #16a34a;
        --t-code: #0d9488;
        --t-key: #d97706;
        color-scheme: light;
    }
}

/* --- Base ---------------------------------------------------------------- */

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

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Ubuntu, Cantarell, 'Helvetica Neue', Arial, sans-serif;
    background: radial-gradient(1200px 500px at 50% -120px, var(--bg-glow), transparent 70%), var(--bg);
    background-color: var(--bg);
    color: var(--text);
    margin: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

:focus { outline: none; }
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 6px;
}

.sr-only {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0);
    white-space: nowrap; border: 0;
}

svg { display: block; flex-shrink: 0; }

/* --- Cartão principal ---------------------------------------------------- */

.main-container {
    flex: 1;
    width: 100%;
    max-width: 1040px;
    margin: 48px auto 24px;
    padding: 36px 40px;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
}

/* --- Cabeçalho ----------------------------------------------------------- */

.header-section {
    margin-bottom: 24px;
    padding-bottom: 22px;
    border-bottom: 1px solid var(--border);
}

.brand-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.brand-link {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    min-width: 0;
}

.brand-icon {
    display: grid;
    place-items: center;
    width: 40px; height: 40px;
    border-radius: 10px;
    background: var(--accent-soft);
    color: var(--accent);
    flex-shrink: 0;
}

.page-title {
    font-size: 1.45rem;
    font-weight: 650;
    letter-spacing: -0.01em;
    margin: 0;
}

.brand-link:hover .page-title { color: var(--accent); }

.icon-btn {
    display: grid;
    place-items: center;
    width: 38px; height: 38px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-muted);
    cursor: pointer;
    transition: color .15s, border-color .15s;
}
.icon-btn:hover { color: var(--accent); border-color: var(--accent); }

/* Breadcrumb */
.breadcrumb ol {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 4px;
    list-style: none;
    margin: 0;
    padding: 0;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: thin;
    font-size: 0.92rem;
}
.breadcrumb li { display: inline-flex; align-items: center; gap: 4px; }
.breadcrumb li + li::before {
    content: "›";
    color: var(--text-muted);
    opacity: .6;
    padding: 0 4px;
}
.breadcrumb a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 6px;
    color: var(--text-muted);
    text-decoration: none;
    transition: background-color .15s, color .15s;
}
.breadcrumb a:hover { color: var(--text); background: var(--surface-2); }
.breadcrumb [aria-current="page"] {
    padding: 4px 8px;
    color: var(--text);
    font-weight: 600;
}

/* --- Barra de busca ------------------------------------------------------ */

.toolbar {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 12px;
}

.search {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
}
.search-icon {
    position: absolute;
    left: 14px;
    color: var(--text-muted);
    pointer-events: none;
}
#searchInput {
    width: 100%;
    padding: 12px 76px 12px 42px;
    background-color: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font: inherit;
    font-size: 0.95rem;
    transition: border-color .2s, box-shadow .2s;
}
#searchInput::placeholder { color: var(--text-muted); }
#searchInput::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
#searchInput:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
#searchInput:disabled { opacity: .55; cursor: not-allowed; }

.kbd-hint {
    position: absolute;
    right: 12px;
    font: 600 0.75rem ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: 5px;
    padding: 1px 7px;
    pointer-events: none;
}
.search.has-value .kbd-hint,
#searchInput:focus ~ .kbd-hint { display: none; }

.clear-btn {
    position: absolute;
    right: 8px;
    display: grid;
    place-items: center;
    width: 28px; height: 28px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
}
.clear-btn:hover { color: var(--text); background: var(--border-soft); }
.clear-btn[hidden] { display: none; }
.counter:empty { display: none; }

.counter {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.85rem;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

/* --- Tabela -------------------------------------------------------------- */

/* Evita o "pisca" em inglês enquanto o script ajusta a tabela */
.js:not(.ready) #list { visibility: hidden; }

table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

th {
    width: auto;
    padding: 12px 12px;
    text-align: left;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
th a { color: inherit; text-decoration: none; }
th.col-size, td.size { width: 120px; text-align: right; }
th.col-date, td.date { width: 170px; }

.sort-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    letter-spacing: inherit;
    text-transform: inherit;
    color: inherit;
    cursor: pointer;
}
.sort-btn:hover { color: var(--text); }
.sort-btn .arrow { width: 14px; height: 14px; color: var(--accent); }
th[aria-sort="none"] .arrow { visibility: hidden; }
th.col-size .sort-btn { flex-direction: row-reverse; }

td {
    padding: 0;
    border-bottom: 1px solid var(--border-soft);
    font-size: 0.94rem;
    vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }

td.size, td.date {
    padding: 12px;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

tbody tr { transition: background-color .12s; }
tbody tr:hover { background-color: var(--row-hover); }
.ready tbody tr { cursor: pointer; }

td.link a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    min-width: 0;
    color: var(--text);
    text-decoration: none;
}
td.link a:hover .name { color: var(--accent); }

.ficon { display: grid; place-items: center; width: 22px; flex-shrink: 0; color: var(--t-file); }
.ficon[data-type="folder"]  { color: var(--t-folder); }
.ficon[data-type="image"]   { color: var(--t-image); }
.ficon[data-type="video"]   { color: var(--t-video); }
.ficon[data-type="audio"]   { color: var(--t-audio); }
.ficon[data-type="archive"] { color: var(--t-archive); }
.ficon[data-type="disk"]    { color: var(--t-disk); }
.ficon[data-type="pdf"]     { color: var(--t-pdf); }
.ficon[data-type="doc"]     { color: var(--t-doc); }
.ficon[data-type="sheet"]   { color: var(--t-sheet); }
.ficon[data-type="code"]    { color: var(--t-code); }
.ficon[data-type="key"]     { color: var(--t-key); }
.ficon[data-type="parent"]  { color: var(--text-muted); }

.text { display: flex; flex-direction: column; min-width: 0; }
.name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: color .12s;
}
.is-dir .name { font-weight: 550; }
.parent-row .name { color: var(--text-muted); font-weight: 500; }
.meta { display: none; color: var(--text-muted); font-size: 0.8rem; margin-top: 2px; }

tr.is-hidden { display: none; }

/* --- Estado vazio -------------------------------------------------------- */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 48px 16px 40px;
    color: var(--text-muted);
    text-align: center;
}
.empty-state[hidden] { display: none; }
.empty-state svg { color: var(--border); width: 44px; height: 44px; }
.empty-state p { margin: 0; }
.empty-state .empty-title { color: var(--text); font-weight: 600; }

/* --- Rodapé -------------------------------------------------------------- */

.site-footer {
    padding: 8px 16px 32px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}
.site-footer a { color: var(--accent); text-decoration: none; font-weight: 500; }
.site-footer a:hover { text-decoration: underline; }

/* --- Celular ------------------------------------------------------------- */

@media (max-width: 640px) {
    .main-container {
        margin: 16px 16px 12px;
        width: auto;
        padding: 20px 16px;
        border-radius: 14px;
    }
    .header-section { margin-bottom: 16px; padding-bottom: 16px; }
    .page-title { font-size: 1.2rem; }
    .brand-icon { width: 34px; height: 34px; }
    .toolbar { flex-direction: column; align-items: stretch; gap: 8px; }
    .counter { padding-left: 2px; }
    .kbd-hint { display: none; }

    .ready th.col-size, .ready td.size,
    .ready th.col-date, .ready td.date { display: none; }
    .ready .meta { display: block; }
    td.link a { padding: 10px 6px; }
    th { padding: 10px 6px; }
}
