/* ==========================================================================
   Transferts — Olivier Moreau
   DA « dashboard admin » sombre (type Metronic) : fond neutre profond,
   cartes arrondies, pilules, accent bleu périwinkle, badges pastel.
   Typo : Plus Jakarta Sans (variable), auto-hébergée. Icônes : Lucide.
   ========================================================================== */

@font-face {
    font-family: 'Plus Jakarta Sans';
    font-style: normal;
    font-weight: 200 800;
    font-display: swap;
    src: url('/assets/fonts/jakarta-var-latin.woff2') format('woff2');
}

:root {
    --bg: #0d0e12;
    --surface: #16171e;
    --surface-2: #1d1f28;
    --border: rgba(255, 255, 255, .06);
    --border-strong: rgba(255, 255, 255, .12);
    --text: #f2f3f7;
    --muted: #878d99;
    --primary: #0084e4;
    --primary-soft: rgba(0, 132, 228, .14);
    --green: #55d98b;
    --green-soft: rgba(85, 217, 139, .13);
    --red: #f88a80;
    --red-soft: rgba(248, 138, 128, .12);
    --orange: #f5b263;
    --orange-soft: rgba(245, 178, 99, .13);
    --font: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    --font-mono: ui-monospace, 'SF Mono', 'Cascadia Mono', Menlo, monospace;
    --radius: 20px;
    --ease-out: cubic-bezier(.16, 1, .3, 1);
}

* { box-sizing: border-box; }

html { color-scheme: dark; }

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 15.5px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

.mono { font-family: var(--font-mono); font-size: .84em; letter-spacing: .01em; }

.icon { vertical-align: -.18em; flex: none; }

/* --------------------------------------------------------------------------
   Arrière-plan : deux lueurs très discrètes, fond flat
   -------------------------------------------------------------------------- */

.backdrop { position: fixed; inset: 0; z-index: -1; overflow: hidden; }
.glow { position: absolute; border-radius: 50%; filter: blur(110px); }
.glow-a {
    width: 720px; height: 720px;
    top: -380px; left: 50%;
    transform: translateX(-50%);
    background: radial-gradient(circle, rgba(0, 132, 228, .09), transparent 65%);
}
.glow-b {
    width: 520px; height: 520px;
    right: -240px; bottom: -220px;
    background: radial-gradient(circle, rgba(0, 132, 228, .05), transparent 65%);
}

/* --------------------------------------------------------------------------
   Animation d'entrée
   -------------------------------------------------------------------------- */

.reveal {
    opacity: 0;
    transform: translateY(14px);
    animation: rise .6s var(--ease-out) forwards;
    animation-delay: var(--d, 0s);
}
@keyframes rise {
    to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
    .reveal { animation: none; opacity: 1; transform: none; }
}

/* --------------------------------------------------------------------------
   Marque
   -------------------------------------------------------------------------- */

.brand {
    display: flex;
    align-items: center;
    gap: .65rem;
    color: var(--text);
}
.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px; height: 34px;
    border-radius: 11px;
    background: var(--primary-soft);
    color: var(--primary);
    flex: none;
}
.brand-mark img { display: block; }
.brand-logo {
    height: 34px;
    width: auto;
    opacity: .95;
}

/* --------------------------------------------------------------------------
   Structure
   -------------------------------------------------------------------------- */

.container {
    max-width: 880px;
    margin: 0 auto;
    padding: 1.5rem 1.25rem 5rem;
}
.container-narrow { max-width: 660px; }

.topbar {
    max-width: 880px;
    margin: 0 auto;
    padding: 1.3rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}
.topnav { display: flex; align-items: center; gap: 1.1rem; }

.page-title {
    font-weight: 800;
    font-size: clamp(1.6rem, 4vw, 2.1rem);
    letter-spacing: -.03em;
    margin: 1rem 0 1.4rem;
}

