/* === TEMA NEON CURATOR (Brand Netlab) === */
:root, [data-theme="neon"] {
  --primary: #7e4391;
  --primary-strong: #eca8fe;
  --secondary: #caf155;
  --secondary-text: #3a4a00;
  --surface: #f1f7ff;
  --surface-low: #e6f2ff;
  --surface-mid: #dce9f7;
  --surface-high: #ffffff;
  --text: #25303a;
  --muted: #708090;
  --line: rgba(163, 174, 187, 0.15);
  --shadow: 0 20px 40px rgba(37, 48, 58, 0.06);
  --danger: #ba1a1a;
  --sidebar-bg: rgba(230, 242, 255, 0.92);
  --brand-gradient: linear-gradient(135deg, #7e4391, #eca8fe);
  --login-bg: rgba(126, 67, 145, 0.08);
  --login-card-bg: #ffffff;
  --radius-xl: 3rem;
  --radius-md: 1.5rem;
  --radius-sm: 1rem;
  --radius-pill: 9999px;
}

/* === TEMA MINIMAL === */
[data-theme="minimal"] {
  --primary: #36454f;
  --primary-strong: #4a5d6a;
  --secondary: #e8e8e8;
  --secondary-text: #36454f;
  --surface: #fafafa;
  --surface-low: #f5f5f5;
  --surface-mid: #eeeeee;
  --surface-high: #ffffff;
  --text: #1a1a1a;
  --muted: #708090;
  --line: rgba(0, 0, 0, 0.08);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 8px 24px rgba(0, 0, 0, 0.04);
  --danger: #c62828;
  --sidebar-bg: #ffffff;
  --brand-gradient: linear-gradient(135deg, #36454f, #708090);
  --login-bg: rgba(54, 69, 79, 0.04);
  --login-card-bg: #ffffff;
  --radius-xl: 16px;
  --radius-md: 10px;
  --radius-sm: 8px;
  --radius-pill: 9999px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: "Manrope", sans-serif;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
}

button, input, textarea, select { font: inherit; }
h1, h2, h3, h4, .nav-link, .cta, .filter-chip { font-family: "Plus Jakarta Sans", sans-serif; }

.app-shell {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--sidebar-bg);
  backdrop-filter: blur(16px);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  box-shadow: 12px 0 28px rgba(19,28,38,.04);
}

.brand { display:flex; gap:12px; align-items:center; }
.brand-mark {
  width: 42px; height: 42px; border-radius: var(--radius-sm);
  display:grid; place-items:center;
  background: var(--brand-gradient); color:#fff; font-weight:800;
}
.brand h1, .topbar h2 { margin:0; color: var(--primary); }
.brand p, .tiny { margin:0; font-size:10px; text-transform:uppercase; letter-spacing:.18em; color:rgba(95,91,102,.72); font-weight:700; }

.nav { display:grid; gap:8px; }
.nav-link {
  border:0; background:transparent; text-align:left; cursor:pointer;
  border-radius: var(--radius-md); padding:12px 14px; font-weight:700; color:var(--muted);
  transition: background .2s, color .2s;
}
.nav-link.active { background: var(--secondary); color: var(--secondary-text); }
.ghost-link { border:0; background:transparent; padding:0; color:var(--primary); cursor:pointer; text-align:left; font-weight:700; }
.sidebar-footer { margin-top:auto; display:grid; gap:6px; padding:8px; }

.main { padding: 18px; overflow-x: hidden; }
.topbar { display:flex; justify-content:space-between; align-items:center; gap:16px; margin-bottom:14px; }
.eyebrow { margin:0 0 6px; text-transform:uppercase; letter-spacing:.22em; font-size:10px; color:rgba(95,91,102,.7); font-weight:800; }
.topbar h2 { font-size:26px; line-height:1; }
.topbar-actions { display:flex; gap:10px; align-items:center; }
.topbar input {
  width:min(360px, 44vw); border:0; border-radius:999px; padding:10px 14px; background:var(--surface-mid);
}

.screen { display:none; }
.screen.active { display:block; }

.section-head, .actions-row, .chip-row, .tab-row, .form-grid, .workspace-two, .stats-grid, .provider-grid {
  display:flex;
  gap:12px;
  flex-wrap:wrap;
}
.section-head { justify-content:space-between; align-items:flex-start; margin-bottom:12px; }
.section-head.compact { margin-bottom:10px; }

.card, .project-card, .stat-card {
  background: var(--surface-high);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  transition: box-shadow .25s, transform .25s;
}
.card { padding: 14px; }
.project-grid {
  display:grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.project-card { overflow:hidden; }
.project-visual { background: var(--surface-low); padding:10px; min-height: 136px; }
.project-visual-split { display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.project-mini-visual {
  border-radius: 18px; overflow:hidden; background:#fff; min-height:116px; display:grid; place-items:center;
}
.project-mini-visual img { width:100%; height:116px; object-fit:contain; display:block; }
.project-copy { padding:12px; display:grid; gap:6px; }
.project-copy strong { font-size:14px; }

.cta, .cta-secondary, .filter-chip, .download-link, .actions-row button {
  border:0; border-radius: var(--radius-md); padding:9px 13px; cursor:pointer; text-decoration:none;
  transition: transform .15s, box-shadow .15s;
}
.cta { background: var(--brand-gradient); color:#fff; font-weight:800; box-shadow:0 8px 20px rgba(0,0,0,.12); }
.cta:hover { transform: translateY(-1px); box-shadow:0 12px 28px rgba(0,0,0,.16); }
.cta-secondary, .filter-chip { background: var(--surface-mid); color: var(--text); font-weight:700; }
.filter-chip.active { background: var(--secondary); color: var(--secondary-text); }

label { display:grid; gap:6px; font-weight:700; color: var(--text); }
input, textarea, select {
  border:1px solid transparent; border-radius: var(--radius-sm); background:var(--surface-low); padding:10px 12px; color:var(--text);
  transition: outline .15s, background .15s;
}
textarea { resize: vertical; min-height: 100px; }
input:focus, textarea:focus, select:focus { outline:2px solid rgba(94,35,111,.18); }

.workspace-two { display:grid; grid-template-columns:1fr 1fr; gap:14px; }
.workspace-two.tight-layout { grid-template-columns: repeat(2,minmax(0,1fr)); }
.provider-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); width:100%; }
.form-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); width:100%; }
.summary-block, .provider-block {
  background: var(--surface-low); border-radius: var(--radius-md); padding:12px; display:grid; gap:8px;
}

