/* ============================================================================
   Plancia — identità visiva Studio Alma
   Token di colore e tipografia ripresi dal sistema di design di simulazioni
   (teal #00617D, marble #3B3D3E, Montserrat), su layout a barra laterale
   ispirato a Bussola.

   Accessibilità: il responsabile dello studio ha una discromatopsia
   rosso-verde. Regola vincolante — il significato non è mai affidato al solo
   colore: l'asse del denaro è blu-arancio (entrate teal, uscite arancio),
   sempre accompagnato da segno e icona; avvisi ed errori portano icona e testo.
   ========================================================================== */

:root {
  /* Marca */
  --alma-teal:        #00617D;
  --alma-teal-dark:   #004C63;
  --alma-teal-darker: #003A4D;
  --alma-marble:      #3B3D3E;
  --alma-marble-soft: #6B6D6E;

  /* Neutri "carta" */
  --alma-paper:       #FFFFFF;
  --alma-paper-soft:  #F7F7F5;
  --alma-paper-cool:  #F4F6FA;
  --alma-rule:        #E5E7EB;
  --alma-rule-strong: #D1D5DB;
  --alma-text-faint:  #9A9C9D;

  /* Asse del denaro — coppia sicura per discromatopsia rosso-verde (blu/arancio) */
  --alma-entrata-fg:  #00617D;   /* teal: entrate */
  --alma-entrata-bg:  #EAF1F4;
  --alma-uscita-fg:   #9A4A00;   /* arancio scuro: uscite */
  --alma-uscita-bg:   #FBEEDF;

  /* Avvisi ed errori — sempre con icona e testo, colore di rinforzo */
  --alma-warn-fg:     #7A5315;
  --alma-warn-bg:     #FBF3E3;
  --alma-warn-bd:     #E8D6AF;

  --radius:    14px;
  --radius-sm: 10px;
  --shadow:       0 4px 20px rgba(0, 97, 125, .10);
  --shadow-hover: 0 8px 32px rgba(0, 97, 125, .18);
  --sidebar-w: 248px;
  --sidebar-w-collapsed: 64px;
  --sidebar-transition: width .22s cubic-bezier(.4, 0, .2, 1);
}

body {
  background: linear-gradient(150deg, #eef3f5 0%, #f4f6fa 50%, #eef4f6 100%);
  background-attachment: fixed;
  font-family: 'Montserrat', 'Helvetica Neue', Arial, sans-serif;
  color: var(--alma-marble);
  min-height: 100vh;
}

/* ── Barra laterale ──────────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: linear-gradient(180deg, var(--alma-teal-darker) 0%, var(--alma-teal) 65%, var(--alma-teal-dark) 100%);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  box-shadow: 4px 0 20px rgba(0, 97, 125, .20);
  transition: var(--sidebar-transition);
  overflow: hidden;
}

.sidebar.collapsed { width: var(--sidebar-w-collapsed); }

.sidebar-brand {
  padding: .85rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, .15);
  display: flex;
  align-items: center;
  gap: .75rem;
  overflow: hidden;
}

.sidebar-toggle {
  flex-shrink: 0;
  width: 36px; height: 36px;
  background: rgba(255, 255, 255, .15);
  border: none;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
  font-size: 1.1rem;
}

.sidebar-toggle:hover { background: rgba(255, 255, 255, .25); }

.sidebar-brand .brand-info {
  display: flex;
  align-items: center;
  gap: .65rem;
  overflow: hidden;
  white-space: nowrap;
  min-width: 0;
}

.sidebar.collapsed .sidebar-brand .brand-info { opacity: 0; pointer-events: none; }

.sidebar-brand img {
  flex-shrink: 0;
  width: 34px; height: 34px;
  object-fit: contain;
  background: #fff;
  border-radius: var(--radius-sm);
  padding: 4px;
}

.sidebar-brand .app-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: .02em;
}

.sidebar-brand .studio-name {
  font-size: .66rem;
  color: rgba(255, 255, 255, .7);
  letter-spacing: .08em;
  text-transform: uppercase;
}

.sidebar-nav { flex: 1; overflow-y: auto; padding: 1rem 0; }

.sidebar-nav .nav-section {
  font-size: .66rem;
  font-weight: 600;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .5);
  padding: .75rem 1.25rem .25rem;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar.collapsed .sidebar-nav .nav-section { opacity: 0; height: 0; padding: 0; pointer-events: none; }

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .55rem 1.25rem;
  color: rgba(255, 255, 255, .85);
  font-size: .9rem;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar.collapsed .sidebar-nav .nav-link { padding-left: 0; padding-right: 0; justify-content: center; gap: 0; }
.sidebar.collapsed .sidebar-nav .nav-link .nav-label { opacity: 0; width: 0; overflow: hidden; }

.sidebar-nav .nav-link:hover,
.sidebar-nav .nav-link.active { background: rgba(255, 255, 255, .15); color: #fff; }

/* lo stato attivo non è solo colore: anche un bordo a sinistra */
.sidebar-nav .nav-link.active { background: rgba(255, 255, 255, .20); border-left: 3px solid #fff; }

.sidebar-nav .nav-link i { font-size: 1rem; width: 20px; text-align: center; }

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, .15);
  font-size: .82rem;
  color: rgba(255, 255, 255, .7);
  overflow: hidden;
}

