:root {
  --bg: #17191c;
  --surface: #1f2226;
  --surface-hover: #262a2f;
  --border: #2c2f34;
  --text: #e8e9eb;
  --muted: #9a9da3;
  --accent: #6d8dfa;
  --accent-hover: #849dfb;
  --ok: #4ade80;
  --ok-bg: rgba(74,222,128,0.12);
  --warn: #fbbf24;
  --warn-bg: rgba(251,191,36,0.12);
  --danger: #f87171;
  --danger-bg: rgba(248,113,113,0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar .brand { font-weight: 700; font-size: 16px; color: var(--text); }
.topbar .who { color: var(--muted); font-size: 13px; }

/* ── Notifiche: campanella ancorata dentro la topbar, accanto a "Esci" ── */
.notif-widget { position: relative; z-index: 50; }
.notif-bell-btn {
  position: relative; width: 34px; height: 34px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); cursor: pointer;
}
.notif-bell-btn:hover { border-color: var(--accent); }
.notif-bell-btn svg { width: 18px; height: 18px; }
.notif-badge {
  position: absolute; top: -6px; right: -6px; min-width: 16px; height: 16px;
  padding: 0 4px; border-radius: 8px; background: var(--danger); color: #1a0a0a;
  font-size: 10px; font-weight: 700; line-height: 16px; text-align: center;
}
.notif-dropdown {
  position: absolute; top: 42px; right: 0; width: 340px; max-height: 420px;
  overflow-y: auto; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}
.notif-dropdown-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-bottom: 1px solid var(--border); font-weight: 700;
}
.notif-read-all-btn {
  background: transparent; border: none; color: var(--accent); font-size: 12px;
  font-weight: 600; cursor: pointer; padding: 0;
}
.notif-item {
  display: block; padding: 10px 14px; border-bottom: 1px solid var(--border);
  color: var(--text);
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--bg); text-decoration: none; }
.notif-item-unread { background: rgba(255,255,255,0.03); }
.notif-item-unread .notif-item-summary { font-weight: 700; }
.notif-item-summary { font-size: 13px; }
.notif-item-time { font-size: 11px; color: var(--muted); margin-top: 2px; }

.container { max-width: 1100px; margin: 0 auto; padding: 28px 24px; }

.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 20px; margin-bottom: 16px;
}
.panel-urgent { border-color: var(--danger); }

h1 { font-size: 20px; font-weight: 700; margin: 0 0 6px; }
h2 { font-size: 13px; font-weight: 700; margin: 0 0 14px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

.field, select, input[type=text], input[type=email], input[type=password] {
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  padding: 9px 11px; border-radius: 6px; font-size: 14px; width: 100%;
}
.field:focus, select:focus, input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(109,141,250,0.18); }
.field-required { border-color: var(--danger) !important; box-shadow: 0 0 0 3px rgba(248,113,113,0.18) !important; }
.field-required::placeholder { color: var(--danger); }

.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 38px; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: none; border: none; padding: 4px; cursor: pointer;
  color: var(--muted); display: flex; align-items: center;
}
.pw-toggle:hover { color: var(--text); }
.pw-toggle svg { width: 18px; height: 18px; }

button, .btn {
  background: var(--accent); color: #0d1117; border: none; border-radius: 6px;
  padding: 9px 16px; font-size: 13px; cursor: pointer; font-weight: 700;
}
button:hover { background: var(--accent-hover); }
button.secondary { background: transparent; border: 1px solid var(--border); color: var(--text); font-weight: 600; }
button.secondary:hover { background: var(--surface-hover); border-color: var(--muted); }
button.danger { background: var(--danger); color: #1a0a0a; }
button.danger:hover { background: #fa8b8b; }
button:disabled { background: var(--border); color: var(--muted); cursor: not-allowed; }

.btn-link {
  display: inline-block; padding: 9px 16px; border-radius: 6px;
  background: var(--accent); color: #0d1117; font-weight: 700;
  text-decoration: none;
}
.btn-link:hover { background: var(--accent-hover); text-decoration: none; }

.row { display: flex; gap: 10px; align-items: center; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; align-items: end; }
.grid-form label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px; border-bottom: 1px solid var(--border); font-size: 13px; }
th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge-pending { background: var(--border); color: var(--muted); }
.badge-approved { background: var(--ok-bg); color: var(--ok); }
.badge-rejected { background: var(--danger-bg); color: var(--danger); }
.badge-draft { background: var(--warn-bg); color: var(--warn); }
.badge-published { background: var(--ok-bg); color: var(--ok); }
.badge-role { background: rgba(109,141,250,0.15); color: var(--accent); }

.fb-section-title { font-size: 13px; font-weight: 700; margin: 0 0 10px; }
.fb-section-title-rejected { color: var(--danger); }

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }

