/* Cloud — design moderne, mode sombre permanent, mobile-first.
 * Inspiré Proton Drive / Dropbox / Linear. */

:root {
    /* palette zinc + accent indigo, plus contemporain */
    --bg:           #09090b;
    --bg-elev:      #111114;
    --bg-elev-2:    #1a1a1f;
    --bg-hover:     #202028;
    --fg:           #fafafa;
    --fg-muted:     #a1a1aa;
    --fg-subtle:    #71717a;
    --accent:       #818cf8;
    --accent-strong:#6366f1;
    --accent-soft:  rgba(99, 102, 241, 0.12);
    --danger:       #f87171;
    --danger-strong:#ef4444;
    --success:      #34d399;
    --warning:      #fbbf24;
    --border:       #232328;
    --border-strong:#33333b;

    --radius-sm: 6px;
    --radius:    10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow:    0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.5);

    --sidebar-w: 240px;
    --header-h:  60px;
}

* { box-sizing: border-box; }
html, body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", "Inter",
                 Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
}
body { overflow-x: hidden; }

/* ─── typographie ──────────────────────────────────────────── */
h1, h2, h3, h4 { color: var(--fg); margin: 0 0 0.75rem; line-height: 1.3; font-weight: 600; }
h1 { font-size: 1.5rem; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; color: var(--fg-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; }
p { margin: 0 0 0.75rem; }
small, .muted { color: var(--fg-muted); font-size: 0.85rem; }

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 120ms ease;
}
a:hover { color: var(--accent-strong); }
a.subtle { color: var(--fg); }
a.subtle:hover { color: var(--accent); }

/* ─── header ───────────────────────────────────────────────── */
.header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1.25rem;
    background: rgba(17, 17, 20, 0.85);
    backdrop-filter: saturate(150%) blur(10px);
    -webkit-backdrop-filter: saturate(150%) blur(10px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 30;
    height: var(--header-h);
}
.header .brand {
    font-weight: 600;
    font-size: 1.05rem;
    letter-spacing: -0.01em;
    white-space: nowrap;
    /* Sur desktop : occupe la largeur de la sidebar pour que la search commence après. */
    min-width: calc(var(--sidebar-w) - 1.25rem);
    flex-shrink: 0;
}
.header .brand a { color: var(--fg); }
.header .brand a:hover { color: var(--accent); }
.header .search { flex: 1; max-width: 540px; position: relative; }
.header .search input {
    width: 100%;
    background: var(--bg-elev-2);
    border: 1px solid var(--border);
    color: var(--fg);
    padding: 0.55rem 0.9rem 0.55rem 2.25rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    transition: border-color 120ms ease, background 120ms ease;
}
.header .search input::placeholder { color: var(--fg-subtle); }
.header .search input:focus {
    outline: none;
    border-color: var(--accent-strong);
    background: var(--bg);
}
.header .search::before {
    content: "🔍";
    position: absolute;
    left: 0.75rem; top: 50%;
    transform: translateY(-50%);
    font-size: 0.85rem;
    opacity: 0.55;
    pointer-events: none;
}
.header .nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
}
.header .nav a {
    color: var(--fg-muted);
    padding: 0.4rem 0.6rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    transition: background 120ms ease, color 120ms ease;
}
.header .nav a:hover { background: var(--bg-hover); color: var(--fg); }

.badge {
    display: inline-block;
    background: var(--accent-strong);
    color: white;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    margin-left: 0.25rem;
    line-height: 1.4;
}

.link-btn {
    background: none; border: 0;
    color: var(--accent); cursor: pointer;
    padding: 0; font: inherit;
    transition: color 120ms ease;
}
.link-btn:hover { color: var(--accent-strong); }

/* burger mobile */
.burger {
    display: none;
    background: none; border: 0; color: var(--fg);
    font-size: 1.4rem; cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    transition: background 120ms ease;
}
.burger:hover { background: var(--bg-hover); }

