@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* =====================================================================
   Drive — feuille de style unique (refonte "SaaS premium")
   Restyle les classes existantes ; police Inter, palette neutre,
   boutons sombres sobres, icones en trait, transitions douces.
   ===================================================================== */

:root {
  --bg:        #f4f6f9;
  --surface:   #ffffff;
  --border:    #e2e5ea;
  --border-2:  #edeff2;
  --text:      #10131a;
  --text-2:    #525a68;
  --text-3:    #858d9c;
  --accent:    #2f6bff;
  --accent-soft: #eaf1ff;
  --accent-line: #b9cdfb;
  --dark:      #14161c;
  --dark-h:    #23262e;
  --muted:     #5b6472;
  --muted-h:   #474f5c;
  --danger:    #d8422b;
  --danger-soft: #fdeeeb;
  --ok:        #17864a;  --ok-soft: #e8f7ee;
  --warn:      #9a6a0d;  --warn-soft: #fbf2e0;
  --r-card: 15px;
  --r-btn: 10px;
  --shadow-sm:   0 1px 2px rgba(16,19,26,.05);
  --shadow-card: 0 1px 3px rgba(16,19,26,.05), 0 6px 16px rgba(16,19,26,.05);
  --shadow-pop:  0 8px 30px rgba(16,19,26,.14);
  --tr: .16s cubic-bezier(.4,0,.2,1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

/* ---------- Page de connexion / carte de partage ---------- */

body.login-page {
  background: radial-gradient(1200px 600px at 50% -10%, #eef2f8 0%, var(--bg) 55%);
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-card);
  padding: 44px 40px;
  max-width: 440px; width: 100%;
  text-align: center;
}
.logo-badge {
  width: 56px; height: 56px;
  margin: 0 auto 22px;
  border-radius: 14px;
  background: var(--dark);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-sm);
}
.logo-badge svg { width: 27px; height: 27px; fill: #fff; }
.card h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -.02em; margin-bottom: 10px; line-height: 1.3; }
.welcome { color: var(--text-2); margin-bottom: 26px; }
.login-form { text-align: left; }
.login-form label {
  display: block; font-size: .82rem; font-weight: 600; color: var(--text-2); margin-bottom: 7px;
}
.login-form input {
  width: 100%; padding: 11px 14px; margin-bottom: 16px;
  border: 1px solid var(--border); border-radius: 10px;
  font: inherit; font-size: .95rem; background: var(--surface);
  transition: border-color var(--tr), box-shadow var(--tr);
}
.login-form input:focus {
  outline: none; border-color: var(--accent-line);
  box-shadow: 0 0 0 3px rgba(47,107,255,.12);
}
.btn-login {
  display: block; width: 100%;
  background: var(--dark); color: #fff; border: 1px solid var(--dark);
  text-decoration: none; font: inherit; font-size: .98rem; font-weight: 600;
  padding: 13px 24px; border-radius: 11px; cursor: pointer;
  transition: background var(--tr), transform var(--tr);
}
.btn-login:hover { background: var(--dark-h); }
.btn-login:active { transform: translateY(1px); }
.note { margin-top: 24px; color: var(--text-3); font-size: .82rem; }

/* ---------- Barre superieure ---------- */

.topbar {
  background: rgba(255,255,255,.9);
  backdrop-filter: saturate(180%) blur(8px);
  -webkit-backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px; min-height: 66px;
  display: flex; align-items: center; gap: 22px; flex-wrap: wrap;
  position: sticky; top: 0; z-index: 50;
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: 800; font-size: 1.12rem; letter-spacing: -.02em;
  color: var(--text); text-decoration: none; flex-shrink: 0;
}
/* Marque (carré sombre) injectée en CSS : présente sur toutes les pages sans
   toucher au HTML de chaque en-tête. */
.brand::before {
  content: "";
  width: 30px; height: 30px; border-radius: 9px; flex-shrink: 0;
  background: var(--dark) center/17px 17px no-repeat;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 4H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-8l-2-2z'/%3E%3C/svg%3E");
  box-shadow: var(--shadow-sm);
}

.topbar-search {
  flex: 1; max-width: 440px;
  display: flex; align-items: center; gap: 10px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 13px;
  transition: border-color var(--tr), box-shadow var(--tr), background var(--tr);
}
.topbar-search:focus-within {
  background: var(--surface); border-color: var(--accent-line);
  box-shadow: 0 0 0 3px rgba(47,107,255,.12);
}
.topbar-search svg { width: 16px; height: 16px; fill: var(--text-3); stroke: none; flex-shrink: 0; }
.topbar-search input {
  border: none; outline: none; background: none; font: inherit; font-size: .92rem; color: var(--text); width: 100%;
}
.topbar-search input::placeholder { color: var(--text-3); }

.topbar nav { display: flex; align-items: center; gap: 3px; margin-left: auto; flex-wrap: wrap; }
.topbar nav a {
  color: var(--text-2); text-decoration: none; font-size: .92rem; font-weight: 500;
  padding: 9px 14px; border-radius: 9px;
  transition: background var(--tr), color var(--tr);
}
.topbar nav a:hover { background: var(--border-2); color: var(--text); }
.user-chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); padding: 6px 14px; border-radius: 999px;
  font-size: .9rem; font-weight: 600; box-shadow: var(--shadow-sm);
}

