/* Styles ported from backup/inc/layout.php */
:root{
  --bg:#ffffff;
  --card:#ffffff;
  --border:#000000;
  --border-hover:#000000;
  --text:#000000;
  --muted:#222222;
}

/* DARK THEME */
html[data-theme="dark"]{
  --bg: #0e0a1f;
  --card: #171330;
  --border: #2c3270;
  --border-hover: #4b5cff;
  --text: #ffffff;
  --muted: #d6d9ff;
}

html[data-theme="dark"] body{
  background:
    radial-gradient(
      1200px 600px at top right,
      rgba(75,92,255,0.18),
      transparent 60%
    ),
    radial-gradient(
      900px 500px at bottom left,
      rgba(140,90,255,0.15),
      transparent 60%
    ),
    var(--bg);
  color: var(--text);
}

html[data-theme="dark"] header{
  background: linear-gradient(
    180deg,
    #1a1640 0%,
    #13102b 100%
  );
  border-bottom: 1px solid var(--border);
}

html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] h4,
html[data-theme="dark"] h5,
html[data-theme="dark"] h6,
html[data-theme="dark"] p,
html[data-theme="dark"] span,
html[data-theme="dark"] label{
  color: var(--text);
}

html[data-theme="dark"] .card,
html[data-theme="dark"] .panel{
  background: linear-gradient(
    180deg,
    #1a1640 0%,
    #13102b 100%
  );
  border: 1px solid var(--border);
  box-shadow:
    0 12px 35px rgba(0,0,0,.55),
    inset 0 1px 0 rgba(255,255,255,.05);
}

html[data-theme="dark"] .card:hover{
  border-color: var(--border-hover);
  box-shadow:
    0 18px 50px rgba(0,0,0,.7),
    0 0 0 1px rgba(75,92,255,.35);
}

html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] button{
  background:#1c1848;
  color:#ffffff;
  border:1px solid var(--border) !important;
}

html[data-theme="dark"] .btn{
  background:#1c1848;
  color:#ffffff;
  border:1px solid var(--border);
}

html[data-theme="dark"] .btn:hover{
  background:#1c1848;
  color:#ffffff;
  border-color:var(--border-hover);
}

html[data-theme="dark"] .btn.primary,
html[data-theme="dark"] .btn.primary:hover{
  background:#1c1848;
  color:#ffffff;
  border-color:var(--border-hover);
}