.tab-row { margin-bottom:12px; }
.tab-btn {
  border:0; background:var(--surface-mid); color:var(--text); cursor:pointer; border-radius:999px; padding:9px 14px; font-weight:700;
}
.tab-btn.active { background: var(--secondary); color: var(--secondary-text); }
.workspace-tab, .settings-tab { display:none; }
.workspace-tab.active, .settings-tab.active { display:block; }

.empty-state {
  background: var(--surface-high); border-radius: var(--radius-xl); box-shadow:var(--shadow); padding:24px; text-align:center;
}
.empty-card { padding:24px; text-align:center; background:var(--surface-high); border-radius: var(--radius-xl); box-shadow:var(--shadow); }

.side-visuals {
  display:grid;
  grid-template-columns: minmax(0,1fr) minmax(0,1fr);
  gap: 14px;
  margin-bottom: 12px;
}
.mini-label { margin:0 0 8px; font-size:11px; text-transform:uppercase; letter-spacing:.18em; color:rgba(95,91,102,.75); font-weight:800; }
.visual-frame {
  position:relative;
  min-height: 360px;
  border-radius: var(--radius-xl);
  background: var(--surface-low);
  overflow:hidden;
  display:grid;
  place-items:center;
}
.visual-frame img, .history-thumb img, .history-modal-visual img, #lightboxImage {
  width:100%;
  height:100%;
  object-fit:contain;
  display:block;
}
.preview-clickable { cursor: zoom-in; }
.thumb-placeholder { text-align:center; color:var(--muted); padding:18px; }
.thumb-placeholder.compact { font-size:11px; }
.source-dropzone { border:2px dashed rgba(94,35,111,.16); cursor:pointer; }
.source-dropzone.dragover { border-color: var(--primary); background:#f5eff8; }
.source-dropzone input[type=file] { display:none !important; }
.preview-crop-btn, .preview-zoom-btn {
  position:absolute; bottom:12px; border:0; border-radius:999px; background:rgba(255,255,255,.95); padding:8px 12px; font-weight:700; cursor:pointer;
}
.preview-crop-btn { left:12px; }
.preview-zoom-btn { right:12px; }

.compact-grid { display:grid; grid-template-columns:1fr 1fr; gap:12px; margin-bottom:12px; }

.history-list { display:grid; gap:10px; }
.history-row {
  background: var(--surface-low); border:1px solid var(--line); border-radius:18px; padding:10px; cursor:pointer;
}
.history-row-layout { display:grid; grid-template-columns:72px 1fr; gap:10px; align-items:center; }
.history-thumb { background:#fff; border-radius:12px; overflow:hidden; height:72px; }
.history-row-main, .history-row-meta { display:flex; justify-content:space-between; gap:8px; flex-wrap:wrap; }
.history-note { margin:4px 0 0; }

.description-article { display:grid; grid-template-columns:1.1fr .9fr; gap:16px; }
.card-surface { background:var(--surface-low); border-radius:18px; padding:14px; }
.faq-column { display:grid; gap:10px; }
.faq-item { background:var(--surface-low); border-radius:16px; padding:12px; }

.log-list { display:grid; gap:10px; }
.log-item, .provider-cost-card {
  background: var(--surface-low); border-radius:16px; padding:12px;
}
.usage-row { display:flex; justify-content:space-between; gap:8px; }
.stats-grid { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:12px; margin-bottom:12px; }
.stat-card { padding:14px; }
.stat-label, .muted { color: var(--muted); }
.stat-value { margin:0; font-size:24px; font-weight:800; color:var(--primary); }
.accent { background:linear-gradient(180deg,#fff,#faf3ff); }
.provider-costs-grid { display:grid; gap:10px; }
.top-space-block { height: 14px; }
.view-meta-grid { margin-top: 14px; }
.prompt-section {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}
.base-prompt-textarea {
  background: #f8f6fb;
  color: var(--muted);
}
.prompt-actions {
  margin-top: -2px;
}
.side-visual {
  min-width: 0;
}
.image-dropzone {
  min-height: 260px;
  border-radius: 18px;
  background: var(--surface-low);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 12px;
}
.image-dropzone img {
  width: 100%;
  height: 100%;
  max-height: 320px;
  object-fit: contain;
  display: block;
}
.image-dropzone.passive {
  cursor: default;
}
.side-visual .actions-row {
  margin-top: 8px;
}
.side-visual .actions-row button[disabled] {
  opacity: .45;
  cursor: not-allowed;
}

.article-list { display:grid; gap:10px; max-height: 560px; overflow:auto; }
.article-row {
  display:grid;
  grid-template-columns: minmax(0,1fr) auto;
  align-items:center;
  gap:12px;
  background: var(--surface-low);
  border-radius:16px;
  padding:10px 12px;
  border: 1px solid var(--line);
}
.article-row.selected {
  border-color: rgba(94,35,111,.45);
  box-shadow: inset 0 0 0 1px rgba(94,35,111,.18);
}
.compact-article-list {
  max-height: 220px;
  margin-bottom: 12px;
}
.article-row-main {
  min-width: 0;
  display:flex;
  align-items:center;
  gap:10px;
}
.article-code {
  flex: 0 0 auto;
  font-size: 13px;
}
.article-description {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.compact-button {
  padding: 7px 11px;
  min-width: 0;
  font-size: 12px;
}
.article-item {
  background: var(--surface-low); border-radius:16px; padding:12px; display:grid; gap:8px;
}
.article-item h4 { margin:0; }
.article-meta { display:flex; gap:8px; flex-wrap:wrap; }
.chip {
  display:inline-flex; align-items:center; gap:6px; background:#fff; border-radius:999px; padding:5px 9px; font-size:11px; font-weight:700;
}
.chip-list { display:flex; gap:8px; flex-wrap:wrap; }

.login-screen {
  position:fixed; inset:0; background: var(--login-bg);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  display:grid; place-items:center; z-index:1000;
}
.login-card {
  width:min(420px, calc(100vw - 32px));
  background: var(--login-card-bg); border-radius: var(--radius-xl); box-shadow: var(--shadow); padding:28px; display:grid; gap:14px;
}
.login-card h1 { background: var(--brand-gradient); -webkit-background-clip:text; -webkit-text-fill-color:transparent; background-clip:text; }

/* --- Selettore tema nel login --- */
.theme-selector { display:flex; gap:8px; justify-content:center; margin-top:4px; }
.theme-btn {
  border:2px solid var(--line); border-radius: var(--radius-pill); padding:7px 14px;
  font-size:12px; font-weight:700; cursor:pointer; background:var(--surface-low); color:var(--text);
  transition: border-color .2s, background .2s;
}
.theme-btn.active { border-color: var(--primary); background: var(--surface-mid); }
.theme-btn:hover { border-color: var(--primary); }
.error-text { color: var(--danger); font-weight:700; }

.overlay {
  position:fixed; inset:0; background:rgba(14,20,28,.5); display:grid; place-items:center; padding:18px; z-index:1200;
}
.overlay-panel {
  width:min(1100px, calc(100vw - 36px)); max-height:calc(100vh - 36px); overflow:auto; background:var(--surface-high); border-radius: var(--radius-xl); box-shadow:var(--shadow); padding:18px;
}
.overlay-close { border:0; background:var(--surface-mid); padding:8px 12px; border-radius:12px; cursor:pointer; }
.image-panel img { width:100%; height:auto; display:block; }
.history-modal-grid { display:grid; grid-template-columns:minmax(0,1fr) 320px; gap:16px; }
.history-modal-visual { min-height:380px; background:var(--surface-low); border-radius:18px; overflow:hidden; }
.article-modal-grid { display:grid; grid-template-columns: minmax(0,1fr) 360px; gap:16px; }

.crop-layout { display:grid; grid-template-columns:minmax(0,1fr) 320px; gap:16px; }
.crop-preview {
  position:relative; background:var(--surface-low); border-radius:20px; min-height:520px; overflow:hidden; display:grid; place-items:center;
}
.crop-preview img { width:100%; height:100%; object-fit:contain; display:block; transform-origin:center center; }
.crop-controls { background:var(--surface-low); border-radius:20px; padding:16px; display:grid; gap:16px; align-content:start; }
.crop-frame {
  position:absolute; border:2px solid var(--primary); border-radius:18px; cursor:move;
}
.crop-handle {
  position:absolute; width:14px; height:14px; border-radius:999px; background:var(--primary); border:2px solid #fff;
}
.crop-handle.nw { left:-7px; top:-7px; cursor:nwse-resize; }
.crop-handle.ne { right:-7px; top:-7px; cursor:nesw-resize; }
.crop-handle.sw { left:-7px; bottom:-7px; cursor:nesw-resize; }
.crop-handle.se { right:-7px; bottom:-7px; cursor:nwse-resize; }
.crop-handle.n { left:calc(50% - 7px); top:-7px; cursor:ns-resize; }
.crop-handle.s { left:calc(50% - 7px); bottom:-7px; cursor:ns-resize; }
.crop-handle.e { right:-7px; top:calc(50% - 7px); cursor:ew-resize; }
.crop-handle.w { left:-7px; top:calc(50% - 7px); cursor:ew-resize; }

.status-pill {
  border-radius:999px; background:var(--secondary); color:var(--secondary-text); font-weight:800; padding:7px 11px;
}

.admin-only.hidden-by-role { display:none !important; }

@media (max-width: 1100px) {
  .app-shell { grid-template-columns:1fr; }
  .sidebar { position:sticky; top:0; z-index:100; }
  .workspace-two, .provider-grid, .form-grid, .side-visuals, .description-article, .history-modal-grid, .crop-layout, .stats-grid {
    grid-template-columns:1fr !important;
  }
}

@media (max-width: 720px) {
  .main { padding:12px; }
  .topbar { flex-direction:column; align-items:flex-start; }
  .topbar input { width:100%; }
  .visual-frame { min-height: 280px; }
  .compact-grid { grid-template-columns:1fr; }
  .image-dropzone {
    min-height: 220px;
  }
  .article-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }
  .article-row-main {
    display:grid;
    gap:4px;
  }
  .article-description {
    white-space: normal;
    overflow: visible;
  }
}
