/* ═══════════════════════════════════════════════════════════════
   theme.css — Global styles, variables, reusable components
   Dark theme default. Light theme via data-theme="light"
   SEZIONI: L.1 Variables · L.80 Reset · L.150 Typography
            L.200 Buttons · L.280 Cards · L.350 Forms
            L.450 Alerts · L.520 Badges · L.580 Nav
            L.650 Modal · L.700 Spinner · L.750 Responsive
   ═══════════════════════════════════════════════════════════════ */

/* ──────────────────────────────────────────────────────────────
   VARIABLES — Dark theme (default)
   ────────────────────────────────────────────────────────────── */
:root[data-theme="dark"],
:root {
  --bg: #0d1117;
  --surf: #161b22;
  --border: #30363d;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #58a6ff;
  --green: #3fb950;
  --yellow: #d2a21a;
  --purple: #bc8cff;
  --red: #f85149;

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', sans-serif;
  --mono: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);

  --radius-sm: 4px;
  --radius:    6px;
  --radius-md: 8px;
  --radius-lg: 12px;

  --duration: 200ms;
  --easing: cubic-bezier(0.4, 0, 0.2, 1);

  /* Nav backdrop — semi-transparent surface for sticky blur effect */
  --nav-bg: rgba(22, 27, 34, 0.94);
  /* Mobile drawer — fully opaque background */
  --nav-drawer-bg: #0d1117;
}

/* Light theme */
:root[data-theme="light"] {
  --bg: #ffffff;
  --surf: #f6f8fa;
  --border: #d0d7de;
  --text: #1f2328;
  --muted: #656d76;
  --accent: #0969da;
  --green: #1a7f37;
  --yellow: #9a6700;
  --purple: #8250df;
  --red: #d1242f;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.15);

  --nav-bg: rgba(246, 248, 250, 0.94);
  --nav-drawer-bg: #ffffff;
}

/* ──────────────────────────────────────────────────────────────
   RESET
   ────────────────────────────────────────────────────────────── */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background-color: var(--bg);
  transition: background-color var(--duration) var(--easing),
              color var(--duration) var(--easing);
}

input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  font-family: inherit;
  border: none;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--duration) var(--easing);
}

a:hover {
  color: var(--purple);
  text-decoration: underline;
}

/* ──────────────────────────────────────────────────────────────
   TYPOGRAPHY
   ────────────────────────────────────────────────────────────── */
h1 {
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 0.5rem;
}

h2 {
  font-size: 1.875rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 0.75rem;
}

h3 {
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 0.5rem;
}

h4 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

h5 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

h6 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

p {
  margin-bottom: 1rem;
  color: var(--text);
}

small {
  font-size: 0.875rem;
  color: var(--muted);
}

code {
  background-color: var(--surf);
  padding: 0.2rem 0.4rem;
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 0.85rem;
}

/* ──────────────────────────────────────────────────────────────
   BUTTONS
   ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.95rem;
  transition: all var(--duration) var(--easing);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.btn-primary {
  background-color: var(--accent);
  color: var(--bg);
  border: 1px solid var(--accent);
}

.btn-primary:hover {
  background-color: var(--purple);
  border-color: var(--purple);
}

.btn-primary:active {
  opacity: 0.8;
  transform: scale(0.98);
}

.btn-secondary {
  background-color: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background-color: var(--surf);
  color: var(--accent);
  border-color: var(--accent);
}

.btn-danger {
  background-color: var(--red);
  color: white;
  border: 1px solid var(--red);
}

.btn-danger:hover {
  opacity: 0.8;
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ──────────────────────────────────────────────────────────────
   CARDS
   ────────────────────────────────────────────────────────────── */
.card {
  background-color: var(--surf);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: all var(--duration) var(--easing);
}

.card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--accent);
}

.card-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

.card-body {
  padding: 1.5rem;
}

.card-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  background-color: rgba(0, 0, 0, 0.1);
}

/* ──────────────────────────────────────────────────────────────
   FORMS
   ────────────────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 0.2rem;
  display: flex;
  flex-direction: column;
}

.form-label {
  font-weight: 600;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}

.form-input,
.form-textarea,
.form-select {
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background-color: var(--surf);
  color: var(--text);
  font-size: 0.95rem;
  transition: all var(--duration) var(--easing);
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.1);
}

.form-input::placeholder {
  color: var(--muted);
}

.form-textarea {
  resize: vertical;
  min-height: 100px;
}

.form-hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

.form-error {
  color: var(--red);
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

/* ──────────────────────────────────────────────────────────────
   ALERTS
   ────────────────────────────────────────────────────────────── */
.alert {
  padding: 1rem 1.5rem;
  border-radius: var(--radius-md);
  border-left: 4px solid;
  margin-bottom: 1rem;
}

.alert-success {
  background-color: rgba(63, 185, 80, 0.1);
  color: var(--green);
  border-left-color: var(--green);
}