.sidebar-footer .user-name { color: #fff; font-weight: 600; font-size: .88rem; }
.sidebar.collapsed .sidebar-footer .footer-text { opacity: 0; pointer-events: none; height: 0; }

/* ── Contenuto principale ────────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  padding: 1.75rem 2rem;
  transition: margin-left var(--sidebar-transition);
}

body.sidebar-collapsed .main-content { margin-left: var(--sidebar-w-collapsed); }

.page-header { margin-bottom: 1.5rem; }
.page-title { font-size: 1.45rem; font-weight: 700; color: var(--alma-marble); margin: 0; }
.page-subtitle { font-size: .875rem; color: var(--alma-marble-soft); margin: .2rem 0 0; }

/* ── Schede ──────────────────────────────────────────────────────────────── */
.card { border: 1px solid var(--alma-rule); border-radius: var(--radius); box-shadow: var(--shadow); background: #fff; }
.card-header {
  background: var(--alma-teal);
  color: #fff;
  border-radius: var(--radius) var(--radius) 0 0 !important;
  border: none;
  padding: .85rem 1.25rem;
  font-weight: 600;
  font-size: .95rem;
}
.card-header.light { background: var(--alma-paper-soft); color: var(--alma-marble); border-bottom: 1px solid var(--alma-rule); }

/* ── Bottoni ─────────────────────────────────────────────────────────────── */
.btn { border-radius: var(--radius-sm); font-weight: 500; }
.btn-primary { background: var(--alma-teal); border-color: var(--alma-teal); }
.btn-primary:hover, .btn-primary:focus { background: var(--alma-teal-dark); border-color: var(--alma-teal-dark); }
.btn-outline-primary { color: var(--alma-teal); border-color: var(--alma-teal); }
.btn-outline-primary:hover { background: var(--alma-teal); border-color: var(--alma-teal); }

/* ── Form ────────────────────────────────────────────────────────────────── */
.form-control, .form-select {
  border-radius: var(--radius-sm);
  background: var(--alma-paper-soft);
  border: 1px solid var(--alma-rule-strong);
}
.form-control:focus, .form-select:focus {
  box-shadow: 0 0 0 3px rgba(0, 97, 125, .15);
  border-color: var(--alma-teal);
  background: #fff;
}

/* ── Tabelle ─────────────────────────────────────────────────────────────── */
.table th {
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: #495057;
  border-bottom: 2px solid var(--alma-rule);
}
.table td { font-size: .9rem; vertical-align: middle; }
.table-hover tbody tr:hover { background: var(--alma-paper-cool); }

/* ── Schede statistiche (saldi cassa, totali estratto) ───────────────────── */
.stat-card {
  background: #fff;
  border: 1px solid var(--alma-rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.25rem;
  height: 100%;
}
.stat-number {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--alma-marble);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.stat-label {
  font-size: .8rem;
  color: var(--alma-marble-soft);
  margin-top: .15rem;
}
.stat-icon {
  font-size: 1.6rem;
  color: var(--alma-teal);
  opacity: .55;
}

/* ── Importi: asse blu-arancio, mai solo colore (segno + icona obbligatori) ── */
.importo-entrata { color: var(--alma-entrata-fg); font-weight: 600; font-variant-numeric: tabular-nums; }
.importo-uscita  { color: var(--alma-uscita-fg);  font-weight: 600; font-variant-numeric: tabular-nums; }

/* ── Avvisi ──────────────────────────────────────────────────────────────── */
.flash-container { position: sticky; top: 0; z-index: 900; }

/* ── Stampa ──────────────────────────────────────────────────────────────── */
@media print {
  .sidebar, .flash-container { display: none !important; }
  .main-content { margin-left: 0 !important; padding: 1rem !important; }
  body { background: #fff !important; }
  .card { box-shadow: none !important; border: 1px solid var(--alma-rule-strong) !important; }
  .card-header { background: var(--alma-paper-soft) !important; color: #000 !important; }
}
