/* Reset + base typography + shared component classes — docs/12-stile-sito.md */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.5;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-optical-sizing: auto;
  font-weight: 600;
  line-height: 1.2;
  margin: 0 0 var(--space-4);
}

h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }

p { margin: 0 0 var(--space-4); }

a {
  color: var(--link);
  text-decoration: none;
}

a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

.container {
  max-width: 72rem;
  margin: 0 auto;
  padding: var(--space-8) var(--space-4);
}

/* Buttons — one primary per screen (docs/12-stile-sito.md) */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  border: none;
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 500;
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease), opacity var(--duration-fast) var(--ease);
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:not(:disabled):hover { opacity: 0.9; }

/* Spinner — an async action (API call) is in flight and would otherwise look frozen,
   since Blazor Server doesn't re-render mid-await without one (docs/12-stile-sito.md). */
.spinner {
  display: inline-block;
  width: 1em;
  height: 1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.btn-primary { background: var(--clay); color: #fff; }
.btn-secondary { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn-secondary:not(:disabled):hover { background: var(--paper-raised); opacity: 1; }
.btn-success { background: var(--teal); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }

.btn-lg { font-size: var(--text-lg); padding: var(--space-3) var(--space-6); }

/* Cards — thin border, no heavy shadow */
.card {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  padding: var(--space-6);
  transition: border-color var(--duration-base) var(--ease);
}

a.card:hover { border-color: var(--clay); }

/* Top navigation — wordmark + auth links, present on every page */
.navbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 72rem;
  margin: 0 auto;
  padding: var(--space-4);
}

.wordmark {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-lg);
  color: var(--ink);
  letter-spacing: -0.01em;
}

.wordmark:hover { text-decoration: none; }

.navbar nav { display: flex; align-items: center; gap: var(--space-4); }

/* Hidden on desktop, where .navbar nav renders as a normal row. */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  border-radius: 1px;
  background: var(--ink);
}

@media (max-width: 767px) {
  .nav-toggle { display: flex; }

  .navbar nav {
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--paper-raised);
    border-bottom: 1px solid var(--line);
    padding: var(--space-2) var(--space-4) var(--space-4);
    z-index: 10;
  }

  .navbar nav.nav-open { display: flex; }

  .navbar nav a,
  .navbar nav form,
  .navbar nav button {
    width: 100%;
    padding: var(--space-3) 0;
  }
}

.footer {
  max-width: 72rem;
  margin: var(--space-12) auto 0;
  padding: var(--space-4);
  border-top: 1px solid var(--line);
  display: flex;
  gap: var(--space-4);
}

.footer a { color: var(--ink-soft); }

/* Hero — the product's subject is a conversation, not a stat block (docs/12-stile-sito.md) */
.hero {
  max-width: 72rem;
  margin: 0 auto;
  padding: var(--space-12) var(--space-4) var(--space-16);
  display: grid;
  gap: var(--space-8);
}

@media (min-width: 768px) {
  .hero { grid-template-columns: 1fr 1fr; align-items: center; }
}

.hero h1 {
  font-size: var(--text-3xl);
  margin-bottom: var(--space-6);
}

.hero p.lead {
  font-size: var(--text-lg);
  color: var(--ink-soft);
  margin-bottom: var(--space-8);
}

/* Chat mockup — the real "hero", not an abstract illustration */
.chat-mockup {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  font-size: var(--text-sm);
}

.chat-bubble {
  max-width: 85%;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  line-height: 1.4;
}

.chat-bubble.from-user {
  align-self: flex-end;
  background: var(--teal);
  color: #fff;
}

.chat-bubble.from-bot {
  align-self: flex-start;
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--ink);
}

/* Dashboard preview sections — a boxed divider so 4-5 grid cells scan as
   distinct sections instead of running together (docs/12-stile-sito.md). */
.dashboard-section {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
}

/* Permission badges — the AccessLevel color mapping (docs/12-stile-sito.md); color carries
   meaning here, but text is always present too (colorblind users). */
.badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 500;
  white-space: nowrap;
}