.alert-error {
  background-color: rgba(248, 81, 73, 0.1);
  color: var(--red);
  border-left-color: var(--red);
}

.alert-warning {
  background-color: rgba(210, 162, 26, 0.1);
  color: var(--yellow);
  border-left-color: var(--yellow);
}

.alert-info {
  background-color: rgba(88, 166, 255, 0.1);
  color: var(--accent);
  border-left-color: var(--accent);
}

/* ──────────────────────────────────────────────────────────────
   BADGES
   ────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  background-color: var(--surf);
  color: var(--text);
  border: 1px solid var(--border);
}

.badge-green {
  background-color: rgba(63, 185, 80, 0.15);
  color: var(--green);
  border-color: var(--green);
}

.badge-yellow {
  background-color: rgba(210, 162, 26, 0.15);
  color: var(--yellow);
  border-color: var(--yellow);
}

.badge-red {
  background-color: rgba(248, 81, 73, 0.15);
  color: var(--red);
  border-color: var(--red);
}

.badge-blue {
  background-color: rgba(88, 166, 255, 0.15);
  color: var(--accent);
  border-color: var(--accent);
}

.badge-purple {
  background-color: rgba(188, 140, 255, 0.15);
  color: var(--purple);
  border-color: var(--purple);
}

/* ──────────────────────────────────────────────────────────────
   NAVIGATION
   ────────────────────────────────────────────────────────────── */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  background-color: var(--surf);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-logo {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  font-size: 1.25rem;
  font-weight: 900;
  letter-spacing: -.01em;
  text-decoration: none;
  white-space: nowrap;
}
.nav-logo .nl-1 { color: var(--text); }
.nav-logo .nl-2 {
  background: linear-gradient(135deg, var(--accent), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.nav-logo .nl-badge {
  font-size: .6rem;
  font-weight: 800;
  letter-spacing: .04em;
  color: #fff;
  background: linear-gradient(120deg, var(--accent), var(--purple));
  border-radius: 99px;
  padding: .2rem .5rem;
  line-height: 1;
}

.nav-links {
  display: flex;
  gap: 2rem;
  align-items: center;
  list-style: none;
}

.nav-links a {
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  transition: color var(--duration) var(--easing);
}

.nav-links a:hover {
  color: var(--accent);
  text-decoration: none;
}

.nav-cta {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.theme-toggle {
  background-color: transparent;
  border: none;
  padding: 0.5rem;
  cursor: pointer;
  font-size: 1.2rem;
  transition: transform var(--duration) var(--easing);
}

.theme-toggle:hover {
  transform: scale(1.1);
}

/* ──────────────────────────────────────────────────────────────
   MODAL
   ────────────────────────────────────────────────────────────── */
.modal-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.6);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

.modal-backdrop.active {
  display: flex;
}

.modal {
  background-color: var(--surf);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideIn var(--duration) var(--easing);
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
}

.modal-close {
  background-color: transparent;
  border: none;
  font-size: 1.5rem;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--duration) var(--easing);
}

.modal-close:hover {
  color: var(--text);
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
}

/* ──────────────────────────────────────────────────────────────
   SPINNER / LOADING
   ────────────────────────────────────────────────────────────── */
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.spinner-sm {
  width: 20px;
  height: 20px;
  border-width: 2px;
}

/* ──────────────────────────────────────────────────────────────
   CHIP / TAG
   ────────────────────────────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.8rem;
  background-color: var(--surf);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.85rem;
  white-space: nowrap;
}

.chip-removable {
  cursor: pointer;
}

.chip-removable:hover {
  background-color: rgba(248, 81, 73, 0.2);
  border-color: var(--red);
}

/* ──────────────────────────────────────────────────────────────
   CONTAINER / LAYOUT HELPERS
   ────────────────────────────────────────────────────────────── */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
}

.container-sm {
  max-width: 600px;
  margin: 0 auto;
  padding: 0 2rem;
}

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

.flex-col {
  flex-direction: column;
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.grid {
  display: grid;
  gap: 2rem;
}

.grid-2 {
  grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
  grid-template-columns: repeat(4, 1fr);
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.px-2 { padding: 0 1rem; }
.py-2 { padding: 1rem 0; }
.py-4 { padding: 2rem 0; }

/* ──────────────────────────────────────────────────────────────
   RESPONSIVE — Mobile (< 768px)
   ────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  h1 { font-size: 1.875rem; }
  h2 { font-size: 1.5rem; }
  h3 { font-size: 1.25rem; }

  .nav {
    padding: 0.75rem 1rem;
  }

  .nav-logo {
    font-size: 1.05rem;
  }

  .nav-links {
    gap: 1rem;
  }

  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }

  .container {
    padding: 0 1rem;
  }

  .btn {
    width: 100%;
    justify-content: center;
  }

  .modal {
    width: 95%;
    max-height: 95vh;
  }
}
