/*
 * ChantillyApp — Unified Stylesheet
 * ═══════════════════════════════════════════════════════════════
 * Sezioni:
 *   1. Variables & Reset
 *   2. Layout
 *   3. Typography & Utilities
 *   4. Buttons
 *   5. Cards & Sections
 *   6. Forms & Inputs
 *   7. Grid System
 *   8. Tables
 *   9. Pagination
 *  10. Alerts & Feedback
 *  11. Tags & Badges
 *  12. Stats Bar
 *  13. Order-specific (dashboard, show, create)
 *  14. Users-specific
 *  15. Lab Switcher
 *  16. Login Page
 *  17. Responsive
 * ═══════════════════════════════════════════════════════════════
 */

/* ─────────────────────────────────────────────────────────────
   1. VARIABLES & RESET
   ───────────────────────────────────────────────────────────── */

:root {
  /* Defaults — overridden by theme partial per-lab */
  --accent: #bcd23a;
  --accent-hover: #a7c51f;
  --accent-soft: #eef6c3;
  --bg: #f6f7f8;
  --card: #fff;
  --ink: #111;
  --muted: #666;
  --line: #e8eaee;
  --field: #dcdcdc;
}

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

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

body {
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

input,
button,
select,
textarea {
  font: inherit;
}

/* ─────────────────────────────────────────────────────────────
   2. LAYOUT
   ───────────────────────────────────────────────────────────── */

.wrap {
  max-width: 960px;
  margin: 24px auto;
  padding: 0 16px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.topbar-right {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

/* ─────────────────────────────────────────────────────────────
   3. TYPOGRAPHY & UTILITIES
   ───────────────────────────────────────────────────────────── */

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

.text-accent {
  color: var(--accent);
}

.text-danger {
  color: #b00020;
}

.text-bold {
  font-weight: 700;
}

.nowrap {
  white-space: nowrap;
}

.hidden {
  display: none !important;
}

.help {
  font-size: 12px;
  color: #666;
  margin-top: 6px;
}

.highlight {
  color: #b30000;
  font-weight: 700;
}

/* ─────────────────────────────────────────────────────────────
   4. BUTTONS
   ───────────────────────────────────────────────────────────── */

.btn {
  appearance: none;
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 800;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  text-decoration: none;
  font-size: inherit;
  line-height: 1;
}

.btn:hover {
  background: var(--accent-hover);
}

a.btn {
  color: #fff;
  text-decoration: none;
}

.btn--secondary {
  background: var(--accent-soft);
  color: #000;
  border: 1px solid var(--accent);
  font-weight: 700;
}

.btn--secondary:hover {
  background: var(--accent);
  color: #fff;
}

.btn--danger {
  background: #fff;
  color: #c03a2b;
  border: 1px solid #f2cbc7;
}

.btn--danger:hover {
  background: #ffe9e7;
}

.btn--danger-fill {
  background: #ffe6e6;
  color: #8a1f1f;
  border: 1px solid #ffbdbd;
}

.btn--danger-fill:hover {
  background: #ffd4d4;
}

.btn--primary {
  background: var(--accent);
  color: #fff;
  border: 0;
}

/* ─────────────────────────────────────────────────────────────
   5. CARDS & SECTIONS
   ───────────────────────────────────────────────────────────── */

.card {
  background: var(--card);
  border-radius: 16px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .06);
  padding: 20px;
}

.section {
  margin-top: 18px;
}

.section-title {
  font-weight: 750;
  margin: 0 0 12px;
}

.block {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  margin-top: 6px;
}

.block--full {
  grid-column: 1 / -1;
}

/* ─────────────────────────────────────────────────────────────
   6. FORMS & INPUTS
   ───────────────────────────────────────────────────────────── */

label {
  display: block;
  font-size: 13px;
  margin: 0 0 6px;
  color: #333;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="time"],
input[type="number"],
select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--field);
  border-radius: 10px;
  background: #fff;
  height: 40px;
}

textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--field);
  border-radius: 10px;
  background: #fff;
  min-height: 90px;
  height: auto;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.fieldset {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
}

.fieldset--accent {
  border-left: 4px solid var(--accent);
  padding-left: 12px;
}

.radio-line {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  align-items: center;
}

.radio-line input[type="radio"] {
  accent-color: var(--accent);
}

.check-line input[type="checkbox"] {
  accent-color: var(--accent);
}

