/* ==========================================================================
   Duccio Lex — Legal Navy & Gold Design System + Discreet Christmas Touch
   ========================================================================== */

:root {
  --navy-950: #06101f;
  --navy-900: #0a192f;
  --navy-800: #0f2342;
  --navy-700: #16325c;
  --navy-600: #22467a;

  --gold-600: #9e7b16;
  --gold-500: #c9a227;
  --gold-400: #dfb946;
  --gold-300: #efd682;
  --gold-soft: rgba(201, 162, 39, 0.14);

  --xmas-red: #8c232c;
  --xmas-pine: #1e4d3b;

  /* Light theme ("Carta & Toga") */
  --bg: #f6f3eb;
  --bg-elevated: #ffffff;
  --bg-subtle: #ede8dc;
  --text: #152238;
  --text-muted: #526075;
  --border: #ddd5c3;
  --shadow: 0 4px 18px rgba(10, 25, 47, 0.08);

  --ok: #1b6e44;
  --warn: #b4690e;
  --danger: #9e2a2b;

  --radius: 14px;
  --radius-sm: 9px;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: Georgia, "Times New Roman", Cambria, serif;
}

[data-theme="dark"] {
  --bg: #081324;
  --bg-elevated: #0f213d;
  --bg-subtle: #142b4e;
  --text: #eef1f6;
  --text-muted: #9fb0c9;
  --border: #203b64;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  --gold-soft: rgba(223, 185, 70, 0.14);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

body {
  display: flex;
  flex-direction: column;
  padding-bottom: 72px; /* space for mobile bottom nav */
}

/* ---------- 5-second Discreet Christmas Greeting ---------- */
.xmas-banner {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  width: min(92vw, 460px);
  background: linear-gradient(135deg, var(--navy-900) 0%, var(--navy-700) 100%);
  color: #f8f5ec;
  border: 1px solid var(--gold-500);
  border-radius: var(--radius);
  padding: 14px 16px 12px;
  box-shadow: 0 14px 36px rgba(6, 16, 31, 0.45);
  overflow: hidden;
  animation: xmasIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transition: opacity 0.45s ease, transform 0.45s ease;
}

.xmas-banner.hiding {
  opacity: 0;
  transform: translate(-50%, -14px);
  pointer-events: none;
}

.xmas-banner-inner {
  display: flex;
  align-items: center;
  gap: 12px;
}

.xmas-icon {
  font-size: 1.65rem;
  line-height: 1;
  flex-shrink: 0;
  filter: drop-shadow(0 0 6px rgba(223, 185, 70, 0.45));
}

.xmas-text {
  flex: 1;
}

.xmas-title {
  font-family: var(--font-serif);
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--gold-300);
  margin: 0 0 2px;
}

.xmas-sub {
  font-size: 0.8rem;
  color: #d6deeb;
  margin: 0;
}

.xmas-close {
  background: transparent;
  border: none;
  color: var(--gold-300);
  font-size: 1.15rem;
  cursor: pointer;
  padding: 4px 6px;
  line-height: 1;
  opacity: 0.8;
}
.xmas-close:hover { opacity: 1; }

.xmas-progress {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: 100%;
  background: linear-gradient(90deg, var(--gold-500), var(--gold-300));
  transform-origin: left;
  animation: xmasTimer 5s linear forwards;
}

