/* Hyrule France — thème sombre par défaut, clair si le système le demande. */
:root {
  --bg: #0f1216;
  --surface: #171b21;
  --surface-2: #1f252d;
  --border: #2a313b;
  --text: #e6e9ee;
  --muted: #9aa4b2;
  --accent: #4fb7a0;
  --accent-strong: #3a9c87;
  --danger: #e26d6d;
  --discord: #5865f2;
  --radius: 12px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f4f6f8; --surface: #ffffff; --surface-2: #eef1f4; --border: #d8dde3;
    --text: #1a1f26; --muted: #5d6773; --accent: #237a68; --accent-strong: #1c6455;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
}
a { color: var(--accent); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Boutons */
.btn {
  display: inline-flex; align-items: center; gap: .5em; justify-content: center;
  padding: .55em 1em; border-radius: 9px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); font: inherit; cursor: pointer;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #0b1310; font-weight: 600; }
.btn-primary:hover { background: var(--accent-strong); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--danger); }
.btn-discord { background: var(--discord); border-color: var(--discord); color: #fff; font-weight: 600; padding: .8em 1.4em; font-size: 1.05em; }
.btn-discord:hover { filter: brightness(1.08); border-color: var(--discord); }
.btn-sm { padding: .3em .6em; font-size: .85em; }

/* Connexion */
.login-page { display: grid; place-items: center; padding: 16px;
  background: radial-gradient(1200px 600px at 50% -10%, rgba(79,183,160,.15), transparent 60%), var(--bg); }
.login-card {
  width: 100%; max-width: 420px; text-align: center; padding: 40px 28px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.login-card h1 { margin: 12px 0 4px; font-size: 1.8em; letter-spacing: .02em; }
.subtitle { margin: 0 0 24px; color: var(--muted); }
.hint { margin: 22px 0 0; color: var(--muted); font-size: .88em; }
.alert {
  margin: 0 0 20px; padding: 12px 14px; border-radius: 10px; text-align: left;
  background: rgba(226,109,109,.12); border: 1px solid rgba(226,109,109,.4); color: var(--text);
}

/* En-tête */
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 16px; background: color-mix(in srgb, var(--surface) 92%, transparent);
  border-bottom: 1px solid var(--border); backdrop-filter: blur(6px);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 700; font-size: 1.1em; }
.user { display: flex; align-items: center; gap: 10px; min-width: 0; }
.user img { border-radius: 50%; flex: none; }
#user-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 30vw; }

/* Drive */
.drive { max-width: 1100px; margin: 0 auto; padding: 16px; }
.breadcrumbs { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin: 4px 0 14px; font-size: 1.05em; }
.breadcrumbs a { color: var(--muted); text-decoration: none; padding: 2px 6px; border-radius: 6px; }
.breadcrumbs a:hover { color: var(--text); background: var(--surface-2); }
.breadcrumbs a:last-child { color: var(--text); font-weight: 600; }
.breadcrumbs .sep { color: var(--muted); opacity: .6; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.toolbar input[type="search"], .toolbar select, .ask input {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 9px; padding: .55em .8em;
}
.toolbar input[type="search"] { flex: 1 1 220px; min-width: 0; }
.manage { display: flex; gap: 8px; flex-wrap: wrap; }

.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.files { width: 100%; border-collapse: collapse; table-layout: fixed; }
.files th, .files td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); }
.files tr:last-child td { border-bottom: none; }
.files th { font-size: .82em; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; cursor: pointer; user-select: none; }
.files th.sorted::after { content: " ▾"; }
.files th.sorted.asc::after { content: " ▴"; }
.files tbody tr:hover { background: var(--surface-2); }
.col-size { width: 110px; } .col-date { width: 170px; } .col-actions { width: 210px; cursor: default !important; }
.files td.col-size, .files td.col-date { color: var(--muted); font-variant-numeric: tabular-nums; }
.name-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.name-cell button, .name-cell a {
  all: unset; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text);
}
.name-cell button:hover, .name-cell a:hover { color: var(--accent); text-decoration: underline; }
.name-cell button:focus-visible, .name-cell a:focus-visible { outline: 2px solid var(--accent); }
.icon { flex: none; width: 22px; text-align: center; }
.actions { display: flex; gap: 6px; justify-content: flex-end; }
.empty { padding: 28px; text-align: center; color: var(--muted); margin: 0; }

/* Uploads */
.uploads { display: grid; gap: 8px; margin-bottom: 12px; }
.upload-item { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; font-size: .9em; }
.upload-item .row { display: flex; justify-content: space-between; gap: 10px; }
.upload-item .row span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-item progress { width: 100%; height: 6px; margin-top: 6px; accent-color: var(--accent); }
.upload-item.error { border-color: var(--danger); }
.dropzone {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center;
  background: rgba(15,18,22,.8); border: 3px dashed var(--accent); font-size: 1.4em; font-weight: 600;
}
.dropzone[hidden] { display: none; }

/* Dialogues */
dialog { color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 0; }
dialog::backdrop { background: rgba(0,0,0,.65); }
.preview { width: min(1100px, 96vw); max-height: 92vh; }
.preview-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.preview-head strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-head > div { display: flex; gap: 6px; flex: none; }
.preview-body { padding: 12px; display: grid; place-items: center; max-height: calc(92vh - 60px); overflow: auto; }
.preview-body img, .preview-body video { max-width: 100%; max-height: calc(92vh - 90px); }
.preview-body audio { width: min(600px, 100%); }
.preview-body iframe { width: 100%; height: calc(92vh - 90px); border: 0; background: #fff; border-radius: 6px; }
.preview-body pre { width: 100%; margin: 0; white-space: pre-wrap; word-break: break-word; font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.ask { width: min(420px, 92vw); }
.ask form { padding: 18px; display: grid; gap: 12px; }
.ask p { margin: 0; }
.ask-actions { display: flex; justify-content: flex-end; gap: 8px; }

.toast {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 30;
  background: var(--surface-2); border: 1px solid var(--border); padding: 10px 16px; border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,.35); max-width: calc(100vw - 32px);
}

/* Mobile */
@media (max-width: 720px) {
  .col-date, .files td.col-date { display: none; }
  .col-size { width: 80px; }
  .col-actions { width: 96px; }
  .files th, .files td { padding: 10px 8px; }
  .actions .label { display: none; }
  #user-name { display: none; }
  .brand span { font-size: .95em; }
}