/* ---------- Contenu ---------- */

.container { max-width: 1060px; margin: 0 auto; padding: 24px 24px 80px; }
.container h1 { font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; margin-bottom: 18px; }

.breadcrumb {
  display: flex; flex-wrap: wrap; gap: 3px; align-items: center;
  margin-bottom: 12px; font-size: .92rem;
}
.breadcrumb a {
  color: var(--text-2); text-decoration: none; font-weight: 500;
  padding: 5px 9px; border-radius: 7px;
  transition: background var(--tr), color var(--tr);
}
.breadcrumb a:hover { background: var(--border-2); color: var(--text); }
.breadcrumb span { color: var(--text-3); }
.breadcrumb .current { color: var(--text); font-weight: 600; }

/* ---------- Alertes / encadrés ---------- */

.alert {
  background: var(--danger-soft); border: 1px solid #f6cabf; color: #9a2f1c;
  padding: 12px 15px; border-radius: 11px; margin-bottom: 18px; font-size: .92rem;
}
.alert-ok { background: var(--ok-soft); border-color: #bfe6cd; color: #136339; }
.callout {
  background: var(--accent-soft); border: 1px solid var(--accent-line); color: #1e3f8f;
  border-radius: 12px; padding: 13px 15px; font-size: .9rem; margin-bottom: 22px;
}

/* ---------- En-tête de dossier ---------- */

.folder-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin: 4px 0 22px;
}
.folder-title { display: flex; flex-direction: column; gap: 3px; }
.folder-title h1 { font-size: 1.72rem; font-weight: 800; letter-spacing: -.025em; margin: 0; }
.folder-title .count { color: var(--text-3); font-size: .88rem; font-weight: 500; }
.head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- Boutons ---------- */

.btn, .btn-ghost, .btn-secondary {
  display: inline-flex; align-items: center; gap: 8px;
  font: inherit; font-size: .9rem; font-weight: 600;
  border-radius: var(--r-btn); padding: 9px 15px; cursor: pointer;
  text-decoration: none; white-space: nowrap; border: 1px solid transparent;
  transition: background var(--tr), border-color var(--tr), color var(--tr), transform var(--tr), box-shadow var(--tr);
}
/* Les icônes de boutons de l'app sont des glyphes pleins (fill) — on conserve
   ce rendu partout ; seules les icônes de type de fichier (.ficon) sont en trait. */