/* --------------------------------------------------------------------------
   Composants
   -------------------------------------------------------------------------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    background: #fff;
    color: #14151b;
    font-family: var(--font);
    font-weight: 700;
    font-size: .92rem;
    padding: .68rem 1.4rem;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    text-decoration: none;
    transition: transform .18s var(--ease-out), box-shadow .18s var(--ease-out), opacity .18s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(0, 0, 0, .45); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-small { padding: .48rem 1.05rem; font-size: .86rem; }
.btn-block { width: 100%; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { box-shadow: 0 8px 24px rgba(0, 132, 228, .35); }

.btn-ghost {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: .48rem 1.05rem;
    font-family: var(--font);
    font-weight: 600;
    font-size: .86rem;
    cursor: pointer;
    transition: border-color .18s, background .18s;
}
.btn-ghost:hover { border-color: var(--border-strong); background: var(--surface); }

.link-btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    background: none;
    border: none;
    padding: 0;
    color: var(--muted);
    font-family: var(--font);
    font-weight: 600;
    font-size: .9rem;
    cursor: pointer;
    text-decoration: none;
}
.link-btn:hover { color: var(--text); }

.alert {
    border-radius: 14px;
    padding: .85rem 1.15rem;
    margin: 0 0 1.2rem;
    font-size: .93rem;
    font-weight: 500;
}
.alert-ok  { background: var(--green-soft); border: 1px solid rgba(85, 217, 139, .3); color: var(--green); }
.alert-err { background: var(--red-soft); border: 1px solid rgba(248, 138, 128, .32); color: var(--red); }

.badge {
    display: inline-flex;
    align-items: center;
    gap: .32rem;
    font-size: .76rem;
    font-weight: 700;
    padding: .26rem .7rem;
    border-radius: 999px;
    white-space: nowrap;
}
.badge-ok      { background: var(--green-soft); color: var(--green); }
.badge-wait    { background: rgba(255, 255, 255, .06); color: var(--muted); }
.badge-expired { background: var(--orange-soft); color: var(--orange); }

/* --------------------------------------------------------------------------
   Formulaires
   -------------------------------------------------------------------------- */

label, .field { display: block; margin: 0 0 1.25rem; font-weight: 600; font-size: .92rem; }
.field-label { display: block; margin-bottom: .5rem; }
label > input, label > textarea { margin-top: .5rem; }
.optional { color: var(--muted); font-weight: 500; }

input[type="text"], input[type="email"], input[type="password"], textarea {
    display: block;
    width: 100%;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    font: inherit;
    font-weight: 500;
    padding: .68rem .95rem;
    transition: border-color .18s, box-shadow .18s;
}
input::placeholder, textarea::placeholder { color: #5c626e; font-weight: 500; }
input:focus, textarea:focus, .dropzone:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 132, 228, .18);
}
textarea { resize: vertical; }

.form-foot {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 1.6rem;
}
.upload-status { color: var(--muted); font-size: .87rem; font-weight: 500; }

/* Zone de dépôt */
.dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .1rem;
    border: 1.5px dashed var(--border-strong);
    border-radius: 16px;
    padding: 2rem 1rem;
    text-align: center;
    cursor: pointer;
    color: var(--muted);
    font-weight: 500;
    transition: border-color .18s, background .18s, color .18s;
}
.dropzone strong { color: var(--text); font-weight: 700; }
.dropzone:hover, .dropzone.dragover {
    border-color: var(--primary);
    background: var(--primary-soft);
    color: var(--text);
}
.dz-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px; height: 46px;
    border-radius: 14px;
    background: var(--primary-soft);
    color: var(--primary);
    margin-bottom: .7rem;
}

/* Pastille d'icône de fichier */
.file-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px; height: 40px;
    border-radius: 12px;
    background: var(--primary-soft);
    color: var(--primary);
    flex: none;
}

/* Liste de fichiers (upload et téléchargement) */
.file-list {
    list-style: none;
    margin: .8rem 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: .55rem;
}
.file-row, .upload-row {
    display: flex;
    align-items: center;
    gap: .9rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: .8rem 1rem;
}
.file-row .btn { margin-left: auto; }
.file-row .file-info { flex: 1; }
.file-info { display: flex; flex-direction: column; gap: .05rem; min-width: 0; }
.file-name { font-weight: 600; overflow-wrap: anywhere; }
.file-size { color: var(--muted); }

