/* ═══════════════════════════════════════════════════════════════════
   filebrowser.css  — all classes prefixed fb- to avoid collisions
   Import once in your base template.
   ═══════════════════════════════════════════════════════════════════ */

/* ─── Design tokens ──────────────────────────────────────────────── */
:root {
  --fb-bg:       #0f1117;
  --fb-surface:  #1a1d27;
  --fb-panel:    #21253a;
  --fb-border:   #2e3352;
  --fb-accent:   #5b6af0;
  --fb-accent2:  #c471ed;
  --fb-text:     #e8eaf6;
  --fb-muted:    #6b7099;
  --fb-danger:   #f05b6a;
  --fb-success:  #4ecb94;
  --fb-radius:   12px;
}

/* ─── Widget wrapper ─────────────────────────────────────────────── */
.fb-widget {
  font-family: 'DM Sans', 'Segoe UI', sans-serif;
  color: var(--fb-text);
  width: 100%;
}

.fb-label {
  display: block;
  font-size: .8rem;
  font-weight: 700;
  color: var(--fb-muted);
  text-transform: uppercase;
  letter-spacing: .1em;
  margin-bottom: 8px;
}

/* ─── Card ───────────────────────────────────────────────────────── */
.fb-card {
  background: var(--fb-surface);
  border: 1px solid var(--fb-border);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,.35);
}

