/* Cloud drive view (views/cloud.js). All classes prefixed .cl- */

/* ---------- header ---------- */
.cl-tabsrow{display:flex; align-items:flex-end; justify-content:space-between; gap:18px; flex-wrap:wrap; margin-bottom:16px; border-bottom:1px solid var(--border);}
.cl-tabs{border-bottom:0; margin-bottom:-1px;}
.cl-tabs .tab .ic{width:14px; height:14px;}
.cl-quota{width:240px; display:flex; flex-direction:column; gap:6px; padding-bottom:10px;}
.cl-banner{display:flex; align-items:flex-start; gap:10px; padding:11px 14px; border-radius:12px; font-size:13px; line-height:1.5; margin-bottom:14px; animation:fadeUp .4s var(--ease) both;}
.cl-banner .ic{width:17px; height:17px; margin-top:1px;}
.cl-banner.warn{background:var(--warn-soft); color:var(--warn); border:1px solid color-mix(in srgb,var(--warn) 28%,transparent);}
.cl-banner.bad{background:var(--bad-soft); color:var(--bad); border:1px solid color-mix(in srgb,var(--bad) 28%,transparent);}

/* ---------- toolbar ---------- */
.cl-toolbar{display:flex; align-items:center; gap:8px; margin-bottom:12px; min-height:36px;}
.cl-crumbs{display:flex; align-items:center; gap:2px; min-width:0; overflow:hidden;}
.cl-crumb{display:inline-flex; align-items:center; gap:7px; height:30px; padding:0 8px; border-radius:8px; font-weight:600; font-size:13.5px; color:var(--text-2); white-space:nowrap; max-width:220px; transition:background .15s, color .15s;}
.cl-crumb span{overflow:hidden; text-overflow:ellipsis;}
a.cl-crumb:hover, button.cl-crumb:hover{background:var(--hover); color:var(--text);}
.cl-crumb.cur{color:var(--text);}
.cl-crumb .ic{color:var(--muted);}
.cl-sep{color:var(--muted); display:inline-flex; flex-shrink:0;}
.cl-search{width:230px; flex-shrink:0;}
.cl-search .input{height:32px;}
.cl-viewseg button{width:32px; padding:0; justify-content:center;}

/* ---------- body / list ---------- */
.cl-body{min-height:300px; overflow:hidden; position:relative;}
.cl-list{display:flex; flex-direction:column;}
.cl-row{
  display:grid; grid-template-columns:28px 34px minmax(0,1fr) 110px 120px 32px; align-items:center; gap:12px;
  padding:9px 14px; border-bottom:1px solid var(--border); cursor:default; user-select:none; -webkit-user-select:none;
  transition:background .15s; position:relative; -webkit-touch-callout:none;
}
.cl-list > .stagger > .cl-row:last-child, .cl-list > .cl-row:last-child{border-bottom:0;}
.cl-row:hover{background:var(--hover);}
.cl-row.sel{background:var(--accent-soft);}
.cl-row.sel::before{content:""; position:absolute; left:0; top:0; bottom:0; width:3px; background:var(--accent); animation:barIn .25s var(--ease);}
.cl-row .r{text-align:right;}
.cl-head{padding-top:7px; padding-bottom:7px; background:var(--surface-2); cursor:default;}
.cl-head:hover{background:var(--surface-2);}
.cl-th{font-size:11px; font-weight:600; letter-spacing:.6px; text-transform:uppercase; color:var(--muted); display:inline-flex; align-items:center; gap:4px; padding:3px 0;}
.cl-th.r{justify-content:flex-end;}
.cl-th:hover, .cl-th.on{color:var(--text);}
.cl-namecell{display:flex; flex-direction:column; min-width:0; gap:1px;}
.cl-name{font-weight:500; font-size:13.5px;}
.cl-row .cl-more{opacity:0; transition:opacity .15s;}
.cl-row:hover .cl-more, .cl-row.sel .cl-more, .cl-more:focus-visible{opacity:1;}
.cl-check{justify-content:center;}
.cl-check input{width:17px; height:17px;}
.cl-row .cl-check{opacity:.55; transition:opacity .15s;}
.cl-row:hover .cl-check, .cl-row.sel .cl-check, .selecting .cl-check, .cl-head .cl-check{opacity:1;}
.cl-result, .cl-trashrow{cursor:pointer;}
.cl-trashrow{cursor:default; grid-template-columns:4px 34px minmax(0,1fr) auto;}
.cl-result{grid-template-columns:4px 34px minmax(0,1fr) 110px 120px 20px;}
.cl-result > :last-child{color:var(--muted); display:flex;}
.cl-results-head{padding:10px 14px; border-bottom:1px solid var(--border); background:var(--surface-2);}
.cl-trash-note{padding:10px 14px; border-bottom:1px solid var(--border); background:var(--surface-2);}
.cl-purge:hover{color:var(--bad); background:var(--bad-soft);}