.upload-row { flex-wrap: wrap; }
.upload-row .file-info { flex: 1; }
.upload-progress {
    flex: 1 1 100%;
    height: 5px;
    border-radius: 99px;
    background: var(--surface-2);
    overflow: hidden;
}
.upload-progress-bar {
    height: 100%;
    width: 0;
    background: var(--primary);
    border-radius: 99px;
    transition: width .25s var(--ease-out);
}
.upload-row.is-done .upload-progress { display: none; }
.upload-state { color: var(--muted); font-size: .82rem; font-weight: 700; white-space: nowrap; }
.upload-row.is-done .upload-state { color: var(--green); }
.upload-row.is-error .upload-state { color: var(--red); }
.upload-remove {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    padding: .1rem .35rem;
}
.upload-remove:hover { color: var(--red); }

/* Lignes destinataires */
.recipient-row {
    display: flex;
    gap: .6rem;
    margin-bottom: .6rem;
    align-items: center;
}
.recipient-row input { flex: 1; }
.row-remove {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
    padding: .1rem .3rem;
    flex: none;
}
.row-remove:hover { color: var(--red); }

/* --------------------------------------------------------------------------
   Connexion
   -------------------------------------------------------------------------- */

.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}
.login-card { width: 100%; max-width: 400px; padding: 2.2rem; }
.login-card .brand { justify-content: center; margin-bottom: 1.5rem; }
.login-title {
    font-size: .82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .1em;
    text-align: center;
    color: var(--muted);
    margin: 0 0 1.6rem;
}

/* --------------------------------------------------------------------------
   Admin : liste des envois
   -------------------------------------------------------------------------- */

.transfer-card { margin-bottom: 1rem; }
.transfer-title {
    font-weight: 800;
    font-size: 1.18rem;
    letter-spacing: -.02em;
    margin: 0 0 .25rem;
}
.transfer-meta { color: var(--muted); font-size: .88rem; font-weight: 500; margin: 0 0 1rem; }
.recipient-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: .45rem;
}
.recipient-list li {
    display: flex;
    align-items: center;
    gap: .7rem;
    flex-wrap: wrap;
    font-size: .93rem;
    border-top: 1px solid var(--border);
    padding-top: .6rem;
}
.r-name { font-weight: 700; }
.r-email { color: var(--muted); }
.recipient-list .badge { margin-left: auto; }

.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--muted);
}
.empty-state .btn { margin-top: .9rem; }

/* --------------------------------------------------------------------------
   Page de téléchargement
   -------------------------------------------------------------------------- */

.dl { padding-top: 2.2rem; }
.dl-hero { margin: 2.8rem 0 2rem; }
.dl-kicker {
    color: var(--muted);
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .09em;
    margin: 0 0 .7rem;
}
.dl-title {
    font-weight: 800;
    font-size: clamp(1.7rem, 5vw, 2.5rem);
    letter-spacing: -.03em;
    line-height: 1.12;
    margin: 0 0 .9rem;
    overflow-wrap: anywhere;
}
.dl-meta {
    display: inline-flex;
    align-items: center;
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 600;
    font-size: .95rem;
    padding: .35rem .9rem;
    border-radius: 999px;
    margin: 0;
}
.dl-message {
    margin: 1.4rem 0 0;
    padding: 1rem 1.25rem;
    border-left: 3px solid var(--primary);
    background: var(--surface);
    border-radius: 0 14px 14px 0;
    color: var(--text);
    font-weight: 500;
}
.dl-foot {
    color: var(--muted);
    font-size: .84rem;
    font-weight: 500;
    margin-top: 2rem;
}

/* --------------------------------------------------------------------------
   Page d'erreur
   -------------------------------------------------------------------------- */

.center-page {
    min-height: 80vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}