.badge-none { background: transparent; color: var(--ink-soft); border: 1px solid var(--line); }
.badge-availability { background: var(--plum); color: #fff; }
.badge-read { background: var(--ochre); color: var(--ink); }
.badge-write { background: var(--teal); color: #fff; }
.badge-admin { background: var(--clay); color: #fff; }

/* Section divider — a small group of tessere instead of a generic <hr> */
.seam {
  display: flex;
  gap: var(--space-2);
  margin: var(--space-6) 0;
}

.seam span {
  display: block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.seam span:nth-child(1) { background: var(--clay); transform: rotate(-2deg); }
.seam span:nth-child(2) { background: var(--teal); transform: rotate(1deg); }
.seam span:nth-child(3) { background: var(--ochre); transform: rotate(-1deg); }

.text-soft { color: var(--ink-soft); }
.text-mono { font-family: var(--font-mono); }

header {
  max-width: 72rem;
  margin: 0 auto;
  padding: var(--space-8) var(--space-4);
}

/* The scaffolded Account pages (Login, Register) put a bare <h1> directly in the page,
   outside any wrapper — give it the same gutter as the .row that follows it. */
body > h1 {
  max-width: 72rem;
  margin: var(--space-8) auto var(--space-4);
  padding: 0 var(--space-4);
}

/* Identity's scaffolded Account pages (Login, Register, ...) ship with Bootstrap-shaped
   class names; recreated here against our own tokens instead of pulling in Bootstrap. */
.row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-6);
  max-width: 72rem;
  margin: 0 auto;
  padding: 0 var(--space-4) var(--space-8);
}

.col-lg-6, .col-lg-4, .col-md-4 { flex: 1 1 20rem; }
.col-lg-offset-2 { margin-left: var(--space-6); }

.form-label {
  display: block;
  margin-bottom: var(--space-2);
  font-weight: 500;
  font-size: var(--text-sm);
}

.form-control {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
  transition: border-color var(--duration-fast) var(--ease);
}

.form-control:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--teal);
}

.form-control:disabled { opacity: 0.6; cursor: wait; }

/* Floating label — Bootstrap's pattern, recreated with our tokens */
.form-floating { position: relative; }

.form-floating > .form-control {
  height: 3.5rem;
  padding: 1.5rem var(--space-3) var(--space-2);
}

.form-floating > label {
  position: absolute;
  top: 0;
  left: 0;
  padding: var(--space-3);
  color: var(--ink-soft);
  font-size: var(--text-base);
  pointer-events: none;
  transition: transform var(--duration-fast) var(--ease), font-size var(--duration-fast) var(--ease);
  transform-origin: 0 0;
}

.form-floating > .form-control:focus ~ label,
.form-floating > .form-control:not(:placeholder-shown) ~ label {
  transform: translateY(-0.6rem) scale(0.82);
  color: var(--ink-soft);
}

.mb-3 { margin-bottom: var(--space-4); }
.w-100 { width: 100%; }
.text-danger { color: var(--danger); }

.checkbox label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  font-weight: 400;
}

.form-check-input {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--teal);
}

hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: var(--space-4) 0;
}

.alert {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
  border: 1px solid var(--line);
}

.alert-danger { background: var(--paper-raised); border-color: var(--danger); color: var(--danger); }
.alert-success { background: var(--paper-raised); border-color: var(--teal); color: var(--teal); }
.alert-info { background: var(--paper-raised); border-color: var(--teal); color: var(--ink); }

/* Usage meter (e.g. daily L3 calls used/limit) — a plain div bar rather than <progress>,
   since styling the native element consistently across browsers fights the design tokens
   more than it's worth for something this simple. */
.meter {
  height: 8px;
  border-radius: var(--radius-sm);
  background: var(--paper);
  border: 1px solid var(--line);
  overflow: hidden;
  margin: var(--space-2) 0 var(--space-4);
}

.meter-fill {
  height: 100%;
  background: var(--clay);
  transition: width var(--duration-base) var(--ease);
}

.meter-fill.meter-fill-danger { background: var(--danger); }

/* Shared list-row layout (ShoppingList, Reminders, Expenses): a nowrap label/date, the main
   text, and a group of actions in one line on desktop. A fixed-width label next to a flex:1
   text column doesn't leave enough room on a narrow phone, so this stacks vertically below
   480px instead of squeezing everything into one row. */
.list-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.list-row-label {
  color: var(--ink-soft);
  white-space: nowrap;
}

.list-row-main {
  flex: 1;
}

.list-row-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

@media (max-width: 480px) {
  .list-row {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-2);
  }

  .list-row-label {
    white-space: normal;
  }
}

.btn-link {
  background: transparent;
  color: var(--link);
  padding: 0;
  min-height: auto;
}

.btn-link:hover { text-decoration: underline; opacity: 1; }