.photo-group { margin-bottom: 32px; }
.photo-group-title {
  font-size: 15px; font-weight: 700; text-transform: none; letter-spacing: normal;
  color: var(--text); margin-bottom: 14px; padding-bottom: 8px; border-bottom: 1px solid var(--border);
}
.photo-card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.photo-card img { width: 100%; aspect-ratio: 2/3; object-fit: cover; display: block; background: var(--bg); }
.photo-card .body { padding: 12px; }
.photo-card .sku { font-weight: 700; margin-bottom: 6px; word-break: break-all; }
.photo-card .actions { display: flex; gap: 8px; margin-top: 10px; }

.notes-list { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.notes-list .note {
  position: relative; padding: 10px 32px 10px 12px; border-radius: 8px;
  background: var(--bg); border: 1px solid var(--border);
  font-size: 14px; line-height: 1.5; color: var(--text);
}
.notes-list .note b { display: block; margin-bottom: 4px; color: var(--accent); font-size: 13px; }
.notes-list .note .note-body { white-space: pre-wrap; }
.note-delete-form { position: absolute; top: 6px; right: 6px; margin: 0; }
.note-delete-btn {
  background: none; border: none; color: var(--muted); font-size: 16px; line-height: 1;
  cursor: pointer; padding: 4px; border-radius: 4px;
}
.note-delete-btn:hover { background: var(--danger-bg); color: var(--danger); }

.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg); }
.login-box { width: 340px; }
.error-msg { color: var(--danger); font-size: 13px; margin-bottom: 12px; background: var(--danger-bg); padding: 8px 12px; border-radius: 6px; }

.hint { color: var(--muted); font-size: 12px; }

.breadcrumb { font-size: 13px; color: var(--muted); margin-bottom: 16px; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .sep { margin: 0 6px; }
.breadcrumb .current { color: var(--text); }

.zone { margin-bottom: 36px; }
.zone-header { margin-bottom: 14px; }
.zone-header h1 { margin-bottom: 4px; }
.zone-raw { padding: 18px; border: 1px solid var(--border); border-radius: 10px; background: rgba(251,191,36,0.03); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 24px; }
.tab-btn {
  background: none; border: none; color: var(--muted); font-weight: 600;
  padding: 10px 16px; cursor: pointer; font-size: 14px;
  border-bottom: 2px solid transparent; border-radius: 0;
}
.tab-btn:hover { color: var(--text); background: none; }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-btn .tab-count {
  display: inline-block; background: var(--border); color: var(--muted);
  font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; margin-left: 6px;
}
.tab-btn.active .tab-count { background: rgba(109,141,250,0.18); color: var(--accent); }
.tab-panel[hidden] { display: none; }

.drop-zone {
  border: 2px dashed var(--border); border-radius: 8px; padding: 28px;
  text-align: center; transition: border-color 0.15s, background 0.15s; background: var(--bg);
}
.drop-zone-active { border-color: var(--accent); background: rgba(109,141,250,0.06); }
.drop-zone p { margin: 6px 0; }

.page-drop-overlay {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(15,17,20,0.85);
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.page-drop-overlay[hidden] { display: none; }
.page-drop-overlay-inner {
  border: 3px dashed var(--accent); border-radius: 16px;
  padding: 60px 80px; background: rgba(109,141,250,0.08);
}
.page-drop-overlay-inner p { font-size: 22px; font-weight: 700; color: var(--text); margin: 0; }

.filebrowser-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; gap: 12px; flex-wrap: wrap; }
.fb-breadcrumb { font-size: 15px; font-weight: 700; }
.fb-breadcrumb a { color: var(--text); }
.fb-breadcrumb a:hover { color: var(--accent); }
.fb-breadcrumb .sep { color: var(--muted); margin: 0 6px; font-weight: 400; }

.fb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
.fb-grid .photo-card { cursor: grab; }
.fb-grid .photo-card:active { cursor: grabbing; }

.fb-tile-folder {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 24px 12px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; cursor: pointer; transition: background 0.1s, border-color 0.1s;
}
.fb-tile-folder:hover { background: var(--surface-hover); }
.fb-tile-folder.fb-tile-drop-active { border-color: var(--accent); background: rgba(109,141,250,0.1); }
.fb-tile-folder svg { width: 36px; height: 36px; color: var(--warn); }
.fb-tile-name { font-weight: 600; font-size: 13px; text-align: center; word-break: break-word; }
.fb-tile-delete {
  position: absolute; top: 6px; right: 6px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--border); color: var(--muted);
  font-size: 14px; line-height: 1; cursor: pointer; padding: 0;
  display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity 0.1s;
}
.fb-tile-folder:hover .fb-tile-delete { opacity: 1; }
.fb-tile-delete:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

