/* =====================================================================
   Grafica "Moderno chiaro" – Plaghia Magazzino
   I colori principali sono qui sotto: per adattarli al logo basta
   cambiare --brand e --brand-scuro.
   ===================================================================== */
:root {
  /* Colori presi dal logo Plaghia Charter: grigio-azzurro della vela e nero della scritta */
  --brand: #44687c;
  --brand-scuro: #2b4757;
  --brand-chiaro: #e9f0f4;
  --sidebar-bg: #16191d;
  --sidebar-testo: #b9c3ca;
  --sfondo: #f3f5f9;
  --bordo: #e3e8ef;
  --raggio: 14px;
  --ombra: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .08);
  --ombra-alta: 0 8px 24px rgba(16, 24, 40, .10);
  --larghezza-sidebar: 248px;

  --bs-primary: var(--brand);
  --bs-primary-rgb: 68, 104, 124;
  --bs-link-color: var(--brand);
  --bs-link-color-rgb: 68, 104, 124;
  --bs-link-hover-color: var(--brand-scuro);
  --bs-body-bg: var(--sfondo);
  --bs-border-color: var(--bordo);
  --bs-border-radius: 10px;
  --bs-border-radius-lg: var(--raggio);
  --bs-body-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body { background: var(--sfondo); color: #1d2939; -webkit-font-smoothing: antialiased; }
h1, .h1, h2, .h2, h3, .h3 { font-weight: 700; letter-spacing: -.01em; color: #101828; }

/* --- Pulsanti --- */
.btn { min-height: 2.6rem; border-radius: 10px; font-weight: 500; display: inline-flex; align-items: center; justify-content: center; gap: .4rem; }
.btn-sm { min-height: 2.1rem; border-radius: 8px; }
.btn-primary { --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand-scuro); --bs-btn-hover-border-color: var(--brand-scuro); --bs-btn-active-bg: var(--brand-scuro); --bs-btn-active-border-color: var(--brand-scuro); --bs-btn-disabled-bg: var(--brand); --bs-btn-disabled-border-color: var(--brand); }
.btn-outline-primary { --bs-btn-color: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand); --bs-btn-hover-border-color: var(--brand); --bs-btn-active-bg: var(--brand); --bs-btn-active-border-color: var(--brand); }
.form-control, .form-select { min-height: 2.6rem; border-radius: 10px; border-color: #d0d7e2; }
.form-control:focus, .form-select:focus { border-color: var(--brand); box-shadow: 0 0 0 .2rem rgba(68, 104, 124, .15); }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.nav-pills { --bs-nav-pills-link-active-bg: var(--brand); }
.nav-pills .nav-link { border-radius: 999px; }
.pagination { --bs-pagination-active-bg: var(--brand); --bs-pagination-active-border-color: var(--brand); --bs-pagination-color: var(--brand); }

/* --- Schede --- */
.card { --bs-card-bg: #fff; border: 1px solid var(--bordo); border-radius: var(--raggio); box-shadow: var(--ombra); }
.card.shadow-sm { box-shadow: var(--ombra) !important; }
.card-header { background: #fff; border-bottom-color: var(--bordo); border-radius: var(--raggio) var(--raggio) 0 0 !important; }
.card-footer { background: #fafbfc; border-top-color: var(--bordo); }
.list-group-item { border-color: var(--bordo); }
.list-group-item-action:hover { background: #f8fafc; }
a.card { transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease; }
a.card:hover { transform: translateY(-2px); box-shadow: var(--ombra-alta); border-color: var(--brand); }
.border-dashed { border-style: dashed !important; box-shadow: none !important; background: transparent; }
.alert { border-radius: 12px; }
.badge { font-weight: 600; }
.breadcrumb { font-size: .9rem; }

/* =====================================================================
   Struttura: menu laterale + barra in alto
   ===================================================================== */
.app-layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--larghezza-sidebar); background: var(--sidebar-bg); color: var(--sidebar-testo);
  display: flex; flex-direction: column;
}
@media (min-width: 992px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 1030; }
  .app-main { margin-left: var(--larghezza-sidebar); }
}
.sidebar.offcanvas-lg { --bs-offcanvas-width: 280px; --bs-offcanvas-bg: var(--sidebar-bg); background-color: var(--sidebar-bg) !important; }
.sidebar .offcanvas-body { display: flex; flex-direction: column; padding: 0; overflow-y: auto; height: 100%; }
.sidebar-logo { display: flex; align-items: center; gap: .65rem; padding: 1.25rem 1.25rem 1rem; color: #fff; text-decoration: none; }
.sidebar-logo img { height: 40px; width: auto; max-width: 180px; }
.sidebar-logo .nome { font-weight: 600; font-size: 1.05rem; line-height: 1.1; letter-spacing: .12em; }
.sidebar-logo .nome small { display: block; font-weight: 500; font-size: .75rem; color: var(--sidebar-testo); letter-spacing: .04em; text-transform: uppercase; }
.sidebar-sezione { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: #6b7a90; padding: 1rem 1.25rem .4rem; }
.sidebar-nav { list-style: none; margin: 0; padding: 0 .75rem; }
.sidebar-nav a {
  display: flex; align-items: center; gap: .75rem; padding: .6rem .75rem; border-radius: 10px;
  color: var(--sidebar-testo); text-decoration: none; font-weight: 500;
}
.sidebar-nav a .bi { font-size: 1.15rem; width: 1.25rem; text-align: center; }
.sidebar-nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.sidebar-nav a.attivo { background: var(--brand); color: #fff; box-shadow: 0 4px 12px rgba(68, 104, 124, .35); }
.sidebar-nav .contatore { margin-left: auto; background: #f59e0b; color: #111; border-radius: 999px; font-size: .72rem; font-weight: 700; padding: .1rem .5rem; }
.sidebar-utente { margin-top: auto; padding: 1rem; border-top: 1px solid rgba(255, 255, 255, .08); }
.sidebar-utente .avatar {
  width: 38px; height: 38px; border-radius: 50%; background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0;
}
.sidebar-utente .nome { color: #fff; font-weight: 600; line-height: 1.2; }
.sidebar-utente .ruolo { font-size: .78rem; }
.sidebar-utente a, .sidebar-utente button { color: var(--sidebar-testo); font-size: .85rem; text-decoration: none; background: none; border: 0; padding: 0; }
.sidebar-utente a:hover, .sidebar-utente button:hover { color: #fff; }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 1020; background: rgba(243, 245, 249, .85);
  backdrop-filter: saturate(180%) blur(10px); -webkit-backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--bordo); padding: .75rem 0;
}
.topbar .btn-menu { border: 1px solid var(--bordo); background: #fff; width: 2.6rem; padding: 0; }
.topbar .logo-mobile img { height: 32px; }
.barra-ricerca { flex: 1 1 auto; max-width: 30rem; position: relative; }
.barra-ricerca .bi-search { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); color: #98a2b3; }
.barra-ricerca input { padding-left: 2.4rem; background: #fff; border-radius: 999px; }
.contenuto { padding-top: 1.5rem; padding-bottom: 3rem; }

/* Intestazione di pagina */
.titolo-pagina { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1.25rem; }
.titolo-pagina h1 { margin: 0; font-size: 1.6rem; }
.titolo-pagina .sottotitolo { color: #667085; margin: .15rem 0 0; }

/* =====================================================================
   Home
   ===================================================================== */
.benvenuto {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-scuro) 100%); color: #fff;
  border-radius: calc(var(--raggio) + 4px); padding: 1.5rem; box-shadow: var(--ombra-alta); position: relative; overflow: hidden;
}
.benvenuto::after { content: ""; position: absolute; right: -60px; top: -60px; width: 220px; height: 220px; border-radius: 50%; background: rgba(255, 255, 255, .08); }
.benvenuto h1 { color: #fff; font-size: 1.5rem; margin-bottom: .25rem; }
.benvenuto .ricerca-grande input { border: 0; border-radius: 12px; min-height: 3.1rem; padding-left: 2.8rem; font-size: 1.05rem; }
.benvenuto .ricerca-grande .bi-search { position: absolute; left: 1rem; top: 50%; transform: translateY(-50%); color: #98a2b3; font-size: 1.1rem; }

.statistica { padding: 1.1rem 1.2rem; display: flex; flex-direction: row; align-items: center; gap: 1rem; }
.statistica .icona { width: 46px; height: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.35rem; flex-shrink: 0; }
.statistica .valore { font-size: 1.6rem; font-weight: 700; line-height: 1; color: #101828; }
.statistica .etichetta { color: #667085; font-size: .85rem; margin-top: .2rem; }
.icona-blu { background: var(--brand-chiaro); color: var(--brand); }
.icona-verde { background: #e7f8ef; color: #12805c; }
.icona-arancio { background: #fff3e0; color: #c4570c; }
.icona-viola { background: #f1ecfe; color: #6941c6; }

.azione-rapida { display: flex; align-items: center; gap: .9rem; padding: 1rem 1.1rem; color: inherit; text-decoration: none; }
.azione-rapida .icona { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.3rem; flex-shrink: 0; }
.azione-rapida .titolo { font-weight: 600; color: #101828; }
.azione-rapida .testo { font-size: .85rem; color: #667085; }
.azione-rapida .bi-chevron-right { margin-left: auto; color: #98a2b3; }

.barra-zona { height: 8px; background: #edf0f5; border-radius: 999px; overflow: hidden; }
.barra-zona > div { height: 100%; background: var(--brand); border-radius: 999px; }

/* =====================================================================
   Accesso (pagina di login)
   ===================================================================== */
.pagina-accesso {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem;
  background: radial-gradient(1200px 600px at 10% -10%, rgba(68, 104, 124, .25), transparent 60%),
              radial-gradient(900px 500px at 110% 110%, rgba(43, 71, 87, .35), transparent 60%), #121417;
}
.scheda-accesso { width: 100%; max-width: 410px; border: 0; border-radius: 20px; box-shadow: 0 24px 60px rgba(0, 0, 0, .35); }
.scheda-accesso .logo-accesso { height: 150px; width: auto; max-width: 220px; }

/* =====================================================================
   Mappa del magazzino: una cella per ripiano
   ===================================================================== */
.scaffale .card-header { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; background: #f8fafc; }
.cella {
  display: flex; justify-content: space-between; align-items: center;
  padding: .32rem .5rem; border-radius: 8px; font-size: .8rem;
  text-decoration: none; border: 1px solid; transition: transform .1s ease;
}
.cella-libera { color: #12805c; border-color: #b7e4cd; background: #effaf4; }
.cella-occupata { color: #fff; border-color: var(--brand); background: var(--brand); }
.cella:hover { transform: scale(1.04); filter: brightness(.97); }

/* Stato "Da riparare" */
.text-bg-orange { color: #fff; background-color: #f97316; }

/* Foto */
.miniatura { width: 56px; height: 56px; object-fit: cover; border-radius: 10px; flex-shrink: 0; }
.miniatura-vuota { display: flex; align-items: center; justify-content: center; background: #eef2f7; color: #98a2b3; font-size: 1.4rem; }
.foto-griglia { aspect-ratio: 1; object-fit: cover; }
.min-w-0 { min-width: 0; }

/* Lista di prelievo */
.codice-prelievo { min-width: 7.5rem; }
.casella-stampa { display: none; font-size: 1.5rem; }
@media print {
  .sidebar, .topbar, .no-stampa, .alert, .btn-close { display: none !important; }
  .app-main { margin-left: 0 !important; }
  .casella-stampa { display: inline; }
  body { background: #fff !important; }
  .card { box-shadow: none !important; }
  .codice-prelievo { color: #000 !important; background: none !important; border: 1px solid #000; }
}

/* =====================================================================
   Etichette QR (fogli A4)
   ===================================================================== */
.anteprima-fogli { overflow-x: auto; padding-bottom: 1rem; }
.foglio {
  width: 210mm; height: 297mm; background: #fff; margin: 0 auto 1.5rem; box-shadow: var(--ombra-alta);
  display: grid; align-content: start; overflow: hidden;
}
.foglio-piccole { grid-template-columns: repeat(3, 70mm); grid-auto-rows: 37mm; }
.foglio-grandi { grid-template-columns: repeat(2, 105mm); grid-auto-rows: 74mm; }
.etichetta {
  display: flex; align-items: center; gap: 2.5mm; padding: 2.5mm 3mm; overflow: hidden;
  outline: 1px dashed #d0d7e2; outline-offset: -1px; color: #000;
}
.etichetta .qr { flex-shrink: 0; }
.etichetta .qr svg { display: block; width: 100%; height: 100%; }
.etichetta .testo { min-width: 0; line-height: 1.15; }
.foglio-piccole .qr { width: 30mm; height: 30mm; }
.foglio-piccole .titolo { font-weight: 700; font-size: 10pt; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.foglio-piccole .etichetta-posizione .titolo { font-family: ui-monospace, Menlo, monospace; font-size: 11pt; white-space: nowrap; }
.foglio-piccole .riga1 { font-family: ui-monospace, Menlo, monospace; font-size: 9pt; font-weight: 600; margin-top: 1mm; }
.foglio-piccole .riga2 { font-size: 7.5pt; color: #444; margin-top: .5mm; }
.foglio-grandi .qr { width: 58mm; height: 58mm; }
.foglio-grandi .titolo { font-weight: 700; font-size: 15pt; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.foglio-grandi .etichetta-posizione .titolo { font-family: ui-monospace, Menlo, monospace; font-size: 15pt; white-space: nowrap; }
.foglio-grandi .riga1 { font-size: 11pt; font-weight: 600; margin-top: 2mm; }
.foglio-grandi .riga2 { font-size: 10pt; color: #444; margin-top: 1mm; }

@media print {
  @page { size: A4; margin: 0; }
  .contenuto { padding: 0 !important; max-width: none !important; }
  .anteprima-fogli { overflow: visible; padding: 0; }
  .foglio { margin: 0; box-shadow: none; break-after: page; page-break-after: always; }
  .foglio:last-child { break-after: auto; page-break-after: auto; }
  .etichetta { outline: none; }
}
.foglio-extra { grid-template-columns: 210mm; grid-auto-rows: 148.5mm; }
.foglio-extra .etichetta { padding: 10mm 12mm; gap: 10mm; }
.foglio-extra .qr { width: 120mm; height: 120mm; }
.foglio-extra .titolo { font-weight: 700; font-size: 26pt; }
.foglio-extra .etichetta-posizione .titolo { font-family: ui-monospace, Menlo, monospace; font-size: 40pt; white-space: nowrap; }
.foglio-extra .riga1 { font-size: 16pt; font-weight: 600; margin-top: 4mm; }
.foglio-extra .riga2 { font-size: 14pt; color: #444; margin-top: 2mm; }