.field-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.btnbar {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ─────────────────────────────────────────────────────────────
   7. GRID SYSTEM
   ───────────────────────────────────────────────────────────── */

/* 12-column grid */
.g12 {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 16px;
}

.col-2 {
  grid-column: span 2;
}

.col-3 {
  grid-column: span 3;
}

.col-4 {
  grid-column: span 4;
}

.col-6 {
  grid-column: span 6;
}

.col-12 {
  grid-column: span 12;
}

/* 2/3-column simple grids */
.g2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.g3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.g2--detail {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.full {
  grid-column: 1 / -1;
}

/* ─────────────────────────────────────────────────────────────
   8. TABLES
   ───────────────────────────────────────────────────────────── */

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 8px;
}

.table thead th {
  font-size: 12px;
  color: #444;
  text-transform: uppercase;
  letter-spacing: .02em;
  text-align: left;
  padding: 0 10px;
}

.table .row {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.table .row td {
  padding: 12px 14px;
  vertical-align: middle;
  border-top: 0;
}

.cell-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
}

.empty-state {
  padding: 22px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  text-align: center;
  color: #777;
}

/* ─────────────────────────────────────────────────────────────
   9. PAGINATION
   ───────────────────────────────────────────────────────────── */

.pagination {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: 14px;
}

.pagination a,
.pagination span {
  text-decoration: none;
  background: #fff;
  border: 1px solid #e1e5ea;
  border-radius: 10px;
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #222;
  font-weight: 700;
}

.pagination .active span {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.pagination .disabled span {
  opacity: .45;
}

/* ─────────────────────────────────────────────────────────────
   10. ALERTS & FEEDBACK
   ───────────────────────────────────────────────────────────── */

.alert {
  margin: 12px 0;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 14px;
}

.alert--ok {
  border: 1px solid #cfe8cf;
  background: #e9f7df;
  color: #2d5a2d;
}

.alert--error {
  border: 1px solid #f3c2c2;
  background: #fff3f3;
  color: #7a0000;
}

.alert--big {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  font-size: 16px;
  font-weight: 600;
}

.alert__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #3a9a3a;
  color: #fff;
  font-size: 18px;
  font-weight: 800;
  flex-shrink: 0;
}

/* ─────────────────────────────────────────────────────────────
   10b. LOAD MORE
   ───────────────────────────────────────────────────────────── */

.load-more {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.load-more__btn {
  min-width: 220px;
  justify-content: center;
}

.load-more__count {
  font-size: 13px;
  color: var(--muted);
}

/* ─────────────────────────────────────────────────────────────
   11. TAGS & BADGES
   ───────────────────────────────────────────────────────────── */

.badge {
  background: var(--accent);
  color: #fff;
  font-weight: 750;
  padding: 8px 12px;
  border-radius: 12px;
  display: inline-block;
}

.pill {
  background: var(--accent);
  color: #fff;
  padding: 8px 12px;
  border-radius: 12px;
  font-weight: 800;
  display: inline-block;
}

.tag {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  background: #f0f2f4;
  font-size: 12px;
}

.tag--green {
  background: #e9f7df;
}

.tag--blue {
  background: #eaf2ff;
}

.tag-self {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef1f4;
  font-size: 11px;
  color: #666;
  margin-left: 6px;
}

/* ─────────────────────────────────────────────────────────────
   12. STATS BAR
   ───────────────────────────────────────────────────────────── */

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  color: #555;
}

.stats--dots span {
  position: relative;
  padding-left: 10px;
}

.stats--dots span::before {
  content: "•";
  position: absolute;
  left: 0;
  color: #999;
}

.stats--dots span:first-child {
  padding-left: 0;
}

.stats--dots span:first-child::before {
  content: "";
}

/* ─────────────────────────────────────────────────────────────
   13. ORDER-SPECIFIC
   ───────────────────────────────────────────────────────────── */

/* Dashboard — order row */
.order-number {
  color: #111;
  font-weight: 700;
}

.order-client {
  color: var(--accent);
  font-weight: 700;
}

.order-date {
  color: var(--accent);
  font-weight: 700;
}

.order-mode {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.order-mode .sep {
  color: #bbb;
}

.order-mode .addr {
  color: #555;
}

/* Show — detail */
.detail-label {
  font-size: 12px;
  color: #445;
  margin-bottom: 4px;
}

.detail-value {
  font-weight: 700;
}

.detail-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Show — key/value grid for options */
.kv-grid {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 8px 16px;
}

.kv-key {
  font-size: 12px;
  color: #445;
}

.kv-val {
  font-weight: 600;
}

/* Show — media preview */
.media-preview {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
  align-items: start;
}

.media-thumb {
  width: 100%;
  max-width: 280px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #fafafa;
}

.media-thumb img {
  display: block;
  width: 100%;
  height: auto;
}

.media-thumb object {
  display: block;
  width: 100%;
  height: 360px;
  border: 0;
}

.media-meta {
  color: #555;
}

.actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 18px;
}

/* Create — form-specific */
.form-errors {
  border: 1px solid #f3c2c2;
  background: #fff3f3;
  color: #7a0000;
  margin-bottom: 12px;
}

.form-errors ul {
  margin: 0;
  padding-left: 18px;
}

/* ─────────────────────────────────────────────────────────────
   14. USERS-SPECIFIC
   ───────────────────────────────────────────────────────────── */

.inline-edit {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.inline-edit input[type="text"] {
  width: 160px;
}

.inline-edit input[type="email"] {
  width: 220px;
}

.inline-edit select {
  width: 120px;
}

.inline-edit input[type="password"] {
  width: 200px;
}

/* ─────────────────────────────────────────────────────────────
   15. LAB SWITCHER & LOGOUT
   ───────────────────────────────────────────────────────────── */

.lab-switcher {
  display: flex;
  gap: 8px;
  align-items: center;
}

.lab-switcher .tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid #dfe3ea;
  background: #fff;
  color: #111;
  text-decoration: none;
  font-weight: 600;
}

.lab-switcher .tab.active {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}

.logout-form {
  margin: 0;
}

/* ─────────────────────────────────────────────────────────────
   16. LOGIN PAGE
   ───────────────────────────────────────────────────────────── */

body.page-login {
  min-height: 100vh;
  background: #f4f6f1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 480px;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .08);
  padding: 40px 36px;
}

.login-logo {
  margin: 0 0 28px;
}

.login-logo-chantilly {
  color: #354156;
  font-size: 26px;
  font-weight: 700;
}

.login-logo-app {
  color: #6a82ab;
  font-size: 26px;
  font-weight: 700;
}

.login-field {
  margin-bottom: 18px;
}

.login-field label {
  font-weight: 600;
  color: #444;
}

.login-field input {
  height: 44px;
  padding: 12px 14px;
}

.login-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 6px;
}