.upload-queue-panel {
  position: fixed; bottom: 20px; right: 20px; width: 320px; z-index: 1500;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4); overflow: hidden;
}
.upload-queue-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; background: var(--bg); font-weight: 700; font-size: 13px;
}
.upload-queue-toggle {
  background: none; border: none; color: var(--muted); font-size: 16px;
  cursor: pointer; padding: 0 6px; font-weight: 700;
}
.upload-queue-toggle:hover { color: var(--text); background: none; }
.upload-queue-list { max-height: 240px; overflow-y: auto; padding: 6px 0; }
.upload-queue-row {
  display: flex; justify-content: space-between; gap: 8px;
  padding: 6px 14px; font-size: 12px; color: var(--muted);
}
.upload-queue-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.upload-queue-pct { flex-shrink: 0; font-weight: 700; }
.upload-queue-row.upload-queue-done .upload-queue-pct { color: var(--ok); }
.upload-queue-row.upload-queue-failed .upload-queue-pct { color: var(--danger); }

.raw-batch-list { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }

.upload-progress-wrap { margin-top: 12px; }
.upload-progress-bar { background: var(--border); border-radius: 999px; height: 8px; overflow: hidden; }
.upload-progress-fill { background: var(--accent); height: 100%; width: 0%; transition: width 0.15s ease-out; }

.file-preview-list {
  display: flex; flex-direction: column; gap: 8px;
  max-height: 260px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: 8px; padding: 12px; background: var(--bg);
}
.file-preview-group { border-bottom: 1px solid var(--border); padding-bottom: 10px; }
.file-preview-group:last-child { border-bottom: none; padding-bottom: 0; }
.file-preview-group-title { font-weight: 700; font-size: 13px; margin-bottom: 8px; }
.file-preview-names { color: var(--muted); font-size: 12px; line-height: 1.6; word-break: break-word; }

.file-preview-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px;
}
.file-preview-thumb { display: flex; flex-direction: column; gap: 4px; }
.file-preview-thumb img {
  width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface);
}
.file-preview-thumb-name {
  font-size: 10px; color: var(--muted); text-align: center;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.raw-alert {
  display: flex; align-items: center; gap: 12px;
  background: var(--warn-bg); border: 1px solid rgba(251,191,36,0.35);
  border-radius: 8px; padding: 14px 18px; margin-bottom: 20px;
  color: var(--text); text-decoration: none; font-weight: 600;
}
.raw-alert:hover { background: rgba(251,191,36,0.18); text-decoration: none; }
.raw-alert-count {
  background: var(--warn); color: #1a1200; font-weight: 800;
  border-radius: 999px; min-width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center; padding: 0 8px;
}

.lightbox {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.92);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 40px;
}
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 100%; max-height: 85vh; object-fit: contain; }
.lightbox-close {
  position: absolute; top: 16px; right: 24px; font-size: 32px; line-height: 1;
  background: none; border: none; color: #fff; cursor: pointer;
}
.lightbox-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  font-size: 40px; line-height: 1; background: none; border: none;
  color: #fff; cursor: pointer; padding: 8px 16px;
}
.lightbox-prev { left: 8px; }
.lightbox-next { right: 8px; }
.lightbox-caption {
  position: absolute; bottom: 20px; left: 0; right: 0; text-align: center;
  color: #d1d5db; font-size: 13px;
}

/* ── Griglia densa stile Drive: cartelle e foto come tile quadrate compatte ── */
.fb-grid-dense { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.fb-folders-row { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); margin-bottom: 18px; }
.fb-folders-row:empty { margin-bottom: 0; }

.fb-tile-dense {
  position: relative; cursor: pointer; border-radius: 8px; overflow: hidden;
  border: 1px solid var(--border); background: var(--bg);
  transition: border-color 0.1s, transform 0.1s;
}
.fb-tile-dense:hover { border-color: var(--accent); }

.fb-tile-dense-folder {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; aspect-ratio: 1; padding: 12px;
}
.fb-tile-dense-folder svg { width: 34px; height: 34px; color: var(--warn); }

.fb-tile-dense-photo { aspect-ratio: 2/3; }
.fb-tile-dense-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }

.fb-tile-dense-version {
  position: absolute; top: 6px; left: 6px; z-index: 1;
  font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 4px;
  background: rgba(0,0,0,0.65); color: #fff;
}

