:root {
    --bg: #0e1116;
    --panel: #171b22;
    --panel2: #1e232c;
    --text: #d8dde6;
    --muted: #8a94a6;
    --accent: #4aa3ff;
    --green: #35c461;
    --red: #e55353;
    --border: #2a303b;
}

/* Défensif : l'attribut HTML `hidden` doit TOUJOURS cacher,
   même si une règle plus spécifique comme `.modal-overlay { display: flex }`
   pourrait sinon le neutraliser (cascade à spécificité égale). */
[hidden] { display: none !important; }

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

header {
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    padding: 16px 24px;
    position: relative;
}
header h1 { margin: 0; font-size: 18px; }
header .meta { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
header .header-right {
    position: absolute;
    top: 16px;
    right: 24px;
    margin: 0;
}
header .header-right a { color: var(--accent); text-decoration: none; }
header .header-right a:hover { text-decoration: underline; }

main {
    max-width: 1000px;
    margin: 0 auto;
    padding: 24px;
}

section {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 20px;
    margin-bottom: 24px;
}

section h2 {
    margin: 0 0 16px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

/* Upload zone */
#drop-zone {
    border: 2px dashed var(--border);
    border-radius: 6px;
    padding: 36px 20px;
    text-align: center;
    transition: all 0.15s;
}
#drop-zone.drag-over {
    border-color: var(--accent);
    background: rgba(74, 163, 255, 0.05);
}
#drop-zone.disabled {
    pointer-events: none;
    border-color: rgba(245, 166, 35, 0.3);
    background: rgba(0, 0, 0, 0.3);
    padding: 24px 20px;
}
/* En état désactivé : seul le message d'avertissement est visible. */
#drop-zone.disabled > *:not(.drop-target) {
    display: none !important;
}
#drop-zone.disabled .drop-target {
    color: #f5a623;
    pointer-events: auto;
    opacity: 1;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.7;
    margin: 0;
    text-align: center;
}
#drop-zone .drop-hint {
    margin: 0 0 12px;
    color: var(--muted);
}
#drop-zone .allowed-exts {
    margin: 20px 0 0;
    font-size: 11px;
    color: var(--muted);
}

.btn {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    border: none;
    text-decoration: none;
    font-family: inherit;
}
.btn:hover { background: #3a93ef; }
.btn-danger { background: var(--red); }
.btn-danger:hover { background: #d44141; }
.btn-ghost {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--panel2); }

/* Overwrite warning */
.warning {
    margin-top: 16px;
    padding: 16px 18px;
    background: rgba(245, 166, 35, 0.10);
    border: 1px solid rgba(245, 166, 35, 0.35);
    border-radius: 6px;
}
.warning-title {
    margin: 0 0 8px;
    font-weight: 600;
    color: #f5a623;
}
.warning-body {
    margin: 0 0 12px;
    color: var(--text);
    font-size: 13px;
}
.warning-body code {
    background: rgba(0, 0, 0, 0.3);
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 12px;
}
.warning-actions {
    display: flex;
    gap: 8px;
}

/* Upload progress */
#upload-progress[hidden] { display: none !important; }
#upload-progress {
    margin-top: 16px;
    padding: 12px;
    background: var(--panel2);
    border-radius: 4px;
}
/* Also force-hide 'New folder' button when set via JS element.hidden */
#new-folder-btn[hidden] { display: none !important; }
#upload-filename {
    margin: 0 0 8px;
    font-weight: 500;
    font-size: 13px;
}
.bar {
    height: 10px;
    background: var(--border);
    border-radius: 5px;
    overflow: hidden;
}
.bar-fill {
    height: 100%;
    background: var(--accent);
    width: 0%;
    transition: width 0.2s;
}
#upload-status {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 12px;
}

/* Breadcrumbs */
#breadcrumbs {
    margin-bottom: 16px;
    padding: 8px 12px;
    background: var(--panel2);
    border-radius: 4px;
    font-size: 13px;
}
.crumb { color: var(--accent); text-decoration: none; padding: 2px 6px; border-radius: 3px; }
.crumb:hover { background: rgba(74, 163, 255, 0.1); text-decoration: underline; }
.crumb-sep { color: var(--muted); margin: 0 2px; }

.listing-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 20px 0 8px;
}
.listing-toolbar h2 { margin: 0; font-size: 14px; font-weight: 600; }
.btn-small { padding: 5px 10px; font-size: 12px; }

#drop-zone .drop-target {
    margin: 10px 0 0;
    color: var(--accent);
    font-size: 12px;
    font-family: Menlo, monospace;
}

