/* ============================================================
   Maestrow Drive — drive.css
   Réutilise l'identité auth.css (Space Grotesk / Instrument Sans,
   variables couleurs, coins peu arrondis, aucune ombre portée).
   Ce fichier est chargé APRÈS auth.css : il ne redéfinit pas les
   variables ni les polices, seulement les composants propres au Drive.
   ============================================================ */

*,*::before,*::after{box-sizing:border-box;}
html{overflow-x:clip;}
body{
  margin:0;
  min-height:100vh;
  background:var(--bg-soft);
}

/* ---------- En-tête ---------- */
.mw-drive__header{
  background:#fff;
  border-bottom:1px solid var(--line);
}
.mw-drive__bar{
  max-width:1200px;margin:0 auto;
  padding:14px 24px;
  display:flex;align-items:center;justify-content:space-between;
  gap:16px;
}
.mw-drive__brand{display:inline-flex;align-items:center;gap:12px;}
.mw-drive__brand img{height:28px;width:auto;}
.mw-drive__title{
  font-family:"Space Grotesk",sans-serif;font-weight:700;font-size:16px;
  padding-left:12px;
  border-left:1px solid var(--line-strong);
}
.mw-drive__who{display:flex;align-items:center;gap:14px;font-size:14px;color:var(--muted);}
.mw-drive__who strong{color:var(--ink);font-weight:600;}

/* ---------- Corps ---------- */
.mw-drive__main{max-width:1200px;margin:0 auto;padding:28px 24px 64px;}

/* ---------- État : pas d'accès / non connecté ---------- */
.mw-drive__blocked{
  max-width:520px;margin:60px auto 0;
  background:#fff;border:1px solid var(--line);border-radius:12px;
  overflow:hidden;
  text-align:center;
}
.mw-drive__blocked .mw-accentbar{margin-bottom:0;}
.mw-drive__blocked-body{padding:36px 30px;}
.mw-drive__blocked-body h1{font-size:20px;margin-bottom:10px;}
.mw-drive__blocked-body p{font-size:14.5px;color:var(--muted);}