/* ─── sidebar ──────────────────────────────────────────────── */
.sidebar {
    position: fixed;
    top: var(--header-h);
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    background: var(--bg-elev);
    border-right: 1px solid var(--border);
    padding: 1rem 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    overflow-y: auto;
    z-index: 20;
    transition: transform 200ms ease;
}
.sidebar a {
    color: var(--fg-muted);
    padding: 0.55rem 0.85rem;
    border-radius: var(--radius-sm);
    font-size: 0.92rem;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    transition: background 120ms ease, color 120ms ease;
}
.sidebar a:hover { background: var(--bg-hover); color: var(--fg); }
.sidebar a.active { background: var(--accent-soft); color: var(--accent); }

.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 15;
}

/* ─── content ──────────────────────────────────────────────── */
.content {
    margin-left: var(--sidebar-w);
    padding: 1.5rem 2rem 4rem;
    max-width: 1400px;
    transition: margin-left 200ms ease;
}

/* ─── messages flash ───────────────────────────────────────── */
.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.msg {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-left-width: 3px;
}
.msg-success { border-left-color: var(--success); }
.msg-error { border-left-color: var(--danger); }
.msg-warning { border-left-color: var(--warning); }
.msg-info { border-left-color: var(--accent); }

/* ─── tableaux ─────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); background: var(--bg-elev); }
table { width: 100%; border-collapse: collapse; min-width: 540px; }
th, td {
    text-align: left;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
th {
    color: var(--fg-subtle);
    font-weight: 500;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: var(--bg-elev);
    position: sticky;
    top: 0;
}
tr:last-child td { border-bottom: 0; }
tbody tr { transition: background 120ms ease; }
tbody tr:hover td { background: var(--bg-hover); }
.checkbox-cell { width: 36px; text-align: center; }
input[type="checkbox"] { accent-color: var(--accent-strong); cursor: pointer; }

td a.link-name {
    color: var(--fg);
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}
td a.link-name:hover { color: var(--accent); }

/* boutons inline dans cellules */
.row-actions { display: inline-flex; gap: 0.5rem; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.icon-btn {
    background: var(--bg-elev-2);
    border: 1px solid var(--border-strong);
    color: var(--fg);
    cursor: pointer;
    padding: 0;
    width: 40px; height: 40px;
    border-radius: var(--radius);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 140ms ease, color 140ms ease, border-color 140ms ease,
                transform 80ms ease, box-shadow 140ms ease;
    text-decoration: none;
}
.icon-btn svg { width: 20px; height: 20px; display: block; stroke-width: 2; }
.icon-btn:hover {
    background: var(--bg-hover);
    color: var(--fg);
    border-color: var(--fg-subtle);
    text-decoration: none;
    box-shadow: var(--shadow-sm);
}
.icon-btn:active { transform: scale(0.92); }
.icon-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-soft);
    border-color: var(--accent);
}
.icon-btn.download {
    color: var(--accent);
    border-color: rgba(99, 102, 241, 0.35);
    background: rgba(99, 102, 241, 0.08);
}
.icon-btn.download:hover {
    color: white;
    border-color: var(--accent-strong);
    background: var(--accent-strong);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.30);
}
.icon-btn.danger {
    color: var(--danger);
    border-color: rgba(248, 113, 113, 0.30);
    background: rgba(248, 113, 113, 0.06);
}
.icon-btn.danger:hover {
    color: white;
    border-color: var(--danger-strong);
    background: var(--danger-strong);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.30);
}