.btn svg, .btn-ghost svg, .btn-secondary svg { width: 16px; height: 16px; fill: currentColor; stroke: none; vertical-align: middle; }
.btn {
  background: var(--dark); color: #fff; border-color: var(--dark);
  box-shadow: 0 1px 2px rgba(16,19,26,.18), inset 0 1px 0 rgba(255,255,255,.06);
}
.btn:hover { background: var(--dark-h); border-color: var(--dark-h); }
.btn:active { transform: translateY(1px); }
.btn-ghost {
  background: var(--surface); color: var(--text); border-color: var(--border); box-shadow: var(--shadow-sm);
}
.btn-ghost:hover { border-color: #cfd4dc; background: #fbfcfd; }
.btn-ghost:active { transform: translateY(1px); }
a.btn-ghost, a.btn { text-decoration: none; }
.btn-secondary { background: var(--muted); color: #fff; border-color: var(--muted); }
.btn-secondary:hover { background: var(--muted-h); border-color: var(--muted-h); }
.btn-icon { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
.btn-mini { padding: 6px 11px; font-size: .82rem; }

/* ---------- Formulaires génériques ---------- */

.inline-form, .grid-form { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=file], select, textarea {
  padding: 9px 13px; border: 1px solid var(--border); border-radius: 10px;
  font: inherit; font-size: .9rem; background: var(--surface); color: var(--text);
  transition: border-color var(--tr), box-shadow var(--tr);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent-line); box-shadow: 0 0 0 3px rgba(47,107,255,.12);
}
.checkbox { display: inline-flex; align-items: center; gap: 8px; font-size: .9rem; color: var(--text-2); }
.hint { color: var(--text-2); font-size: .86rem; margin-top: 11px; }
.empty { color: var(--text-2); padding: 34px 0; text-align: center; }

/* ---------- Panneau d'upload repliable ---------- */

.upload-panel { max-height: 0; overflow: hidden; opacity: 0; transition: max-height .25s ease, opacity .2s ease, margin .25s ease; }
.upload-panel.open { max-height: 360px; opacity: 1; margin-bottom: 20px; }
.toolbar {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card);
  padding: 16px; display: flex; flex-wrap: wrap; gap: 20px;
}
#upload-form { display: flex; flex-direction: column; gap: 12px; flex: 1 1 320px; }
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 9px;
  text-align: center; border: 1.5px dashed #cfd6e0; border-radius: var(--r-card);
  background: linear-gradient(180deg, #ffffff 0%, #fcfdff 100%);
  padding: 30px 20px; cursor: pointer; color: var(--text-2); font-size: .9rem;
  transition: border-color var(--tr), background var(--tr);
}
.dropzone:hover { border-color: var(--accent); }
.dropzone-active { border-color: var(--accent); background: var(--accent-soft); }
.dropzone-icon { font-size: 1.5rem; }
.dropzone-files { font-size: .82rem; color: var(--text); font-weight: 600; word-break: break-word; }
.file-input-visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* ---------- Barre de sélection multiple (sombre) ---------- */

.selection-bar {
  display: none; align-items: center; gap: 8px;
  background: var(--dark); color: #fff;
  border-radius: 12px; padding: 9px 10px 9px 16px; margin-bottom: 14px;
  box-shadow: var(--shadow-pop);
}
.selection-bar.show { display: flex; }
.sel-count { font-size: .9rem; font-weight: 600; }
.selection-bar .spacer { flex: 1; }
.sel-btn {
  display: inline-flex; align-items: center; gap: 7px; font: inherit; font-size: .85rem; font-weight: 500;
  color: #e7e9ee; background: rgba(255,255,255,.08); border: none; border-radius: 8px; padding: 7px 12px; cursor: pointer;
  transition: background var(--tr);
}
.sel-btn svg { width: 15px; height: 15px; fill: currentColor; stroke: none; }
.sel-btn:hover { background: rgba(255,255,255,.16); }
.sel-close { width: 32px; height: 32px; border-radius: 8px; border: none; background: rgba(255,255,255,.08); color: #cfd3db; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.sel-close:hover { background: rgba(255,255,255,.16); color: #fff; }
.sel-close svg { width: 15px; height: 15px; fill: currentColor; stroke: none; }

/* Case à cocher personnalisée */
.col-check { width: 46px; text-align: center; }
.cbx {
  width: 17px; height: 17px; border-radius: 5px; border: 1.6px solid #c6ccd6; background: var(--surface);
  cursor: pointer; appearance: none; -webkit-appearance: none; display: inline-block; vertical-align: middle;
  position: relative; transition: border-color var(--tr), background var(--tr);
}
.cbx:hover { border-color: var(--accent); }
.cbx:checked { background: var(--accent); border-color: var(--accent); }
.cbx:checked::after { content: ""; position: absolute; left: 5px; top: 2px; width: 4px; height: 8px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }

/* ---------- Cartes & tableaux ---------- */

.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card);
  box-shadow: var(--shadow-card); padding: 20px; margin-bottom: 22px;
}
.panel h2 { font-size: 1rem; font-weight: 700; letter-spacing: -.015em; margin-bottom: 14px; color: var(--text); }