/* File list */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
table th, table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
table th {
    color: var(--muted);
    font-weight: 500;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
table tr:hover { background: var(--panel2); }
table td.key, table td.name { font-family: Menlo, monospace; font-size: 12px; }
table td.size { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
table td.date { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
table td.actions { text-align: right; white-space: nowrap; }
table td.name a { color: var(--text); text-decoration: none; }
table td.name a:hover { color: var(--accent); text-decoration: underline; }
.row-folder td.name a { font-weight: 500; }
.row-up td a { color: var(--muted); }

.btn-icon {
    background: transparent;
    border: 1px solid transparent;
    color: var(--muted);
    cursor: pointer;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 14px;
    margin-left: 2px;
}
.btn-icon:hover { background: var(--panel2); border-color: var(--border); color: var(--text); }
.act-delete:hover { color: var(--red); }

.lock {
    font-size: 14px;
    cursor: help;
    padding: 2px 8px;
    opacity: 0.7;
}
.row-protected td.name {
    font-weight: 500;
}
.row-protected td.name::before {
    content: '';
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}
.modal {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 24px;
    max-width: 520px;
    width: 100%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}
.modal h3 { margin: 0 0 14px; font-size: 15px; }
.modal input[type=text] {
    background: var(--panel2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 10px;
    border-radius: 4px;
    font-family: Menlo, monospace;
    font-size: 13px;
    width: 100%;
}
.modal input[type=text]:focus { outline: none; border-color: var(--accent); }
.modal code {
    background: var(--panel2);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 12px;
    word-break: break-all;
}
.modal .hint { color: var(--muted); font-size: 12px; margin: 8px 0 0; }
.modal .error { color: var(--red); margin: 8px 0 0; font-size: 12px; }
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}

.muted { color: var(--muted); }
.error { color: var(--red); }

footer {
    text-align: center;
    padding: 24px;
    color: var(--muted);
    font-size: 11px;
}

/* Retour (flèche gauche dans le header) */
.crumb-back {
    color: var(--muted);
    text-decoration: none;
    font-size: 16px;
    margin-right: 6px;
    display: inline-block;
    transition: color 0.1s;
}
.crumb-back:hover { color: var(--accent); }

/* Hub — grille de cartes de choix de service */
main.hub {
    max-width: 920px;
    margin: 0 auto;
    padding: 40px 24px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}
.hub-card {
    display: block;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 28px 24px;
    color: var(--text);
    text-decoration: none;
    transition: border-color 0.15s, transform 0.08s, box-shadow 0.15s;
}
.hub-card:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25),
                0 1px 3px rgba(74, 163, 255, 0.15);
}
.hub-card .hub-icon {
    font-size: 32px;
    margin-bottom: 12px;
    opacity: 0.9;
}
.hub-card h2 {
    margin: 0 0 8px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}
.hub-card p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}

/* Grille d'actions à l'intérieur d'une section */
.action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin-top: 8px;
}
.action-card {
    display: block;
    background: var(--panel2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 18px 16px;
    color: var(--text);
    text-decoration: none;
    transition: border-color 0.15s;
}
.action-card:hover { border-color: var(--accent); }
.action-card .action-icon {
    font-size: 22px;
    margin-bottom: 8px;
    opacity: 0.9;
}
.action-card h3 {
    margin: 0 0 6px;
    font-size: 14px;
    font-weight: 600;
}
.action-card p {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
}

/* Login page — centered card, dark theme */
body.centered {
    min-height: 100vh;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: radial-gradient(ellipse at top, #1a2130 0%, var(--bg) 60%);
}
.login-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 36px 32px 32px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45),
                0 2px 8px rgba(0, 0, 0, 0.3);
    box-sizing: border-box;
}
.login-logo {
    font-size: 32px;
    text-align: center;
    margin-bottom: 8px;
    opacity: 0.9;
}
.login-card h1 {
    margin: 0 0 6px;
    font-size: 20px;
    text-align: center;
    font-weight: 600;
}
.login-card .meta {
    margin: 0 0 24px;
    color: var(--muted);
    font-size: 12px;
    text-align: center;
}
.login-card .meta code {
    background: var(--panel2);
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 11px;
}
.login-card form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.login-card .field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.login-card label {
    font-size: 12px;
    color: var(--muted);
    font-weight: 500;
    letter-spacing: 0.2px;
}
.login-card input[type="text"],
.login-card input[type="password"] {
    background: var(--panel2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 11px 14px;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    width: 100%;
    box-sizing: border-box;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.login-card input[type="text"]:focus,
.login-card input[type="password"]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(74, 163, 255, 0.15);
}
.login-card .btn {
    margin-top: 8px;
    width: 100%;
    padding: 11px;
    font-size: 14px;
    font-weight: 600;
}
.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover { background: #3a93ef; }
.error-banner {
    background: rgba(229, 83, 83, 0.12);
    border: 1px solid rgba(229, 83, 83, 0.4);
    color: var(--red);
    padding: 10px 12px;
    border-radius: 6px;
    margin: 0 0 16px;
    font-size: 13px;
    text-align: center;
}
code {
    background: var(--panel2);
    padding: 1px 6px;
    border-radius: 3px;
    font-family: Menlo, monospace;
    font-size: 12px;
}