.fb-tile-dense-name {
  font-size: 11px; font-weight: 600; text-align: center; padding: 0 4px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%;
}
.fb-tile-dense-photo .fb-tile-dense-name {
  position: absolute; bottom: 0; left: 0; right: 0; padding: 4px 6px;
  background: linear-gradient(transparent, rgba(0,0,0,0.75));
  color: #fff; text-align: left; white-space: nowrap;
}

.fb-dot {
  position: absolute; top: 6px; right: 6px; width: 10px; height: 10px;
  border-radius: 50%; border: 2px solid var(--bg); z-index: 1;
}
.fb-dot-pending { background: var(--muted); }
.fb-dot-ok { background: var(--ok); }
.fb-dot-danger { background: var(--danger); }

/* ── Pannello dettaglio foto (lightbox con azioni) ───────────────────────── */
.detail-overlay { position: fixed; inset: 0; z-index: 2000; }
.detail-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.88); }
.detail-box {
  position: relative; z-index: 1; display: flex; height: 100%;
  max-width: 1100px; margin: 0 auto; padding: 40px 20px;
}
.detail-image-wrap { flex: 1; display: flex; align-items: center; justify-content: center; min-width: 0; }
.detail-image-wrap img { max-width: 100%; max-height: 100%; object-fit: contain; }
.detail-sidebar {
  width: 320px; flex-shrink: 0; background: var(--surface); border-radius: 10px;
  padding: 20px; margin-left: 20px; overflow-y: auto;
}
.detail-close {
  position: absolute; top: 10px; right: 10px; z-index: 2; font-size: 28px; line-height: 1;
  background: none; border: none; color: #fff; cursor: pointer; padding: 6px;
}
.detail-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
  font-size: 36px; line-height: 1; background: none; border: none; color: #fff; cursor: pointer; padding: 8px 14px;
}
.detail-prev { left: 4px; }
.detail-next { right: 340px; }
@media (max-width: 900px) {
  .detail-box { flex-direction: column; padding: 20px; }
  .detail-sidebar { width: auto; margin-left: 0; margin-top: 16px; max-height: 40vh; }
  .detail-next { right: 4px; }
}

/* ── Modal generica (usata per la nota generale sul batch) ───────────────── */
.modal-overlay { position: fixed; inset: 0; z-index: 2100; display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal-overlay[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.75); }
.modal-box {
  position: relative; z-index: 1; width: 100%; max-width: 640px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 24px;
}
.modal-textarea { width: 100%; min-height: 260px; resize: vertical; font-family: inherit; }

/* ── Tour guidato: overlay a step con spotlight sull'elemento reale ── */
.tour-overlay { position: fixed; inset: 0; z-index: 3000; background: rgba(0,0,0,0.55); }
.tour-spotlight {
  position: fixed; border-radius: 10px;
  box-shadow: 0 0 0 4000px rgba(0,0,0,0.55);
  border: 2px solid var(--accent);
  transition: top 0.2s, left 0.2s, width 0.2s, height 0.2s;
  pointer-events: none;
}
.tour-box {
  position: fixed; width: 320px; max-width: calc(100vw - 24px);
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 16px; box-shadow: 0 12px 32px rgba(0,0,0,0.45);
  transition: top 0.2s, left 0.2s;
}
.tour-step-title { font-weight: 700; font-size: 15px; margin-bottom: 6px; }
.tour-step-body { font-size: 13px; color: var(--muted); line-height: 1.5; }
.tour-box-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; }
.tour-step-count { font-size: 12px; color: var(--muted); }

/* ── Tooltip pieghevole: icona "i" che espande una spiegazione inline ── */
.tip-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--border);
  background: transparent; color: var(--muted); font-size: 11px; font-weight: 700;
  cursor: pointer; margin-left: 6px; vertical-align: middle; padding: 0;
}
.tip-toggle:hover { border-color: var(--accent); color: var(--accent); }
.tip-body {
  display: none; margin-top: 8px; padding: 10px 12px; border-radius: 8px;
  background: var(--bg); border: 1px solid var(--border); color: var(--muted);
  font-size: 12px; line-height: 1.5;
}
.tip-body.tip-open { display: block; }

/* ── Galleria pubblica: griglia minimal + lightbox, nessuna azione ── */
.pg-tile {
  border-radius: 8px; overflow: hidden; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface);
  transition: border-color 0.15s;
}
.pg-tile:hover { border-color: var(--accent); }
.pg-tile img { width: 100%; aspect-ratio: 2/3; object-fit: cover; display: block; }

.pg-lightbox {
  position: fixed; inset: 0; z-index: 2000; background: rgba(0,0,0,0.92);
  display: flex; align-items: center; justify-content: center;
}
.pg-lightbox[hidden] { display: none; }
.pg-lightbox img { max-width: 90vw; max-height: 90vh; object-fit: contain; }