.listing {
  width: 100%; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-card);
  border-collapse: collapse; overflow: hidden;
  box-shadow: var(--shadow-card);
}
.listing th {
  text-align: left; font-size: .74rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-3); padding: 12px 18px; background: #f9fafb; border-bottom: 1px solid var(--border);
}
.listing th.col-size, .listing th.col-date { text-align: right; white-space: nowrap; }
.listing td { padding: 12px 18px; border-bottom: 1px solid var(--border-2); vertical-align: middle; }
.listing tr:last-child td { border-bottom: none; }
.listing tbody tr { transition: background var(--tr), box-shadow var(--tr); }
.listing tbody tr:hover { background: #f8fafc; }
.listing tbody tr.selected { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.listing tbody tr.selected:hover { background: #e2ecff; }
.listing a { color: var(--text); text-decoration: none; font-weight: 500; }
.listing a:hover { color: var(--accent); }

.name-cell { display: flex; align-items: center; gap: 13px; min-width: 0; }
.name-cell a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .94rem; }
.meta { color: var(--text-3); font-size: .84rem; white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }
.actions { display: flex; flex-wrap: wrap; gap: 2px; align-items: center; justify-content: flex-end; }

/* Icone colorée par type (voir file_icon_html() dans bootstrap.php) */
.ficon { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ficon svg { width: 17px; height: 17px; fill: none; }
.ficon.folder { background: #fbeecb; } .ficon.folder svg { stroke: #b8801b; }
.ficon.pdf    { background: #fce3e1; } .ficon.pdf svg    { stroke: #c93a2c; }
.ficon.img    { background: #dbf1e3; } .ficon.img svg    { stroke: #1e8a54; }
.ficon.doc    { background: #dde8fc; } .ficon.doc svg    { stroke: #2f6bff; }

/* Cellule icône simple (page de partage public) */
.listing td.icon { width: 52px; text-align: center; font-size: 1.15rem; }

/* Boutons d'action par ligne */
.iconbtn {
  width: 32px; height: 32px; border-radius: 8px; border: none; background: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; color: var(--text-2);
  opacity: 0; transition: opacity var(--tr), background var(--tr), color var(--tr);
}
.iconbtn svg { width: 16px; height: 16px; fill: currentColor; stroke: none; }
.iconbtn:hover { background: var(--accent-soft); color: var(--accent); }
.iconbtn.danger:hover { background: var(--danger-soft); color: var(--danger); }
.listing tbody tr:hover .iconbtn,
.listing tbody tr:focus-within .iconbtn,
.listing tbody tr.selected .iconbtn { opacity: 1; }
@media (hover: none) { .iconbtn { opacity: 1; } }

/* Menus déroulants (Partager / Nouveau dossier) — position fixe calculée en JS */
.menu-details { position: relative; display: inline-block; }
.menu-details summary { cursor: pointer; color: var(--accent); font-size: .9rem; list-style: none; }
.menu-details summary::-webkit-details-marker { display: none; }
.menu-details summary.iconbtn { color: var(--text-2); }
.menu-panel {
  position: fixed; z-index: 1000; margin-top: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-pop); padding: 13px; display: flex; flex-direction: column; gap: 9px; width: 236px;
}

/* Badges & pastilles */
.badge { font-size: .72rem; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--border-2); color: var(--text-2); flex-shrink: 0; }
.badge.read   { background: var(--border-2); color: var(--text-2); }
.badge.write  { background: var(--ok-soft); color: var(--ok); }
.badge.manage { background: var(--warn-soft); color: var(--warn); }
.pill { font-size: .76rem; font-weight: 600; padding: 3px 10px; border-radius: 999px; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }

/* ---------- Partage : liens ---------- */

.share-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.share-toolbar .breadcrumb { margin-bottom: 0; }
.share-url-cell { display: flex; gap: 7px; align-items: center; }
.share-url { width: 100%; min-width: 180px; max-width: 340px; font-size: .8rem; color: var(--text-2); background: var(--bg); }
.copy-btn {
  flex-shrink: 0; font: inherit; font-size: .8rem; font-weight: 600;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 9px;
  padding: 8px 13px; cursor: pointer; transition: border-color var(--tr), background var(--tr);
}
.copy-btn:hover { border-color: #cfd4dc; background: #fbfcfd; }
.link-danger {
  background: none; border: none; cursor: pointer; font: inherit; font-size: .84rem; font-weight: 600;
  color: var(--danger); padding: 6px 9px; border-radius: 7px; transition: background var(--tr);
}
.link-danger:hover { background: var(--danger-soft); }

/* ---------- Écran "Gérer les accès" ---------- */

.who { display: flex; align-items: center; gap: 11px; }
.who .sub { color: var(--text-3); font-size: .8rem; }
.avatar { width: 32px; height: 32px; border-radius: 999px; display: flex; align-items: center; justify-content: center; font-size: .82rem; font-weight: 700; flex-shrink: 0; }
.avatar.user  { background: var(--accent-soft); color: var(--accent); }
.avatar.group { background: #efe9fb; color: #6d3fd0; }
.scope { font-size: .82rem; }
.scope.direct { color: var(--text-2); }
.scope.herit  { color: var(--text-3); font-style: italic; }
.row-actions { text-align: right; }
.level-form { gap: 7px; }
.mini-select { padding: 6px 9px; font-size: .82rem; border-radius: 8px; }

/* ---------- Responsive ---------- */

@media (max-width: 880px) {
  .topbar { gap: 12px; padding: 0 16px; }
  .user-chip { padding: 6px 10px; }
}
@media (max-width: 640px) {
  body { font-size: 14.5px; }
  .container { padding: 18px 14px 60px; }
  .card { padding: 34px 22px; }
  .topbar { min-height: 58px; padding: 10px 16px; }
  .topbar-search { order: 3; flex-basis: 100%; max-width: none; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .inline-form, .grid-form { flex-direction: column; align-items: stretch; }

  .folder-head { align-items: stretch; flex-direction: column; }
  .head-actions { width: 100%; }
  .head-actions .btn { flex: 1 1 100%; justify-content: center; }
  .head-actions .btn-ghost { flex: 1 1 calc(50% - 4px); justify-content: center; }

  .selection-bar { flex-wrap: wrap; }

  /* Sur mobile : nom + actions seulement dans le tableau principal. */
  .file-listing th.col-size, .file-listing th.col-date, .file-listing td.meta { display: none; }
  .listing th, .listing td { padding: 12px 12px; }
  .iconbtn { opacity: 1; }
  .share-url { min-width: 120px; }
}