@keyframes xmasIn {
  from { opacity: 0; transform: translate(-50%, -16px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@keyframes xmasTimer {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

/* ---------- Header ---------- */
.app-header {
  background: linear-gradient(135deg, var(--navy-900) 0%, var(--navy-800) 100%);
  color: #fff;
  border-bottom: 2px solid var(--gold-500);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(6, 16, 31, 0.25);
}

.header-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand img {
  width: 34px;
  height: 34px;
  border-radius: 8px;
}

.brand-title {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: var(--gold-300);
  margin: 0;
  line-height: 1.15;
}

.brand-sub {
  font-size: 0.72rem;
  color: #b7c6dc;
  margin: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-pill {
  font-size: 0.72rem;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(201, 162, 39, 0.35);
  color: #e4ebf5;
  white-space: nowrap;
}

.status-pill.offline {
  border-color: #e0bc4a;
  color: #efd682;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(201, 162, 39, 0.35);
  color: var(--gold-300);
  border-radius: 9px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.15s;
}
.icon-btn:hover {
  background: rgba(201, 162, 39, 0.2);
}

/* ---------- Navigation ---------- */
.desktop-nav {
  display: none;
  background: var(--navy-800);
  border-bottom: 1px solid rgba(201, 162, 39, 0.25);
}

.desktop-nav-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  gap: 6px;
}

.nav-tab {
  background: transparent;
  border: none;
  color: #c5d2e6;
  padding: 11px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.nav-tab:hover { color: #fff; }
.nav-tab.active {
  color: var(--gold-300);
  border-bottom-color: var(--gold-500);
}

.mobile-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--navy-900);
  border-top: 1.5px solid var(--gold-500);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 4px 0 env(safe-area-inset-bottom);
}

.mobile-nav-btn {
  background: transparent;
  border: none;
  color: #9eb0c9;
  padding: 7px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
}
.mobile-nav-btn .ico { font-size: 1.15rem; }
.mobile-nav-btn.active {
  color: var(--gold-300);
}

@media (min-width: 768px) {
  body { padding-bottom: 0; }
  .desktop-nav { display: block; }
  .mobile-nav { display: none; }
}

/* ---------- Main Layout ---------- */
.app-main {
  flex: 1;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 18px 16px 28px;
}

.tab-panel {
  display: none;
}
.tab-panel.active {
  display: block;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Cards & Controls ---------- */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-family: var(--font-serif);
  font-size: 1.12rem;
  font-weight: 700;
  color: var(--navy-800);
  margin: 0;
}
[data-theme="dark"] .card-title {
  color: var(--gold-300);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--gold-soft);
  color: var(--gold-600);
  border: 1px solid rgba(201, 162, 39, 0.35);
}
[data-theme="dark"] .badge {
  color: var(--gold-300);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
@media (min-width: 820px) {
  .grid-2 {
    grid-template-columns: 1fr 1fr;
  }
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media (min-width: 600px) {
  .form-grid.cols-2 { grid-template-columns: 1fr 1fr; }
  .form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
}

.field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.input, select {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus, select:focus {
  outline: none;
  border-color: var(--gold-500);
  box-shadow: 0 0 0 3px var(--gold-soft);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.08s, background 0.15s, border-color 0.15s;
  text-decoration: none;
}
.btn:active { transform: scale(0.98); }

.btn-primary {
  background: linear-gradient(135deg, var(--navy-800), var(--navy-700));
  color: var(--gold-300);
  border-color: var(--gold-500);
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--navy-700), var(--navy-600));
}

.btn-secondary {
  background: var(--bg-subtle);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover {
  border-color: var(--gold-500);
}

.btn-gold {
  background: var(--gold-500);
  color: var(--navy-950);
}
.btn-gold:hover {
  background: var(--gold-400);
}

.btn-sm {
  padding: 6px 10px;
  font-size: 0.8rem;
}

.pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill-btn {
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.83rem;
  font-weight: 600;
  cursor: pointer;
}
.pill-btn.active {
  background: var(--navy-800);
  color: var(--gold-300);
  border-color: var(--gold-500);
}

/* ---------- Result Box ---------- */
.result-box {
  margin-top: 14px;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border-left: 4px solid var(--gold-500);
}

.result-main {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--navy-800);
  margin: 0 0 6px;
}
[data-theme="dark"] .result-main {
  color: var(--gold-300);
}

.result-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
}

.result-list {
  list-style: none;
  padding: 0;
  margin: 10px 0 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.result-list li {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.note-warn {
  margin-top: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: rgba(180, 105, 14, 0.1);
  border: 1px solid rgba(180, 105, 14, 0.3);
  font-size: 0.82rem;
  color: var(--text);
}

/* ---------- Codici Reader ---------- */
.search-bar-wrap {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.article-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 460px;
  overflow-y: auto;
}

.article-item {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.article-item:hover, .article-item.active {
  border-color: var(--gold-500);
  background: var(--gold-soft);
}

.article-item-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 0.92rem;
}

.article-item-rubrica {
  font-size: 0.83rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.article-viewer {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-top: 3px solid var(--gold-500);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.article-viewer-title {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  margin: 0 0 4px;
  color: var(--navy-800);
}
[data-theme="dark"] .article-viewer-title {
  color: var(--gold-300);
}

.article-viewer-rubrica {
  font-style: italic;
  color: var(--text-muted);
  margin: 0 0 14px;
  font-size: 0.95rem;
}

.article-viewer-body {
  font-family: var(--font-serif);
  font-size: 1rem;
  line-height: 1.72;
  white-space: pre-line;
}

.article-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* ---------- Footer Disclaimer ---------- */
.app-footer {
  background: var(--navy-900);
  color: #b7c6dc;
  border-top: 1px solid rgba(201, 162, 39, 0.35);
  padding: 14px 16px;
  font-size: 0.78rem;
  text-align: center;
}

.app-footer strong {
  color: var(--gold-300);
}

.app-footer a {
  color: var(--gold-400);
}

.muted {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  cursor: pointer;
}
.checkbox-row input {
  width: 17px;
  height: 17px;
  accent-color: var(--gold-500);
}