html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder{ color:#cfd3ff; }

html[data-theme="dark"] a{ color:#ffffff; }
html[data-theme="dark"] a:hover{ color:#9aa6ff; }

.brand-link{ color:inherit; }

*{
  box-sizing:border-box;
  font-family:'Oswald',system-ui,-apple-system,Arial !important;
  -webkit-tap-highlight-color: transparent;
}

body{
  margin:0;
  background:var(--bg);
  color:var(--text);
  letter-spacing:.3px;
}

a{text-decoration:none;color:inherit}

/* Top actions (only: Torna al sito) */
.top-actions{
  max-width:1400px;
  margin:14px auto 0;
  padding:0 12px;
}

:where(a, button, input, textarea, select, [tabindex]):focus{ outline:none; }
:where(a, button, input, textarea, select, [tabindex]):focus:not(:focus-visible){ outline:none; box-shadow:none; }
:where(a, button, input, textarea, select, [tabindex]):focus-visible{
  outline:2px solid var(--border-hover);
  outline-offset:2px;
}

/* HEADER MINIMAL */
header{
  position:sticky;
  top:0;
  z-index:40;
  background:var(--card);
  border-bottom:1px solid #ddd;
}

.header-wrap{
  max-width:1400px;
  margin:0 auto;
  padding:14px 14px;
  display:flex;
  align-items:center;
  justify-content:space-between;
}

.brand{
  font-size:30px;
  font-weight:700;
  letter-spacing:.6px;
  text-transform:uppercase;
}

.actions a{ font-size:14px; font-weight:500; }

/* Ensure actions layout is flex everywhere */
.actions{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  flex-wrap:nowrap;
  gap:8px;
}

.brand-link{
  display:block;
  max-width:100%;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

/* Link under header (left) */
.subheader-left{
  max-width:1400px;
  margin:10px auto 0;
  padding:0 12px;
  display:flex;
  justify-content:flex-start;
}

/* Actions row under header (center) */
.subheader-actions{
  max-width:1400px;
  margin:10px auto 0;
  padding:0 12px;
  display:flex;
  align-items:center;
  justify-content:center;
  flex-wrap:nowrap;
  gap:10px;
}

.generator-btn{
  min-width:160px;
  padding-left:12px;
  padding-right:12px;
}

/* Keep the "Generatore / Torna al sito" row compact */
.subheader-actions .btn{
  padding:9px 12px;
}

@media (max-width: 600px){
  .subheader-left{ padding:0 10px; }
  .subheader-actions{
    padding:0 10px;
    justify-content:center;
    overflow-x:auto;
    -webkit-overflow-scrolling:touch;
  }
}

/* Mobile header: force single row */
@media (max-width: 600px){
  .header-wrap{
    padding:10px 10px;
    gap:8px;
    flex-wrap:nowrap;
    justify-content:flex-start;
  }

  .brand{
    font-size:20px;
    letter-spacing:.2px;
    text-transform:uppercase;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
    max-width:48vw;
    flex:0 1 auto;
    min-width:0;
  }

  .actions{
    margin-left:auto;
    gap:6px;
    overflow-x:auto;
    -webkit-overflow-scrolling:touch;
    max-width:52vw;
    min-width:0;
  }

  .actions::-webkit-scrollbar{ display:none; }

  .pillbtn,
  .iconbtn{
    flex:0 0 auto;
    margin-right:0;
    padding:7px 9px;
    font-size:13px;
  }

  /* Keep icons, hide label text to save space */
  .pillbtn span{ display:none; }

  /* But allow specific pills (e.g. GALLERIA) to show label next to icon */
  .pillbtn.show-label span{
    display:inline;
  }
}

@media (max-width: 600px){
  /* Keep search + nav buttons on one row too */
  .search-box{
    flex-wrap:nowrap;
  }
  .search-box input{
    min-width:0;
  }

  .nav-btns{
    flex-wrap:nowrap;
    overflow-x:auto;
    -webkit-overflow-scrolling:touch;
    justify-content:flex-start;
  }
  .nav-btns::-webkit-scrollbar{ display:none; }
  .nav-btns a{ flex:0 0 auto; }
}

.iconbtn{
  border:1px solid var(--border);
  background:var(--card);
  color:var(--text);
  padding:8px 10px;
  border-radius:12px;
  cursor:pointer;
  margin-right:8px;
  line-height:1;
}

.iconbtn:hover{ border-color:var(--border-hover); }
html[data-theme="dark"] .iconbtn{ background:var(--card); }
.iconbtn .icon-sun{ display:none; }
html[data-theme="dark"] .iconbtn .icon-sun{ display:inline; }
html[data-theme="dark"] .iconbtn .icon-moon{ display:none; }

.pillbtn{
  display:inline-flex;
  align-items:center;
  gap:8px;
  border:1px solid var(--border);
  background:var(--card);
  color:var(--text);
  padding:8px 12px;
  border-radius:999px;
  cursor:pointer;
  margin-right:8px;
  line-height:1;
  font-size:14px;
  font-weight:500;
  white-space:nowrap;
}
.pillbtn:hover{ border-color:var(--border-hover); }

.pillbtn.pillbtnPulse{
  background: linear-gradient(180deg,#111,#000);
  border-color:#111;
  color:#fff;
  box-shadow: 0 10px 24px rgba(0,0,0,.22);
  -webkit-animation: pillPulse 1.15s ease-in-out infinite !important;
  animation: pillPulse 1.15s ease-in-out infinite !important;
  transform-origin:center;
  will-change: transform, box-shadow, filter;
}

.pillbtn.pillbtnPulse:hover{ border-color:#000; }

html[data-theme="dark"] .pillbtn.pillbtnPulse{
  background: linear-gradient(180deg,#2a2f7a 0%, #1f2360 100%);
  border-color: rgba(120,130,255,.45);
  box-shadow: 0 10px 26px rgba(0,0,0,.55), 0 0 0 1px rgba(75,92,255,.30);
}

@-webkit-keyframes pillPulse{
  0%{ -webkit-transform:translateY(0) scale(1); transform:translateY(0) scale(1); -webkit-filter:brightness(1) saturate(1); filter:brightness(1) saturate(1); opacity:1; box-shadow:0 10px 24px rgba(0,0,0,.22); }
  50%{ -webkit-transform:translateY(-2px) scale(1.085); transform:translateY(-2px) scale(1.085); -webkit-filter:brightness(1.15) saturate(1.15); filter:brightness(1.15) saturate(1.15); opacity:.88; box-shadow:0 18px 44px rgba(0,0,0,.32); }
  100%{ -webkit-transform:translateY(0) scale(1); transform:translateY(0) scale(1); -webkit-filter:brightness(1) saturate(1); filter:brightness(1) saturate(1); opacity:1; box-shadow:0 10px 24px rgba(0,0,0,.22); }
}
@keyframes pillPulse{
  0%{ transform:translateY(0) scale(1); filter:brightness(1) saturate(1); opacity:1; box-shadow:0 10px 24px rgba(0,0,0,.22); }
  50%{ transform:translateY(-2px) scale(1.085); filter:brightness(1.15) saturate(1.15); opacity:.88; box-shadow:0 18px 44px rgba(0,0,0,.32); }
  100%{ transform:translateY(0) scale(1); filter:brightness(1) saturate(1); opacity:1; box-shadow:0 10px 24px rgba(0,0,0,.22); }
}

@-webkit-keyframes pillPulseSoft{
  0%{ -webkit-transform:translateY(0) scale(1); transform:translateY(0) scale(1); -webkit-filter:brightness(1) saturate(1); filter:brightness(1) saturate(1); opacity:1; box-shadow:0 10px 24px rgba(0,0,0,.22); }
  50%{ -webkit-transform:translateY(-1px) scale(1.03); transform:translateY(-1px) scale(1.03); -webkit-filter:brightness(1.08) saturate(1.08); filter:brightness(1.08) saturate(1.08); opacity:.90; box-shadow:0 18px 44px rgba(0,0,0,.28); }
  100%{ -webkit-transform:translateY(0) scale(1); transform:translateY(0) scale(1); -webkit-filter:brightness(1) saturate(1); filter:brightness(1) saturate(1); opacity:1; box-shadow:0 10px 24px rgba(0,0,0,.22); }
}
@keyframes pillPulseSoft{
  0%{ transform:translateY(0) scale(1); filter:brightness(1) saturate(1); opacity:1; box-shadow:0 10px 24px rgba(0,0,0,.22); }
  50%{ transform:translateY(-1px) scale(1.03); filter:brightness(1.08) saturate(1.08); opacity:.90; box-shadow:0 18px 44px rgba(0,0,0,.28); }
  100%{ transform:translateY(0) scale(1); filter:brightness(1) saturate(1); opacity:1; box-shadow:0 10px 24px rgba(0,0,0,.22); }
}

@-webkit-keyframes pillPulseMobile{ 0%{ -webkit-transform:translateY(0) scale(1); transform:translateY(0) scale(1); opacity:1; } 50%{ -webkit-transform:translateY(-2px) scale(1.10); transform:translateY(-2px) scale(1.10); opacity:.86; } 100%{ -webkit-transform:translateY(0) scale(1); transform:translateY(0) scale(1); opacity:1; } }
@keyframes pillPulseMobile{ 0%{ transform:translateY(0) scale(1); opacity:1; } 50%{ transform:translateY(-2px) scale(1.10); opacity:.86; } 100%{ transform:translateY(0) scale(1); opacity:1; } }

@media (hover: none) and (pointer: coarse){
  .pillbtn.pillbtnPulse{
    -webkit-animation: pillPulseMobile .78s ease-in-out infinite !important;
    animation: pillPulseMobile .78s ease-in-out infinite !important;
    will-change: transform, opacity;
  }
}

@media (prefers-reduced-motion: reduce){
  .pillbtn.pillbtnPulse{
    -webkit-animation: pillPulseSoft 2.4s ease-in-out infinite !important;
    animation: pillPulseSoft 2.4s ease-in-out infinite !important;
  }
}

/* SEARCH MINIMAL */
.search-wrap{
  max-width:520px;
  margin:20px auto 10px;
  padding:0 12px;
  text-align:center;
}

.search-box{ display:flex; gap:8px; }

.search-box input{
  flex:1;
  padding:8px 14px;
  border-radius:999px;
  border:1.5px solid #bbb;
  font-size:14px;
  font-weight:400;
  outline:none;
}

.search-box input::placeholder{ color:#999; }

.search-box button{
  padding:8px 14px;
  border-radius:999px;
  border:none;
  background:#111;
  color:#fff;
  font-size:13px;
  font-weight:500;
  cursor:pointer;
}

.search-box button:hover{ background:#000; }

/* NAV BUTTONS */
.nav-btns{ display:flex; justify-content:center; gap:10px; margin-top:10px; }
.nav-btns a{ background:#f2f2f2; padding:6px 16px; border-radius:999px; font-size:13px; }

/* GRID (thumb cards) */
.grid{
  max-width:1400px;
  margin:16px auto;
  padding:0 10px;
  display:grid;
  gap:8px;
}
@media(max-width:600px){.grid{grid-template-columns:repeat(2,1fr)}}
@media(min-width:601px) and (max-width:1024px){.grid{grid-template-columns:repeat(4,1fr)}}
@media(min-width:1025px){.grid{grid-template-columns:repeat(6,1fr)}}

/* CARD */
.card{
  background:var(--card);
  border-radius:15px;
  overflow:hidden;
  border:1px solid var(--border);
  transition:.18s ease;
}

.card:hover{
  transform:translateY(-3px);
  box-shadow:0 10px 22px rgba(0,0,0,.16);
  border-color:var(--border-hover);
}

.thumb{
  height:280px;
  background:#fafafa;
  background-size:contain;
  background-repeat:no-repeat;
  background-position:center;
}

.thumb.pdf{
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight:700;
  letter-spacing:.8px;
  color:#111;
  background:linear-gradient(180deg,#f7f7f7,#ececec);
}

/* BUTTONS */
.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  padding:10px 14px;
  border-radius:999px;
  border:1px solid #000;
  background:#fff;
  color:#000;
  cursor:pointer;
  font-size:13px;
  font-weight:600;
  letter-spacing:.3px;
  text-transform:uppercase;
}

.btn:hover{ background:#000; border-color:#000; color:#fff; }
.btn.primary{ background:#000; border-color:#000; color:#fff; }
.btn.primary:hover{ background:#000; border-color:#000; color:#fff; }
.btn.ghost{ background:#fff; color:#000; border-color:#000; }
.btn.ghost:hover{ background:#000; color:#fff; }
.btn.danger{ background:#b30000; border-color:#b30000; }
.btn.danger:hover{ background:#900; border-color:#900; }

/* PANELS */
.formpanel{ max-width:1400px; margin:14px auto; padding:0 14px; }
.panel{ background:var(--card); border:1px solid var(--border); border-radius:16px; box-shadow:none; }

/* BREADCRUMB */
.breadcrumb{max-width:1400px;margin:12px auto 0;padding:0 14px;font-size:13px;color:#666;}
.breadcrumb a{color:#111;}
.breadcrumb .sep{margin:0 6px;color:#999;}
.breadcrumb .current{color:#666;}

/* PRINT */
@media print{
  .no-print{ display:none !important; }
  header,.search-wrap,.seo-text,.site-footer{ display:none !important; }
}

/* TOOLS */
.tools{ padding:8px 6px; background:#eee; display:flex; justify-content:center; align-items:center; text-align:center; }
.tools .btn{ width:100%; justify-content:center; text-align:center; white-space:normal; line-height:1.25; padding-left:12px; padding-right:12px; font-weight:600; }

.meta{ text-align:center; font-size:12px; color:var(--muted); margin-bottom:4px; }

/* SEO + DISCLAIMER */
.seo-text{ max-width:900px; margin:32px auto 20px; padding:0 16px; font-size:14px; line-height:1.6; color:#444; }
.seo-text h2{ font-size:17px; font-weight:600; margin-bottom:8px; }
.seo-text .disclaimer{ margin-top:14px; font-size:13px; color:#666; }

/* FOOTER */
.site-footer{ max-width:1400px; margin:28px auto 0; padding:18px 12px 26px; text-align:center; font-size:13px; color:var(--muted); border-top:1px solid var(--border); }

/* DARK premium for nav buttons/tools/thumb */
html[data-theme="dark"] .nav-btns a{
  background: linear-gradient(180deg, #1f1a4a 0%, #151033 100%);
  color:#ffffff;
  border:1px solid var(--border);
  border-radius:999px;
  box-shadow: 0 6px 18px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.06);
  transition: background .25s ease, box-shadow .25s ease, border-color .25s ease, transform .15s ease;
}

html[data-theme="dark"] .nav-btns a:hover{
  background: linear-gradient(180deg, #2a2f7a 0%, #1f2360 100%);
  border-color: var(--border-hover);
  box-shadow: 0 10px 30px rgba(0,0,0,.65), 0 0 0 1px rgba(75,92,255,.35);
  transform: translateY(-1px);
}

html[data-theme="dark"] .thumb{
  height:280px;
  min-height:280px;
  max-height:280px;
  width:100%;
  position:relative;
  background: linear-gradient(180deg, #1b163f 0%, #120e2e 100%);
  background-size:contain;
  background-repeat:no-repeat;
  background-position:center;
  overflow:hidden;
  box-sizing:border-box;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.06), inset 0 -30px 55px rgba(0,0,0,.75);
}

html[data-theme="dark"] .tools{
  background: linear-gradient(180deg, rgba(18,14,46,.85) 0%, rgba(12,10,34,.95) 100%);
  border-top:1px solid rgba(255,255,255,.08);
}

html[data-theme="dark"] .tools .btn{
  background: linear-gradient(180deg, #2a2f7a 0%, #1f2360 100%);
  border:1px solid rgba(120,130,255,.45);
  color:#ffffff;
  box-shadow: 0 6px 18px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,255,255,.08);
}

html[data-theme="dark"] .tools .btn:hover{
  border-color: var(--border-hover);
  box-shadow: 0 10px 28px rgba(0,0,0,.75), 0 0 0 1px rgba(75,92,255,.35);
}

/* Subheader: make the STAMPAECOLORA.IT button readable in dark */
html[data-theme="dark"] .subheader-actions .site-btn{
  color:#ffffff;
  background: linear-gradient(180deg, #2a2f7a 0%, #1f2360 100%);
  border:1px solid rgba(120,130,255,.45);
}
html[data-theme="dark"] .subheader-actions .site-btn:hover{
  border-color: var(--border-hover);
}

.page-container{ width:100%; margin:0 auto; padding:0 12px; }
@media (min-width:768px){ .page-container{ max-width:1200px; } }
@media (min-width:1200px){ .page-container{ max-width:1400px; } }

@media (max-width: 900px){
  .page-container{ padding:0 4px; }
  .formpanel{ padding:0 4px; }
}

/* Extra helpers used by existing pages */
.small{ font-size:13px; color:var(--muted); line-height:1.45; }
.err{ margin:12px 0; padding:12px; border-radius:14px; background:#fee2e2; border:1px solid #fecaca; color:#7f1d1d; font-weight:600; }
hr.sep{ border:0; border-top:1px solid var(--border); margin:14px 0; }

.preview{ text-align:center; }

.preview-box {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #eee;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.preview-box img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  background: #eee;
  display: block;
}