/* ─── boutons ──────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.55rem 1.1rem;
    background: var(--accent-strong);
    color: white;
    border-radius: var(--radius);
    border: 0;
    cursor: pointer;
    font: inherit;
    font-weight: 500;
    font-size: 0.9rem;
    transition: background 120ms ease, transform 80ms ease, box-shadow 120ms ease;
    text-decoration: none;
}
.btn:hover {
    background: var(--accent);
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}
.btn:active { transform: translateY(1px); }
.btn-secondary { background: var(--bg-elev-2); color: var(--fg); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg-hover); box-shadow: none; }
.btn-danger { background: var(--danger-strong); }
.btn-danger:hover { background: var(--danger); box-shadow: 0 4px 12px rgba(239, 68, 68, 0.25); }
.btn-ghost { background: transparent; color: var(--fg-muted); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--fg); box-shadow: none; }

/* ─── inputs ───────────────────────────────────────────────── */
input, select, textarea {
    background: var(--bg);
    color: var(--fg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.55rem 0.85rem;
    font: inherit;
    font-size: 0.9rem;
    transition: border-color 120ms ease, box-shadow 120ms ease;
}
input::placeholder { color: var(--fg-subtle); }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent-strong);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
label { display: block; color: var(--fg-muted); font-size: 0.85rem; margin-bottom: 0.25rem; }

/* ─── cartes ───────────────────────────────────────────────── */
.card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
    transition: border-color 120ms ease;
}
.card:hover { border-color: var(--border-strong); }
.card h2 { margin-bottom: 0.75rem; }

/* ─── dropzone ─────────────────────────────────────────────── */
.dropzone {
    border: 2px dashed var(--border-strong);
    background: var(--bg-elev);
    border-radius: var(--radius-lg);
    padding: 2.5rem 1.5rem;
    text-align: center;
    color: var(--fg-muted);
    margin-bottom: 1.5rem;
    transition: border-color 150ms ease, background 150ms ease;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}
.dropzone.drag {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--fg);
}
.dropzone .actions { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center; }
.dropzone form { display: inline-flex; gap: 0.5rem; flex-wrap: wrap; }

/* ─── breadcrumb ───────────────────────────────────────────── */
.breadcrumb {
    color: var(--fg-subtle);
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
}
.breadcrumb a { color: var(--fg-muted); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .sep { color: var(--fg-subtle); opacity: 0.6; }

/* ─── upload progress ──────────────────────────────────────── */
.upload-progress {
    position: fixed;
    bottom: 1rem; right: 1rem;
    background: var(--bg-elev);
    border: 1px solid var(--border-strong);
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    min-width: 300px;
    box-shadow: var(--shadow-lg);
    display: none;
    z-index: 50;
}
.upload-progress.active { display: block; }
.upload-progress progress {
    width: 100%;
    height: 8px;
    -webkit-appearance: none;
    appearance: none;
    border: 0;
    border-radius: 999px;
    overflow: hidden;
    background: var(--bg-elev-2);
}
.upload-progress progress::-webkit-progress-bar { background: var(--bg-elev-2); }
.upload-progress progress::-webkit-progress-value { background: var(--accent-strong); transition: width 120ms ease; }
.upload-progress progress::-moz-progress-bar { background: var(--accent-strong); }

/* ─── page header (titre + actions) ────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin: 0 0 1.5rem;
}
.page-header h1 { margin: 0; }
.page-header .actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }

/* ─── empty state ──────────────────────────────────────────── */
.empty-state {
    background: var(--bg-elev);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--fg-muted);
}
.empty-state .ico { font-size: 2.5rem; opacity: 0.5; margin-bottom: 0.5rem; line-height: 1; }
.empty-state h2 { color: var(--fg); margin-bottom: 0.5rem; font-size: 1.05rem; }
.empty-state p { margin: 0; font-size: 0.9rem; }

/* ─── pill / status ────────────────────────────────────────── */
.pill {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--bg-elev-2);
    color: var(--fg-muted);
    border: 1px solid var(--border);
}
.pill-success { background: rgba(52, 211, 153, 0.10); color: var(--success); border-color: rgba(52, 211, 153, 0.3); }
.pill-danger  { background: rgba(248, 113, 113, 0.10); color: var(--danger); border-color: rgba(248, 113, 113, 0.3); }
.pill-warning { background: rgba(251, 191, 36, 0.10); color: var(--warning); border-color: rgba(251, 191, 36, 0.3); }
.pill-info    { background: var(--accent-soft); color: var(--accent); border-color: rgba(99, 102, 241, 0.3); }