.err-code {
    display: inline-block;
    background: var(--red-soft);
    color: var(--red);
    font-weight: 700;
    padding: .3rem .9rem;
    border-radius: 999px;
    letter-spacing: .2em;
    margin: 2.2rem 0 0;
}
.err-heading {
    font-weight: 800;
    font-size: clamp(1.7rem, 5vw, 2.4rem);
    letter-spacing: -.03em;
    margin: .7rem 0 .5rem;
}
.err-text { color: var(--muted); font-weight: 500; max-width: 44ch; }

/* --------------------------------------------------------------------------
   Navigation
   -------------------------------------------------------------------------- */

.brand-link { text-decoration: none; flex: none; }
.topbar { flex-wrap: wrap; }
.topnav { flex: 1; }
.topbar-right { display: flex; align-items: center; gap: .8rem; }

.navlink {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    color: var(--muted);
    text-decoration: none;
    font-weight: 600;
    font-size: .92rem;
    padding: .4rem .1rem;
    border-bottom: 2px solid transparent;
    transition: color .15s;
}
.navlink:hover { color: var(--text); }
.navlink.is-active { color: var(--text); border-bottom-color: var(--primary); }
.navlink-user { color: var(--text); }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px; height: 34px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface-2);
    color: var(--muted);
    cursor: pointer;
    transition: color .15s, border-color .15s, background .15s;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }
.icon-btn.danger:hover { color: var(--red); border-color: rgba(248, 138, 128, .4); background: var(--red-soft); }
.icon-btn.copied { color: var(--green); border-color: rgba(85, 217, 139, .4); background: var(--green-soft); }
.inline-form { display: inline-flex; margin: 0; }

/* --------------------------------------------------------------------------
   En-tête de page + recherche
   -------------------------------------------------------------------------- */

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.4rem;
}
.page-head .page-title { margin: 0; }
.search { position: relative; display: inline-flex; align-items: center; }
.search .icon { position: absolute; left: .8rem; color: var(--muted); pointer-events: none; }
.search input { padding-left: 2.4rem; min-width: 240px; }

.card-title {
    display: flex;
    align-items: center;
    gap: .55rem;
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 1.1rem;
}
.card-title .icon { color: var(--primary); }
.muted-note { color: var(--muted); font-size: .9rem; padding: .3rem 0; list-style: none; }
.section-intro { color: var(--muted); font-size: .92rem; margin: -.4rem 0 1.4rem; }

/* --------------------------------------------------------------------------
   Cartes d'envoi : actions et propriétaire
   -------------------------------------------------------------------------- */

.transfer-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}
.transfer-head-main { min-width: 0; }
.transfer-title a { color: inherit; text-decoration: none; }
.transfer-title a:hover { color: var(--primary); }
.card-actions { display: flex; align-items: center; gap: .5rem; flex: none; }
.owner-tag { display: inline-flex; align-items: center; gap: .25rem; color: var(--muted); }

/* --------------------------------------------------------------------------
   Page détail d'un envoi
   -------------------------------------------------------------------------- */

.detail-meta { color: var(--muted); margin: -.6rem 0 1.4rem; }
.card + .card, .card + section.card, section.card + section.card { margin-top: 1rem; }
.add-files { margin-top: 1.2rem; padding-top: 1.2rem; border-top: 1px solid var(--border); }
.add-recipient { display: flex; gap: .55rem; margin-top: 1.2rem; padding-top: 1.2rem; border-top: 1px solid var(--border); flex-wrap: wrap; }
.add-recipient input[type="text"] { flex: 1 1 140px; }
.add-recipient input[type="email"] { flex: 2 1 200px; }
.recipient-list.detail li { align-items: center; }
.recipient-list.detail .r-main { display: flex; flex-direction: column; }
.recipient-list.detail .r-actions { display: flex; gap: .4rem; margin-left: auto; }
.recipient-list.detail .badge { margin-left: 0; }