/* file-type icon tiles */
.cl-ic{--k:#7e8299; width:34px; height:34px; border-radius:10px; display:inline-flex; align-items:center; justify-content:center; flex-shrink:0;
  color:var(--k); background:color-mix(in srgb,var(--k) 15%,transparent);}
.cl-ic .ic{width:17px; height:17px;}
.cl-k-folder{--k:#f5b83d;} .cl-k-image{--k:#22c55e;} .cl-k-video{--k:#ec4899;} .cl-k-audio{--k:#8f6bff;}
.cl-k-pdf{--k:#ef4444;} .cl-k-code{--k:#3b9cf5;} .cl-k-text{--k:#94a3b8;} .cl-k-archive{--k:#f97316;}
.cl-k-model{--k:#14b8a6;} .cl-k-roblox{--k:#5b7cfa;} .cl-k-doc{--k:#3b82f6;} .cl-k-sheet{--k:#16a34a;} .cl-k-design{--k:#d07bff;}
:root[data-theme="light"] .cl-k-folder{--k:#d99a0b;} :root[data-theme="light"] .cl-k-text{--k:#64748b;}

/* ---------- grid ---------- */
.cl-body.cl-grid-mode{background:transparent; border:0; box-shadow:none; overflow:visible;}
.cl-grid{display:grid; grid-template-columns:repeat(auto-fill,minmax(170px,1fr)); gap:14px;}
.cl-card{position:relative; background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-lg); overflow:hidden; cursor:default; user-select:none; -webkit-user-select:none; -webkit-touch-callout:none;
  transition:transform .22s var(--ease), border-color .2s, box-shadow .2s; box-shadow:var(--shadow);}
.cl-card:hover{transform:translateY(-2px); border-color:var(--border-strong);}
.cl-card.sel{border-color:color-mix(in srgb,var(--accent) 70%,transparent); box-shadow:0 0 0 3px var(--accent-soft), var(--shadow);}
.cl-thumb{aspect-ratio:4/3; display:flex; align-items:center; justify-content:center; background:var(--surface-2); overflow:hidden;}
.cl-thumb img{width:100%; height:100%; object-fit:cover; transition:transform .4s var(--ease);}
.cl-card:hover .cl-thumb img{transform:scale(1.04);}
.cl-thumb .cl-ic{border-radius:16px;}
.cl-card-foot{display:flex; align-items:center; gap:6px; padding:9px 6px 10px 12px;}
.cl-card .cl-check{position:absolute; top:8px; left:8px; opacity:0; transition:opacity .15s; background:color-mix(in srgb,var(--surface) 80%,transparent); border-radius:7px; padding:3px;}
.cl-card:hover .cl-check, .cl-card.sel .cl-check, .selecting .cl-card .cl-check{opacity:1;}

/* ---------- skeleton ---------- */
.cl-skel{padding:6px 0;}
.cl-skel-row{display:flex; align-items:center; gap:14px; padding:10px 16px;}

/* ---------- selection bar ---------- */
.cl-selbar{position:fixed; z-index:60; bottom:24px; left:calc(var(--sidebar-w) + (100vw - var(--sidebar-w)) / 2); transform:translateX(-50%);
  display:flex; align-items:center; gap:4px; padding:6px 6px 6px 16px; border-radius:14px; background:var(--surface-3); border:1px solid var(--border-strong);
  box-shadow:var(--shadow-lg); animation:clBarIn .3s var(--ease-spring) both; white-space:nowrap;}
.cl-selcount{font-size:13px; margin-right:8px;}
.cl-selbar .cl-danger:hover{color:var(--bad); background:var(--bad-soft);}
@keyframes clBarIn{from{opacity:0; transform:translate(-50%,16px) scale(.96);}to{opacity:1; transform:translate(-50%,0);}}

/* ---------- FAB (phones) ---------- */
.cl-fab{position:fixed; z-index:60; right:16px; bottom:calc(var(--bottomnav-h) + env(safe-area-inset-bottom) + 16px); width:54px; height:54px; border-radius:18px;
  display:flex; align-items:center; justify-content:center; color:#fff; background:linear-gradient(135deg,var(--accent),var(--accent-2));
  box-shadow:0 12px 28px -10px rgba(91,124,250,.9); animation:pop .4s var(--ease-spring) both; transition:transform .15s;}
.cl-fab:active{transform:scale(.92);}
.cl-fab .ic{width:24px; height:24px;}

/* ---------- drop overlay ---------- */
.cl-drop{position:fixed; z-index:80; top:var(--topbar-h); left:var(--sidebar-w); right:0; bottom:0; padding:22px; pointer-events:none;
  background:color-mix(in srgb,var(--bg) 55%,transparent); backdrop-filter:blur(3px); animation:fadeIn .15s both;}
.cl-drop-box{height:100%; border:2px dashed color-mix(in srgb,var(--accent) 70%,transparent); border-radius:22px; background:var(--accent-soft);
  display:flex; flex-direction:column; align-items:center; justify-content:center; gap:8px; text-align:center; animation:clDropPulse 1.6s ease-in-out infinite;}
.cl-drop-box b{font-family:var(--font-display); font-size:20px;}
.cl-drop-ic{width:76px; height:76px; border-radius:24px; display:grid; place-items:center; color:#fff; background:linear-gradient(135deg,var(--accent),var(--accent-2)); box-shadow:0 18px 40px -14px rgba(91,124,250,.9); margin-bottom:8px; animation:clBounce 1.2s var(--ease) infinite;}
.cl-drop.no .cl-drop-box{border-color:color-mix(in srgb,var(--bad) 60%,transparent); background:var(--bad-soft); animation:none;}
.cl-drop.no .cl-drop-ic{background:var(--bad); animation:none;}
@keyframes clDropPulse{0%,100%{border-color:color-mix(in srgb,var(--accent) 45%,transparent);}50%{border-color:color-mix(in srgb,var(--accent) 95%,transparent);}}
@keyframes clBounce{0%,100%{transform:translateY(0);}50%{transform:translateY(-8px);}}

/* ---------- upload panel (lives on <body>) ---------- */
.cl-up{position:fixed; z-index:90; right:20px; bottom:20px; width:380px; max-width:calc(100vw - 24px); background:var(--surface); border:1px solid var(--border-strong);
  border-radius:16px; box-shadow:var(--shadow-lg); overflow:hidden; animation:toastIn .35s var(--ease-spring) both; display:flex; flex-direction:column;}
.cl-up-head{display:flex; align-items:center; gap:6px; padding:12px 10px 10px 14px;}
.cl-up-title{display:flex; align-items:center; gap:8px; font-weight:600; font-size:13.5px; min-width:0;}
.cl-up-title .ic{width:16px; height:16px; color:var(--good); flex-shrink:0;}
.cl-up-spin{width:14px; height:14px; flex-shrink:0;}
.cl-up-total{height:3px; border-radius:0; background:var(--surface-3);}
.cl-up-total > i{transition:width .4s linear;}
.cl-up-list{max-height:min(320px,45vh); overflow-y:auto; padding:4px 0;}
.cl-up-item{display:flex; align-items:center; gap:10px; padding:8px 10px 8px 14px; animation:fadeIn .25s both;}
.cl-up-item .cl-ic{border-radius:8px;}
.cl-up-item.is-canceled{opacity:.55;}
.cl-up-bar{height:4px; margin-top:5px;}
.cl-up-bar > i{transition:width .3s linear;}
.cl-up-item.is-queued .cl-up-bar > i{background:var(--surface-4);}
.cl-up-ok{width:28px; display:inline-flex; justify-content:center; color:var(--good); animation:pop .35s var(--ease-spring) both;}
/* keep toasts above the upload panel */
body.cl-has-uploads .toasts{bottom:calc(32px + var(--cl-up-h, 0px));}

/* ---------- move picker ---------- */
.cl-pick{display:flex; flex-direction:column; gap:12px;}
.cl-pick-vaults{align-self:flex-start;}
.cl-pick-path{display:flex; align-items:center; flex-wrap:wrap; gap:2px;}
.cl-pick-list{border:1px solid var(--border); border-radius:12px; min-height:220px; max-height:46vh; overflow-y:auto; background:var(--surface-2);}
.cl-pick-item{display:flex; align-items:center; gap:10px; width:100%; padding:8px 12px; text-align:left; font-size:13.5px; border-bottom:1px solid var(--border); color:var(--text);}
.cl-pick-item:last-child{border-bottom:0;}
.cl-pick-item:hover{background:var(--hover);}
.cl-pick-item > .ic{color:var(--muted);}
.cl-clash{margin:10px 0 0 18px; font-size:13px; display:flex; flex-direction:column; gap:3px;}

/* ---------- preview ---------- */
.cl-preview .modal-body{padding:0; background:#05060a; display:flex; min-height:0;}
:root[data-theme="light"] .cl-preview .modal-body{background:#1a1c25;}
.cl-pv{flex:1; display:flex; min-height:min(70vh,720px); min-width:0;}
.cl-pv-media{flex:1; display:flex; align-items:center; justify-content:center; padding:14px; min-width:0;}
.cl-pv-img{max-width:100%; max-height:calc(100dvh - 220px); object-fit:contain; border-radius:6px; user-select:none;}
.cl-pv-video{max-width:100%; max-height:calc(100dvh - 220px); border-radius:8px; background:#000;}
.cl-pv-audio{flex-direction:column; gap:18px; color:#e8eaf2;}
.cl-pv-audio audio{width:min(460px,92%);}
.cl-pv-disc{width:130px; height:130px; border-radius:50%; display:grid; place-items:center; color:#fff; background:conic-gradient(from 0deg,var(--accent),var(--accent-2),#d07bff,var(--accent)); box-shadow:0 20px 50px -18px rgba(143,107,255,.8); animation:spin 9s linear infinite;}
.cl-pv-pdf{flex:1; width:100%; border:0; background:#fff; min-height:min(75vh,820px);}
.cl-pv-loading{flex:1; display:grid; place-items:center;}
.cl-pv-none{flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:12px; padding:40px 20px; text-align:center; background:var(--surface); color:var(--text);}
.cl-pv-none .cl-ic{border-radius:22px; margin-bottom:6px;}
.cl-code{flex:1; margin:0; overflow:auto; max-height:calc(100dvh - 200px); padding:14px 0; background:var(--surface-2); color:var(--text); font-family:var(--font-mono); font-size:12.5px; line-height:1.6; counter-reset:ln; tab-size:4;}
.cl-code code{display:block; min-width:max-content;}
.cl-ln{display:block; padding:0 18px 0 0; white-space:pre;}
.cl-ln::before{counter-increment:ln; content:counter(ln); display:inline-block; width:3.6em; padding-right:1.1em; margin-right:1em; text-align:right; color:var(--muted); border-right:1px solid var(--border); user-select:none;}
.cl-ln:hover{background:var(--hover);}
.cl-pv-nav.single [data-pv-prev], .cl-pv-nav.single [data-pv-next]{display:none;}

/* ---------- phones ---------- */
@media (max-width:899px){
  .cl-tabsrow{flex-direction:column; align-items:stretch; gap:12px; border-bottom:0;}
  .cl-tabs{border-bottom:1px solid var(--border); margin-bottom:0;}
  .cl-quota{width:auto; padding-bottom:0;}
  .cl-toolbar{flex-wrap:wrap;}
  .cl-crumbs{flex-basis:100%; order:-1;}
  .cl-search{flex:1; width:auto;}
  .cl-row{grid-template-columns:40px minmax(0,1fr) 36px; gap:12px; padding:11px 12px; min-height:62px;}
  .cl-row .cl-check, .cl-row .cl-sp{display:none;}
  .selecting .cl-row{grid-template-columns:26px 40px minmax(0,1fr) 36px;}
  .selecting .cl-row .cl-check{display:inline-flex;}
  .cl-row .cl-ic{width:40px; height:40px; border-radius:12px;}
  .cl-row .cl-more{opacity:1;}
  .cl-name{font-size:14.5px;}
  .cl-trashrow{grid-template-columns:40px minmax(0,1fr) auto;}
  .cl-result{grid-template-columns:40px minmax(0,1fr) 20px;}
  .cl-result > .r{display:none;}
  .cl-grid{grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px;}
  .cl-card .cl-check{opacity:0;} .selecting .cl-card .cl-check{opacity:1;}
  .cl-selbar{left:12px; right:12px; transform:none; bottom:calc(var(--bottomnav-h) + env(safe-area-inset-bottom) + 12px); justify-content:space-between; animation:sheetIn .3s var(--ease) both;}
  .cl-selbar .btn{height:40px; min-width:44px;}
  .cl-drop{left:0; top:0;}
  .cl-up{right:10px; left:10px; width:auto; max-width:none; bottom:calc(var(--bottomnav-h) + env(safe-area-inset-bottom) + 10px);}
  body.cl-has-uploads .toasts{bottom:calc(var(--bottomnav-h) + env(safe-area-inset-bottom) + 22px + var(--cl-up-h, 0px));}
  .cl-pv{min-height:0;}
  .cl-pv-img, .cl-pv-video{max-height:calc(100dvh - 190px);}
  .cl-code{max-height:none;}
  .cl-preview .modal-body{flex:1;}
  .cl-pv-pdf{min-height:0; height:100%;}
}
@media (max-width:899px){
  body:has(.cl-selbar:not(.hidden)) .cl-fab{display:none;}
  body.cl-has-uploads .cl-fab{bottom:calc(var(--bottomnav-h) + env(safe-area-inset-bottom) + 20px + var(--cl-up-h, 0px));}
  /* the uploads panel (z-index 90, full width) would otherwise sit on top of the selection bar */
  body.cl-has-uploads .cl-selbar{bottom:calc(var(--bottomnav-h) + env(safe-area-inset-bottom) + 20px + var(--cl-up-h, 0px));}
}
/* Desktop: the centred selection bar reaches under the 380px uploads panel (right:20px) while
   vw < sidebar-w(252) + ~1200px; lift it above the panel there. Wider screens never overlap. */
@media (min-width:900px) and (max-width:1499px){
  body.cl-has-uploads .cl-selbar{bottom:calc(32px + var(--cl-up-h, 0px));}
}