/* ─── form layout ──────────────────────────────────────────── */
.fields { display: flex; flex-direction: column; gap: 0.85rem; }
.fields label { font-weight: 500; color: var(--fg); font-size: 0.85rem; margin-bottom: 0.3rem; display: block; }
.fields .field { }
.fields input, .fields select, .fields textarea { width: 100%; }
.fields .help { color: var(--fg-muted); font-size: 0.8rem; margin-top: 0.3rem; }
.fields .row { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.fields .row > * { flex: 1; min-width: 200px; }

/* ─── barre de stockage (admin) ────────────────────────────── */
.storage-bar {
    width: 100%;
    height: 28px;
    background: var(--bg-elev-2);
    border-radius: 999px;
    overflow: hidden;
    display: flex;
    border: 1px solid var(--border);
    margin: 0.5rem 0 0.75rem;
}
.storage-bar .seg {
    height: 100%;
    transition: width 200ms ease;
}
.storage-bar .seg.cloud { background: linear-gradient(90deg, var(--accent-strong), var(--accent)); }
.storage-bar .seg.other { background: var(--bg-hover); }
.storage-bar .seg.free { background: transparent; }

.storage-legend { display: flex; gap: 1.25rem; flex-wrap: wrap; font-size: 0.85rem; color: var(--fg-muted); }
.storage-legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 0.4rem; vertical-align: middle; }
.storage-legend .dot.cloud { background: var(--accent-strong); }
.storage-legend .dot.other { background: var(--bg-hover); }
.storage-legend .dot.free { background: transparent; border: 1px solid var(--border-strong); }

/* ─── stat grid (admin) ────────────────────────────────────── */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}
.stat-card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
}
.stat-card .label { color: var(--fg-muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.5rem; }
.stat-card .value { font-size: 1.6rem; font-weight: 600; color: var(--fg); line-height: 1.2; }

/* ─── code ─────────────────────────────────────────────────── */
.code {
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    background: var(--bg-elev-2);
    color: var(--fg);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.85em;
    border: 1px solid var(--border);
}

/* ─── login ────────────────────────────────────────────────── */
.login-card {
    max-width: 400px;
    margin: 4rem auto;
    background: var(--bg-elev);
    padding: 2.25rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}
.login-card h1 { margin-bottom: 1.5rem; text-align: center; }
.login-card form { display: flex; flex-direction: column; gap: 0.75rem; }
.login-card label { display: block; color: var(--fg); font-size: 0.85rem; margin-bottom: 0.35rem; font-weight: 500; }
.login-card .help { color: var(--fg-muted); font-size: 0.85rem; margin-top: 1.25rem; text-align: center; }
.login-card .btn { margin-top: 0.5rem; }

/* ─── responsive ───────────────────────────────────────────── */
@media (max-width: 900px) {
    .header { padding: 0.65rem 1rem; gap: 0.5rem; }
    .header .brand { min-width: 0; }
    .header .search { max-width: none; }
    .header .nav a { padding: 0.4rem; }
    .burger { display: inline-flex; }

    .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
    .sidebar.open { transform: translateX(0); }
    .sidebar.open ~ .sidebar-overlay { display: block; }

    .content { margin-left: 0; padding: 1rem 1rem 4rem; }
}

@media (max-width: 600px) {
    .header .brand { font-size: 1rem; }
    .header .search input { padding-left: 2rem; }
    .hide-sm { display: none; }
    .dropzone { padding: 1.5rem 1rem; }
    .login-card { margin: 2rem 1rem; padding: 1.5rem; }
    h1 { font-size: 1.25rem; }
    .upload-progress { left: 1rem; right: 1rem; min-width: 0; }
}