/* ---------- Barre de stockage ---------- */
.mw-storage{
  background:#fff;
  border:1px solid var(--line);
  border-radius:10px;
  padding:16px 20px;
  margin-bottom:20px;
  display:flex;
  align-items:center;
  gap:20px;
  flex-wrap:wrap;
}
.mw-storage__info{flex:1 1 220px;min-width:200px;}
.mw-storage__label{font-size:12px;text-transform:uppercase;letter-spacing:0.04em;color:var(--muted);font-weight:700;margin-bottom:6px;}
.mw-storage__text{font-size:14px;color:var(--ink);}
.mw-storage__reserved{color:var(--muted);font-size:12.5px;}
.mw-storage__bar{
  flex:2 1 320px;
  /* La barre garde une hauteur fixe : `align-self:center` neutralise un
     éventuel `align-items:stretch` du conteneur, et `min-height` empêche
     tout écrasement. */
  align-self:center;
  height:8px;
  min-height:8px;
  border-radius:4px;
  background:var(--bg-soft);
  border:1px solid var(--line);
  overflow:hidden;
  min-width:180px;
}
.mw-storage__fill{
  height:100%;
  background:linear-gradient(90deg,#0d9488,#14b8a6);
  border-radius:4px;
  transition:width .25s ease;
}
.mw-storage__fill.is-full{background:var(--err-ink);}

/* ---------- Barre d'outils ---------- */
.mw-toolbar-drive{
  display:flex;align-items:center;justify-content:space-between;
  gap:12px;flex-wrap:wrap;
  margin-bottom:18px;
}
.mw-toolbar-drive__actions{display:flex;gap:10px;flex-wrap:wrap;}

/* ---------- Fil d'Ariane ---------- */
.mw-breadcrumb{
  display:flex;align-items:center;flex-wrap:wrap;
  gap:6px;
  margin-bottom:18px;
  font-size:14px;
}
.mw-breadcrumb button{
  color:var(--muted);
  font-weight:600;
  padding:4px 6px;
  border-radius:6px;
  transition:background .15s ease,color .15s ease;
}
.mw-breadcrumb button:hover{background:var(--bg-soft);color:var(--ink);}
.mw-breadcrumb button.is-current{color:var(--ink);cursor:default;}
.mw-breadcrumb button.is-current:hover{background:none;}
.mw-breadcrumb__sep{color:var(--line-strong);}

/* ---------- Zone de dépôt ---------- */
.mw-dropzone{
  border:1px solid var(--line);
  border-radius:10px;
  background:#fff;
  min-height:320px;
  padding:20px;
  position:relative;
  transition:border-color .15s ease,background .15s ease;
}
.mw-dropzone.is-dragover{
  border-color:var(--blue);
  background:#f4f7ff;
}
.mw-dropzone.is-dragover::after{
  content:"Dépose les fichiers ici";
  position:absolute;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  font-family:"Space Grotesk",sans-serif;
  font-weight:700;
  font-size:18px;
  color:var(--blue);
  background:rgba(244,247,255,0.9);
  border-radius:10px;
  pointer-events:none;
}

/* ---------- Grille de fichiers ---------- */
.mw-grid{
  display:grid;
  grid-template-columns:repeat(auto-fill,minmax(160px,1fr));
  gap:12px;
}
.mw-item{
  position:relative;
  border:1px solid var(--line);
  border-radius:8px;
  padding:14px 12px 12px;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:8px;
  text-align:center;
  cursor:pointer;
  user-select:none;
  transition:background .15s ease,border-color .15s ease;
}
.mw-item:hover{background:var(--bg-soft);}
.mw-item.is-selected{border-color:var(--blue);background:#f4f7ff;}
.mw-item__icon{
  width:44px;height:44px;
  display:flex;align-items:center;justify-content:center;
  font-size:26px;
  flex:0 0 auto;
}
/* Miniature d'image : l'<img> couvre le cadre ; l'emoji de repli est
   dessous et réapparaît si l'image échoue (onerror → .is-fallback). */
.mw-item__thumb{
  position:relative;
  width:100%;
  aspect-ratio:4/3;
  border-radius:8px;
  overflow:hidden;
  background:var(--bg-soft);
  border:1px solid var(--line);
  display:flex;align-items:center;justify-content:center;
  flex:0 0 auto;
}
.mw-item__thumb-fallback{font-size:26px;line-height:1;}
.mw-item__thumb-img{
  position:absolute;inset:0;
  width:100%;height:100%;
  object-fit:cover;
  display:block;
}
.mw-item--image{cursor:zoom-in;}
.mw-item__name{
  font-size:13px;
  font-weight:600;
  color:var(--ink);
  word-break:break-word;
  line-height:1.35;
  max-height:2.7em;
  overflow:hidden;
  display:-webkit-box;
  -webkit-line-clamp:2;
  -webkit-box-orient:vertical;
}
.mw-item__meta{font-size:11.5px;color:var(--muted);}
.mw-item__menu-btn{
  position:absolute;
  top:6px;right:6px;
  width:26px;height:26px;
  border-radius:6px;
  display:flex;align-items:center;justify-content:center;
  color:var(--muted);
  font-size:16px;
  line-height:1;
  opacity:0;
  transition:opacity .15s ease,background .15s ease,color .15s ease;
}
.mw-item:hover .mw-item__menu-btn,
.mw-item__menu-btn.is-open{opacity:1;}
.mw-item__menu-btn:hover{background:#fff;border:1px solid var(--line-strong);color:var(--ink);}

/* ---------- Menu contextuel ---------- */
.mw-context-menu{
  position:fixed;
  z-index:200;
  min-width:170px;
  background:#fff;
  border:1px solid var(--line-strong);
  border-radius:8px;
  padding:6px;
  display:flex;
  flex-direction:column;
  gap:2px;
}
.mw-context-menu button{
  text-align:left;
  padding:9px 10px;
  border-radius:6px;
  font-size:13.5px;
  color:var(--ink);
  font-weight:500;
}
.mw-context-menu button:hover{background:var(--bg-soft);}
.mw-context-menu button.mw-context-menu__danger{color:var(--err-ink);}

/* ---------- État vide ---------- */
.mw-drive-empty{
  display:flex;flex-direction:column;align-items:center;justify-content:center;
  gap:10px;
  padding:70px 20px;
  color:var(--muted);
  text-align:center;
}
.mw-drive-empty__icon{font-size:38px;}
.mw-drive-empty p{font-size:14.5px;color:var(--muted);}

/* ---------- Modales ---------- */
.mw-modal-overlay{
  position:fixed;inset:0;
  background:rgba(11,11,14,0.45);
  display:flex;align-items:center;justify-content:center;
  padding:20px;
  z-index:300;
}
.mw-modal-overlay[hidden]{display:none;}
.mw-modal{
  width:100%;max-width:420px;
  background:#fff;
  border:1px solid var(--line);
  border-radius:10px;
  overflow:hidden;
}
.mw-modal .mw-accentbar{margin-bottom:0;}
.mw-modal__body{padding:26px 24px 24px;}
.mw-modal__body h2{font-size:17px;margin-bottom:14px;}
.mw-modal__body p{font-size:14px;margin-bottom:14px;}
.mw-modal__field{display:flex;flex-direction:column;gap:6px;margin-bottom:18px;}
.mw-modal__field label{font-size:13.5px;font-weight:600;color:var(--ink);}
.mw-modal__field input,
.mw-modal__field select{
  width:100%;
  padding:10px 12px;
  border-radius:8px;
  border:1px solid var(--line-strong);
  background:#fff;
  color:var(--ink);
  font-family:inherit;
  font-size:14.5px;
}
.mw-modal__field input:focus,
.mw-modal__field select:focus{border-color:var(--blue);}
.mw-modal__folderlist{
  max-height:220px;
  overflow-y:auto;
  border:1px solid var(--line);
  border-radius:8px;
  margin-bottom:18px;
}
.mw-modal__folder-item{
  display:flex;align-items:center;gap:8px;
  padding:10px 12px;
  font-size:14px;
  cursor:pointer;
  border-bottom:1px solid var(--line);
}
.mw-modal__folder-item:last-child{border-bottom:0;}
.mw-modal__folder-item:hover{background:var(--bg-soft);}
.mw-modal__folder-item.is-selected{background:#f4f7ff;color:var(--blue);font-weight:600;}
.mw-modal__actions{display:flex;justify-content:flex-end;gap:10px;}
.mw-modal__actions .mw-btn{width:auto;padding:10px 18px;}
.mw-modal__error{
  font-size:13px;color:var(--err-ink);margin-bottom:14px;display:none;
}
.mw-modal__error.is-visible{display:block;}

/* ---------- Visionneuse d'images (lightbox) ---------- */
.mw-viewer{
  position:fixed;inset:0;
  z-index:400;
  background:rgba(11,11,14,0.86);
  display:flex;align-items:center;justify-content:center;
  padding:24px;
}
.mw-viewer[hidden]{display:none;}
.mw-viewer__img{
  max-width:90vw;
  max-height:90vh;
  width:auto;height:auto;
  object-fit:contain;
  border-radius:8px;
  background:#000;
}
.mw-viewer__close{
  position:absolute;
  top:16px;right:16px;
  width:40px;height:40px;
  border-radius:8px;
  display:flex;align-items:center;justify-content:center;
  font-size:24px;line-height:1;
  color:#fff;
  background:rgba(255,255,255,0.12);
  border:1px solid rgba(255,255,255,0.24);
}
.mw-viewer__close:hover{background:rgba(255,255,255,0.22);}
.mw-viewer__nav{
  position:absolute;
  top:50%;transform:translateY(-50%);
  width:44px;height:64px;
  border-radius:8px;
  display:flex;align-items:center;justify-content:center;
  font-size:30px;line-height:1;
  color:#fff;
  background:rgba(255,255,255,0.10);
  border:1px solid rgba(255,255,255,0.22);
}
.mw-viewer__nav:hover{background:rgba(255,255,255,0.2);}
.mw-viewer__nav--prev{left:16px;}
.mw-viewer__nav--next{right:16px;}
.mw-viewer__nav[hidden]{display:none;}
.mw-viewer__caption{
  position:absolute;
  left:0;right:0;bottom:16px;
  text-align:center;
  color:rgba(255,255,255,0.9);
  font-size:13.5px;
  padding:0 72px;
  pointer-events:none;
  word-break:break-word;
}
@media (max-width:760px){
  .mw-viewer{padding:12px;}
  .mw-viewer__img{max-width:94vw;max-height:82vh;}
  .mw-viewer__nav{width:38px;height:52px;font-size:26px;}
  .mw-viewer__nav--prev{left:8px;}
  .mw-viewer__nav--next{right:8px;}
  .mw-viewer__caption{padding:0 12px;bottom:10px;}
}

/* ---------- Uploads en cours ---------- */
.mw-uploads{
  position:fixed;
  right:20px;bottom:20px;
  width:320px;
  max-width:calc(100vw - 40px);
  background:#fff;
  border:1px solid var(--line-strong);
  border-radius:10px;
  overflow:hidden;
  z-index:150;
}
.mw-uploads[hidden]{display:none;}
.mw-uploads__head{
  padding:10px 14px;
  border-bottom:1px solid var(--line);
  font-size:13px;font-weight:700;
  display:flex;align-items:center;justify-content:space-between;
}
.mw-uploads__head button{color:var(--muted);font-size:16px;}
.mw-uploads__list{max-height:260px;overflow-y:auto;padding:8px 14px;display:flex;flex-direction:column;gap:10px;}
.mw-upload-row{font-size:12.5px;}
.mw-upload-row__name{
  display:flex;justify-content:space-between;gap:8px;
  margin-bottom:5px;
  color:var(--ink);
  font-weight:600;
}
.mw-upload-row__name span:last-child{color:var(--muted);font-weight:400;flex:0 0 auto;}
.mw-upload-row__bar{
  height:5px;border-radius:3px;background:var(--bg-soft);border:1px solid var(--line);overflow:hidden;
}
.mw-upload-row__fill{height:100%;background:var(--blue);border-radius:3px;transition:width .15s ease;}
.mw-upload-row.is-error .mw-upload-row__fill{background:var(--err-ink);}
.mw-upload-row.is-done .mw-upload-row__fill{background:var(--ok-ink);}
.mw-upload-row__msg{color:var(--err-ink);margin-top:3px;}

/* ---------- Bannière d'erreur générale ---------- */
.mw-drive-alert{
  border-radius:8px;
  padding:12px 14px;
  font-size:14px;
  border:1px solid var(--err-line);
  background:var(--err-bg);
  color:var(--err-ink);
  margin-bottom:16px;
  display:none;
}
.mw-drive-alert.is-visible{display:block;}

/* ---------- Responsive : tablette / mobile ---------- */
@media (max-width:760px){
  /* Bloc stockage en colonne : info au-dessus, barre pleine largeur EN
     DESSOUS. Le point clé du bug : en `flex-direction:column`, la barre
     avait `flex:2 1 320px` → 320px sur l'axe principal = 320px de HAUTEUR
     (barre verticale géante). On repasse en `flex:0 0 auto` + hauteur fixe. */
  .mw-storage{
    flex-direction:column;
    align-items:stretch;
    gap:10px;
    padding:14px 16px;
  }
  .mw-storage__info{flex:0 0 auto;min-width:0;}
  .mw-storage__text{font-size:13.5px;}
  .mw-storage__bar{
    flex:0 0 auto;
    width:100%;
    min-width:0;
    height:8px;
    align-self:stretch;
  }
  /* Grille : vignettes plus petites → 2 colonnes lisibles dès 375px. */
  .mw-grid{grid-template-columns:repeat(auto-fill,minmax(120px,1fr));gap:10px;}
  .mw-dropzone{padding:14px;min-height:260px;}
}

@media (max-width:640px){
  .mw-drive__bar{padding:12px 16px;}
  .mw-drive__main{padding:20px 16px 48px;}
  .mw-drive__title{display:none;}
  .mw-uploads{right:12px;left:12px;width:auto;bottom:12px;}
}