.history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.history li {
    display: flex;
    align-items: baseline;
    gap: .5rem;
    flex-wrap: wrap;
    font-size: .92rem;
    border-top: 1px solid var(--border);
    padding-top: .5rem;
}
.history-date { color: var(--primary); }
.history-file { font-weight: 600; overflow-wrap: anywhere; }
.history .muted { color: var(--muted); }

/* --------------------------------------------------------------------------
   Rôles, grilles, select
   -------------------------------------------------------------------------- */

.badge-role-admin { background: var(--primary-soft); color: var(--primary); }
.badge-role-member { background: rgba(255, 255, 255, .06); color: var(--muted); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.grid-2 > label { margin-bottom: 1rem; }

select {
    display: block;
    width: 100%;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    font: inherit;
    font-weight: 500;
    padding: .68rem .95rem;
    margin-top: .5rem;
    cursor: pointer;
}
select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0, 132, 228, .18); }
.role-field { margin-bottom: 0; }

/* --------------------------------------------------------------------------
   Utilisateurs
   -------------------------------------------------------------------------- */

.user-card { margin-bottom: .9rem; }
.user-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.user-id { display: flex; align-items: center; gap: .8rem; min-width: 0; }
.user-avatar {
    display: inline-flex; align-items: center; justify-content: center;
    width: 42px; height: 42px; border-radius: 12px;
    background: var(--primary-soft); color: var(--primary); flex: none;
}
.user-name { font-weight: 700; display: flex; align-items: center; gap: .5rem; }
.you-tag {
    font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
    color: var(--primary); background: var(--primary-soft); padding: .1rem .45rem; border-radius: 99px;
}
.user-sub { display: block; color: var(--muted); font-size: .85rem; }
.user-meta { display: flex; align-items: center; gap: .8rem; flex: none; }
.user-count { color: var(--muted); font-size: .85rem; }
.user-edit { margin-top: 1rem; border-top: 1px solid var(--border); padding-top: .8rem; }
.user-edit summary {
    cursor: pointer; color: var(--muted); font-weight: 600; font-size: .9rem;
    display: inline-flex; align-items: center; gap: .4rem; list-style: none;
}
.user-edit summary::-webkit-details-marker { display: none; }
.user-edit summary:hover { color: var(--text); }
.user-edit-body { margin-top: 1rem; display: flex; flex-direction: column; gap: 1rem; }
.inline-set { display: flex; gap: .55rem; align-items: center; flex-wrap: wrap; }
.inline-set input { flex: 1 1 200px; }
.link-btn.danger { color: var(--red); }
.link-btn.danger:hover { color: #ffb3ad; }
.delete-user { margin: 0; }

/* --------------------------------------------------------------------------
   Carnet d'adresses
   -------------------------------------------------------------------------- */

.add-contact { display: flex; gap: .55rem; flex-wrap: wrap; align-items: center; padding: 1rem 1.1rem; }
.add-contact input[type="text"] { flex: 1 1 160px; }
.add-contact input[type="email"] { flex: 2 1 200px; }
.contact-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .55rem; }
.contact-row { display: flex; align-items: center; gap: .9rem; padding: .8rem 1.1rem; }
.contact-avatar {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: 11px;
    background: var(--surface-2); color: var(--muted); flex: none;
}
.contact-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.contact-name { font-weight: 600; }
.contact-email { color: var(--muted); }
.contact-count { color: var(--muted); font-size: .82rem; white-space: nowrap; }

@media (max-width: 720px) {
    .topnav { order: 3; flex-basis: 100%; }
    .search input { min-width: 0; }
    .page-head .search, .page-head .search input { width: 100%; }
    .grid-2 { grid-template-columns: 1fr; }
    .user-head { align-items: flex-start; }
}

@media (max-width: 560px) {
    .file-row { flex-wrap: wrap; }
    .file-row .btn { margin-left: 0; flex: 1 1 100%; }
    .recipient-list .badge { margin-left: 0; }
    .dl-meta { border-radius: 14px; font-size: .85rem; }
    .recipient-list.detail .r-actions { margin-left: 0; }
}
