/*
 * Stile gestionale La gabbianella — light/dark, minimal moderno.
 * I colori vivono in variabili: il tema si cambia su <html data-theme="...">.
 */

:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f1f2fa;
  --text: #2c3557;
  --muted: #7078a0;
  --border: #e3e5f1;
  --accent: #526496;          /* indaco/periwinkle del brand (dal logo) */
  --accent-contrast: #ffffff;
  --indigo: #606aa3;          /* periwinkle della striscia alta del sito */
  --danger: #b42318;
  --danger-bg: #fdecea;
  --ok: #1a7f47;
  --ok-bg: #e7f4ec;
  --radius: 10px;
  --font-display: "Playfair Display", Georgia, "Times New Roman", serif;
  --shadow: 0 1px 2px rgba(34, 42, 82, .06), 0 1px 3px rgba(34, 42, 82, .05);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12142a;
    --surface: #1a1d3a;
    --surface-2: #232748;
    --text: #e7e8f6;
    --muted: #9ca2c8;
    --border: #2f3457;
    --accent: #aeb4d1;
    --accent-contrast: #12142a;
    --indigo: #aeb4d1;
    --danger: #ff7b72;
    --danger-bg: #2d1715;
    --ok: #56d364;
    --ok-bg: #11261a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .45);
  }
}

:root[data-theme="dark"] {
  --bg: #12142a;
  --surface: #1a1d3a;
  --surface-2: #232748;
  --text: #e7e8f6;
  --muted: #9ca2c8;
  --border: #2f3457;
  --accent: #8b91e0;
  --accent-contrast: #12142a;
  --indigo: #8b91e0;
  --danger: #ff7b72;
  --danger-bg: #2d1715;
  --ok: #56d364;
  --ok-bg: #11261a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }

html { color-scheme: light dark; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Roboto", system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---- Topbar ---- */
.topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: .75rem 1.5rem;
  background: var(--surface);
  border-top: 3px solid var(--indigo);   /* sottile filo indaco del brand */
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

/* Wordmark ufficiale (uccellino + logotipo). Su tema scuro lo schiariamo
   perché è indaco su trasparente e sparirebbe. */
.brand-logo {
  display: block;
  height: 48px;
  width: auto;
  border-radius: 0;
}

:root[data-theme="dark"] .brand-logo { filter: brightness(0) invert(1) brightness(1.1); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand-logo { filter: brightness(0) invert(1) brightness(1.1); }
}

.nav {
  display: flex;
  gap: 1.5rem;
  flex: 1;
}

.nav a {
  color: var(--accent);
  text-decoration: none;
  font-size: .95rem;
  font-weight: 600;
  letter-spacing: .02em;
}

.nav a:hover { color: var(--text); }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.theme-toggle {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: .45rem .6rem;
  color: var(--text);
}

.theme-toggle:hover { border-color: var(--accent); }

/* ---- Layout ---- */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 4rem;
}

h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 2rem;
  letter-spacing: -.01em;
  margin: .2rem 0 1rem;
}
h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.35rem;
  margin: 2rem 0 .75rem;
}

a { color: var(--accent); }

.muted { color: var(--muted); }

/* ---- Tabelle ---- */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

th, td {
  text-align: left;
  padding: .6rem .75rem;
  border-bottom: 1px solid var(--border);
  font-size: .95rem;
}

th {
  background: var(--surface-2);
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  font-size: .75rem;
  letter-spacing: .03em;
}

tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }

/* ---- Liste descrittive ---- */
dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: .4rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow);
}

dt { color: var(--muted); }
dd { margin: 0; font-weight: 500; }

/* ---- Form ---- */
form { max-width: 520px; }

.field { margin-bottom: 1rem; }

label { display: block; font-size: .9rem; color: var(--muted); margin-bottom: .3rem; }

input[type="text"],
input[type="password"],
input[type="number"],
input[type="datetime-local"],
input[type="file"],
select {
  width: 100%;
  padding: .55rem .65rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}

fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin: 0 0 1rem;
}

legend { color: var(--muted); font-size: .85rem; padding: 0 .4rem; }

fieldset label {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  margin: 0 1rem .4rem 0;
  color: var(--text);
}

fieldset input[type="checkbox"] { width: auto; }

/* ---- Bottoni ---- */
input[type="submit"], .btn-primary, button {
  cursor: pointer;
  font: inherit;
}

input[type="submit"], .btn-primary {
  background: var(--accent);
  color: var(--accent-contrast);
  border: 0;
  border-radius: var(--radius);
  padding: .6rem 1.1rem;
  font-weight: 600;
}

input[type="submit"]:hover, .btn-primary:hover { filter: brightness(1.05); }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .4rem .8rem;
}

.btn-ghost:hover { color: var(--text); border-color: var(--accent); }

/* button_to genera un form: niente margine extra */
.topbar-actions form { margin: 0; }

/* ---- Ricerca ---- */
form.search {
  display: flex;
  gap: .5rem;
  align-items: center;
  max-width: none;
  margin-bottom: 1rem;
}

form.search input[type="text"] { flex: 1; }
form.search .btn-primary { white-space: nowrap; }

/* ---- Flash ---- */
.flash {
  padding: .7rem 1rem;
  border-radius: var(--radius);
  margin: 0 0 1rem;
  font-size: .95rem;
  border: 1px solid transparent;
}

.flash-notice { background: var(--ok-bg); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.flash-alert { background: var(--danger-bg); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }

/* ---- Errori di form ---- */
form ul {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
  border-radius: var(--radius);
  padding: .6rem 1rem .6rem 2rem;
  margin: 0 0 1rem;
}

/* ---- Card login ---- */
.auth-card {
  max-width: 380px;
  margin: 4rem auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
}

.auth-card h1 { margin-top: 0; }
.auth-card form { max-width: none; }

/* ---- Immagini prodotto ---- */
img { border-radius: var(--radius); max-width: 100%; height: auto; }