/* ─── Upload zone ────────────────────────────────────────────────── */
.fb-upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 48px 28px;
  cursor: pointer;
  border: 2px dashed var(--fb-border);
  margin: 20px;
  border-radius: var(--fb-radius);
  transition: border-color .2s, background .2s;
  text-align: center;
}
.fb-upload-zone:hover,
.fb-upload-zone.fb-drag-over {
  border-color: var(--fb-accent);
  background: rgba(91,106,240,.06);
}
.fb-upload-icon {
  width: 52px; height: 52px;
  background: linear-gradient(135deg, var(--fb-accent), var(--fb-accent2));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.fb-upload-icon svg { width: 24px; height: 24px; stroke: #fff; fill: none; stroke-width: 2; }
.fb-upload-zone h2  { font-size: 1rem; font-weight: 600; margin: 0; }
.fb-upload-zone p   { font-size: .82rem; color: var(--fb-muted); margin: 0; }

/* ─── Buttons ────────────────────────────────────────────────────── */
.fb-btn-row {
  display: flex; gap: 10px; margin-top: 6px;
  flex-wrap: wrap; justify-content: center;
}
.fb-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 16px; border-radius: 8px; font-size: .82rem;
  font-weight: 600; cursor: pointer; border: none;
  transition: opacity .15s, transform .1s;
  line-height: 1;
}
.fb-btn:active { transform: scale(.97); }
.fb-btn svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; flex-shrink: 0; }
.fb-btn-primary { background: linear-gradient(135deg, var(--fb-accent), #7b8cff); color: #fff; }
.fb-btn-ghost   { background: var(--fb-panel); color: var(--fb-text); border: 1px solid var(--fb-border); }
.fb-btn-success { background: var(--fb-success); color: #0f1117; }
.fb-btn:hover   { opacity: .85; }

/* ─── Preview area ───────────────────────────────────────────────── */
.fb-preview-area { position: relative; }

/* Image wrap + subtle pencil icon */
.fb-img-wrap {
  position: relative;
  overflow: hidden;
}
.fb-preview-img {
  display: block;
  width: 100%;
  max-height: 380px;
  object-fit: contain;
  background: #0a0c14;
}
.fb-edit-icon-btn {
  position: absolute;
  bottom: 10px; right: 12px;
  background: rgba(15,17,23,.72);
  border: 1px solid rgba(255,255,255,.10);
  color: rgba(255,255,255,.40);
  border-radius: 8px;
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .2s, transform .2s, color .15s, background .15s, border-color .15s;
  backdrop-filter: blur(4px);
}
.fb-img-wrap:hover .fb-edit-icon-btn {
  opacity: 1;
  transform: translateY(0);
}
.fb-edit-icon-btn:hover {
  color: rgba(255,255,255,.9);
  background: rgba(91,106,240,.35);
  border-color: rgba(91,106,240,.5);
}
.fb-edit-icon-btn svg {
  width: 13px; height: 13px;
  stroke: currentColor; fill: none; stroke-width: 2;
  pointer-events: none;
}

/* Non-image file card */
.fb-file-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 22px 20px;
  background: var(--fb-panel);
}
.fb-file-card-icon {
  width: 48px; height: 48px; flex-shrink: 0;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
}
.fb-file-card-icon svg { width: 26px; height: 26px; stroke: currentColor; fill: none; stroke-width: 1.5; }
.fb-file-card-meta { flex: 1; min-width: 0; }
.fb-file-card-name {
  font-size: .88rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.fb-file-card-sub { font-size: .73rem; color: var(--fb-muted); margin-top: 3px; }
.fb-file-card-badge {
  display: inline-block;
  padding: 2px 8px; border-radius: 4px;
  font-size: .66rem; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; flex-shrink: 0;
}

/* file type colours */
.fb-fc-pdf   { background: rgba(240,91,106,.15);  color: #f05b6a; }
.fb-fc-doc   { background: rgba(91,106,240,.15);  color: #7b8cff; }
.fb-fc-sheet { background: rgba(78,203,148,.15);  color: #4ecb94; }
.fb-fc-slide { background: rgba(255,180,50,.15);  color: #ffb432; }
.fb-fc-zip   { background: rgba(160,100,240,.15); color: #c47aff; }
.fb-fc-audio { background: rgba(255,140,100,.15); color: #ff9664; }
.fb-fc-video { background: rgba(100,200,255,.15); color: #64c8ff; }
.fb-fc-code  { background: rgba(78,203,148,.15);  color: #4ecb94; }
.fb-fc-text  { background: rgba(180,180,200,.15); color: #a0a4c0; }
.fb-fc-gen   { background: rgba(107,112,153,.15); color: var(--fb-muted); }

/* Preview footer */
.fb-preview-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px; border-top: 1px solid var(--fb-border);
  flex-wrap: wrap; gap: 8px;
}
.fb-img-info { font-size: .75rem; color: var(--fb-muted); }

/* ─── Modals ─────────────────────────────────────────────────────── */
.fb-modal {
  display: none;
  position: fixed; inset: 0; z-index: 9900;
  background: rgba(5,7,15,.88);
  backdrop-filter: blur(6px);
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 20px;
  overflow-y: auto;
}
.fb-modal.fb-open { display: flex; }

/* ─── Cropper modal card ─────────────────────────────────────────── */
.fb-modal-card {
  background: var(--fb-surface);
  border: 1px solid var(--fb-border);
  border-radius: 20px;
  overflow: hidden;
  width: 100%; max-width: 900px;
  box-shadow: 0 32px 100px rgba(0,0,0,.7);
  display: flex; flex-direction: column;
  margin: auto 0;  /* vertical centering within scrollable area */
}
.fb-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--fb-border);
  background: var(--fb-panel);
}
.fb-modal-header h3 { font-size: .95rem; font-weight: 700; margin: 0; }

.fb-close-btn {
  background: none; border: none; cursor: pointer; color: var(--fb-muted);
  padding: 4px; border-radius: 6px; display: flex;
  transition: color .15s, background .15s;
}
.fb-close-btn:hover { color: var(--fb-text); background: var(--fb-border); }
.fb-close-btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; }

/* ─── Toolbar ────────────────────────────────────────────────────── */
.fb-toolbar {
  display: flex; align-items: center; gap: 5px;
  padding: 9px 14px;
  background: var(--fb-panel);
  border-bottom: 1px solid var(--fb-border);
  flex-wrap: wrap;
}
.fb-toolbar-sep { width: 1px; height: 26px; background: var(--fb-border); margin: 0 3px; flex-shrink: 0; }
.fb-toolbar-label {
  font-size: .65rem; font-weight: 700; color: var(--fb-muted);
  text-transform: uppercase; letter-spacing: .1em; white-space: nowrap;
}
.fb-tool-btn {
  background: transparent; border: 1px solid transparent;
  color: var(--fb-text); border-radius: 7px; width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background .15s, border-color .15s, color .15s;
  flex-shrink: 0;
}
.fb-tool-btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2; pointer-events: none; }
.fb-tool-btn:hover { background: var(--fb-border); border-color: var(--fb-border); }
.fb-tool-btn.fb-active { background: rgba(91,106,240,.2); border-color: var(--fb-accent); color: var(--fb-accent); }

.fb-tool-select {
  background: var(--fb-surface); border: 1px solid var(--fb-border);
  color: var(--fb-text); border-radius: 7px; padding: 5px 7px;
  font-size: .75rem; cursor: pointer; outline: none;
  transition: border-color .15s;
}
.fb-tool-select:hover, .fb-tool-select:focus { border-color: var(--fb-accent); }

/* ─── Cropper canvas area ────────────────────────────────────────── */
.fb-cropper-area {
  width: 100%;
  min-height: 260px;
  max-height: 52vh;
  background: #080a12;
  overflow: hidden;
}
.fb-cropper-img { display: block; max-width: 100%; }

/* ─── Modal footer ───────────────────────────────────────────────── */
.fb-modal-footer {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 10px; padding: 12px 18px;
  border-top: 1px solid var(--fb-border);
  background: var(--fb-panel); flex-wrap: wrap;
}
.fb-size-badge {
  font-size: .7rem; color: var(--fb-muted);
  background: var(--fb-bg); border: 1px solid var(--fb-border);
  border-radius: 6px; padding: 4px 10px; margin-right: auto; white-space: nowrap;
}

/* ─── Camera modal ───────────────────────────────────────────────── */
.fb-camera-modal { justify-content: center; }
.fb-camera-card {
  background: var(--fb-surface); border: 1px solid var(--fb-border);
  border-radius: 20px; overflow: hidden;
  width: 100%; max-width: 540px;
  box-shadow: 0 24px 80px rgba(0,0,0,.7);
}
.fb-camera-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 18px; border-bottom: 1px solid var(--fb-border);
  background: var(--fb-panel);
}
.fb-camera-header h3 { font-size: .95rem; font-weight: 700; margin: 0; }
.fb-camera-video {
  display: block; width: 100%; max-height: 340px;
  background: #000; object-fit: cover;
}
.fb-camera-footer {
  display: flex; align-items: center; justify-content: center;
  gap: 16px; padding: 16px 18px;
  background: var(--fb-panel); border-top: 1px solid var(--fb-border);
}
.fb-snap-btn {
  width: 56px; height: 56px; border-radius: 50%;
  background: linear-gradient(135deg, var(--fb-accent), var(--fb-accent2));
  border: 3px solid rgba(255,255,255,.2); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s, box-shadow .15s;
  box-shadow: 0 8px 24px rgba(91,106,240,.45);
}
.fb-snap-btn:hover { transform: scale(1.08); }
.fb-snap-btn svg { width: 22px; height: 22px; stroke: #fff; fill: none; stroke-width: 2; }

/* ─── Cropper.js overrides ───────────────────────────────────────── */
.cropper-view-box,
.cropper-face { border-radius: 0; }
.cropper-line { background-color: var(--fb-accent); }
.cropper-point { background-color: var(--fb-accent); }

/* ─── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 540px) {
  .fb-toolbar { gap: 3px; padding: 7px; }
  .fb-tool-btn { width: 30px; height: 30px; }
  .fb-toolbar-label { display: none; }
  .fb-toolbar-sep { display: none; }
}