.btn-lab {
  appearance: none;
  border: 0;
  border-radius: 14px;
  padding: 14px 20px;
  font-weight: 800;
  font-size: 16px;
  cursor: pointer;
  transition: opacity .15s;
}

.btn-lab:hover {
  opacity: .88;
}

.btn-lab:active {
  transform: scale(.98);
}

.btn-lab--dal {
  background: #bcd23a;
  color: #222;
}

.btn-lab--ven {
  background: #164f9e;
  color: #fff;
}

/* ─────────────────────────────────────────────────────────────
   17. USER HOME (pagina utente standard)
   ───────────────────────────────────────────────────────────── */

.user-home-card {
  background: var(--card);
  border-radius: 24px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .07);
  padding: 60px 40px;
  text-align: center;
  max-width: 520px;
  margin: 80px auto 0;
}

.user-home-icon {
  font-size: 56px;
  line-height: 1;
  margin-bottom: 20px;
}

.user-home-title {
  font-size: 24px;
  font-weight: 800;
  margin: 0 0 10px;
  color: var(--ink);
}

.user-home-text {
  color: var(--muted);
  font-size: 15px;
  margin: 0 0 28px;
  line-height: 1.5;
}

.user-home-btn {
  font-size: 18px;
  padding: 16px 40px;
  height: auto;
  border-radius: 16px;
}

@media (max-width: 500px) {
  .user-home-card {
    padding: 40px 24px;
    margin-top: 40px;
  }

  .user-home-btn {
    width: 100%;
  }
}

/* ─────────────────────────────────────────────────────────────
   18. RESPONSIVE
   ───────────────────────────────────────────────────────────── */

@media (max-width: 900px) {
  .g12 {
    grid-template-columns: 1fr;
  }

  .col-2,
  .col-3,
  .col-4,
  .col-6,
  .col-12 {
    grid-column: span 1;
  }

  .g2,
  .g3 {
    grid-template-columns: 1fr;
  }

  .g2--detail {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 820px) {
  .media-preview {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .table thead {
    display: none;
  }

  .table {
    border-spacing: 0 12px;
  }

  .table .row td {
    display: block;
    padding: 8px 12px;
  }

  .table .row td[data-h]::before {
    content: attr(data-h) ": ";
    font-weight: 700;
    color: #333;
  }

  .cell-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 700px) {
  .stats--dots span {
    padding-left: 0;
  }

  .stats--dots span::before {
    display: none;
  }
}

@media (max-width: 500px) {
  .login-card {
    padding: 28px 20px;
  }

  .login-buttons {
    grid-template-columns: 1fr;
  }

  .btnbar {
    justify-content: stretch;
  }

  .btnbar .btn {
    flex: 1;
  }

  @media (min-width: 721px) {
    .order-mode--truncate .addr {
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      max-width: 420px;
    }
  }
}

@media (min-width: 721px) {
  .order-mode--truncate .addr {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 420px;
  }
}