/* dashboard.css */
/* dashboard admin: intestazione app, box link/QR, campi editabili, elenco sezioni e piatti, toast, loading */

/* ── MAIN APP ── */
#app-screen { display: none; padding: 28px 0 60px; }
.app-header { margin-bottom: 18px; }
.app-header h2 { font-family: var(--font-display); font-size: 26px; font-weight: 600; letter-spacing: -0.3px; }

/* ── LINK & QR CODE PREVIEW ── */
.preview-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; box-shadow: var(--shadow-sm); position: relative; overflow: hidden; }
.preview-card::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: linear-gradient(90deg, var(--accent), var(--accent-register)); }
.preview-link-box { flex: 1; font-size: 13px; color: var(--muted); min-width: 200px; }
.preview-link-box span { font-weight: 700; color: var(--text); text-transform: uppercase; letter-spacing: 0.6px; font-size: 11px; }
.preview-link-box .preview-link-desc { display: block; font-size: 11.5px; color: var(--muted); font-weight: 500; margin-top: 2px; text-transform: none; letter-spacing: normal; }
.preview-link-box a { color: var(--accent); text-decoration: none; font-weight: 700; display: block; margin-top: 4px; word-break: break-all; }
.preview-link-box a:hover { text-decoration: underline; }
.qr-box { display: flex; align-items: center; gap: 12px; }
#qr-canvas { width: 48px; height: 48px; border-radius: 6px; border: 1px solid var(--border); }
.qr-box-buttons { display: flex; flex-direction: column; gap: 6px; }

/* ── BARS & CARDS ── */
.restaurant-name-bar { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 18px; display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; box-shadow: var(--shadow-sm); }

/* ── CAMPI MODIFICABILI (nome ristorante, nome sezione): icona matita + bordo tratteggiato per far capire che si può cliccare e scrivere ── */
.editable-field-wrap { position: relative; display: flex; align-items: center; }
.editable-field-wrap input { border-bottom: 1.5px dashed var(--border) !important; padding-bottom: 3px !important; padding-right: 24px !important; transition: border-color 0.15s ease; }
.editable-field-wrap input:hover, .editable-field-wrap input:focus { border-bottom-color: var(--accent) !important; }
.editable-field-wrap input::placeholder { color: #ADB3A6; }
.editable-icon { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); font-size: 13px; color: var(--muted); pointer-events: none; opacity: 0.75; }
.editable-field-wrap:hover .editable-icon, .editable-field-wrap input:focus ~ .editable-icon { color: var(--accent); opacity: 1; }

.rest-name-wrap { flex: 1 1 160px; min-width: 0; }
.rest-name-wrap input { width: 100%; }
.restaurant-name-bar input { flex: 1 1 160px; min-width: 0; border: none; background: none; font-family: var(--font-display); font-size: 18px; font-weight: 600; color: var(--text); outline: none; }
.currency-label { flex: 0 0 auto; font-size: 12px; font-weight: 600; color: var(--muted); }
#currency-selector { flex: 0 1 auto; max-width: 100%; min-width: 0; padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; background: var(--surface); color: var(--text); font-family: var(--font-body); }

.sections-area { display: grid; gap: 18px; }
.section-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); transition: box-shadow 0.2s ease; }
.section-card:hover { box-shadow: var(--shadow-md); }
.section-header { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); background: #FAFAF7; border-radius: var(--radius) var(--radius) 0 0; }
.section-title-block { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.section-name-wrap { width: 100%; }
.section-name-input {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  border: none;
  background: transparent;
  outline: none;
  width: 100%;
  padding: 1px 22px 3px 0;
}
.section-name-en-input { border: none; border-bottom: 1px dashed transparent; background: transparent; font-size: 11px; color: var(--muted); font-family: var(--font-body); padding: 1px 0; outline: none; width: 100%; }
.section-name-en-input::placeholder { color: #B5BAAE; font-style: italic; }
.section-name-en-input:focus { border-bottom-color: var(--accent); }
.section-body { padding: 14px; }

/* ── DISHES ── */
.dish-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.dish-row { display: flex; align-items: center; gap: 10px; padding: 11px 13px; border: 1px solid #EEEFEA; border-radius: var(--radius-sm); background: #FCFCFA; transition: border-color 0.15s ease, background 0.15s ease, opacity 0.15s ease; position: relative; padding-right: 116px; }
.dish-row:hover { border-color: var(--border); }
.dish-row.dish-row-editing { border-color: var(--accent); background: var(--accent-light); }
.dish-row.dish-row-unavailable { background: #F3EFE9; border-color: #E7E1D6; opacity: 0.6; }
.dish-row.dish-row-unavailable:hover { opacity: 0.85; }
.dish-row .dish-name { font-weight: 700; flex: 1 1 auto; min-height: 20px; display: flex; align-items: center; gap: 6px; word-break: break-word; }
.dish-unavailable-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #A9663A;
  background: #F3E3D3;
  border: 1px solid #E9CBA9;
  border-radius: 4px;
  padding: 2px 6px;
  white-space: nowrap;
}
.dish-row .dish-price { font-family: var(--font-display); font-weight: 600; color: var(--accent-dark); font-size: 16px; flex-shrink: 0; margin-left: auto; }
.dish-row .dish-tag {
  border: 1px solid var(--accent-light);
  background: var(--accent-light);
  color: var(--accent-dark);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  flex-shrink: 0;
}
.dish-actions { display: flex; gap: 4px; position: absolute; top: 8px; right: 8px; z-index: 2; }
.btn-move { background: var(--surface); border: 1px solid var(--border); color: var(--muted); padding: 4px 7px; font-size: 11px; cursor: pointer; border-radius: 5px; transition: all 0.15s ease; min-width: 24px; }
.btn-move:hover { border-color: var(--accent); color: var(--accent); }
.toggle-dish-availability {
  cursor: pointer;
  padding: 0 6px;
  line-height: 1;
  -webkit-user-select: none;
  user-select: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  min-height: 22px;
}
.availability-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #3FA35A;
  box-shadow: 0 0 0 0 rgba(63, 163, 90, 0.6);
  animation: dot-pulse 1.8s ease-out infinite;
  transition: background 0.15s ease;
}
.toggle-dish-availability.is-off .availability-dot {
  background: #D64545;
  box-shadow: none;
  animation: none;
}
@keyframes dot-pulse {
  0% { box-shadow: 0 0 0 0 rgba(63, 163, 90, 0.55); }
  70% { box-shadow: 0 0 0 7px rgba(63, 163, 90, 0); }
  100% { box-shadow: 0 0 0 0 rgba(63, 163, 90, 0); }
}
.edit-dish { cursor: pointer; color: var(--muted); font-size: 16px; padding: 0 6px; line-height: 1; -webkit-user-select: none; user-select: none; transition: color 0.15s ease; display: inline-flex; align-items: center; justify-content: center; min-width: 22px; min-height: 22px; }
.edit-dish:hover { color: var(--accent); }
.del-dish { cursor: pointer; color: var(--danger); font-size: 18px; padding: 0 6px; line-height: 1; -webkit-user-select: none; user-select: none; transition: color 0.15s ease; display: inline-flex; align-items: center; justify-content: center; min-width: 22px; min-height: 22px; }
.del-dish:hover { color: #c62828; transform: scale(1.1); }
.edit-badge { width: 100%; background: var(--accent-light); color: var(--accent-dark); font-size: 12px; font-weight: 700; padding: 7px 11px; border-radius: var(--radius-sm); margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; }
.cancel-edit { cursor: pointer; text-decoration: underline; font-weight: 700; }

/* ── ADD DISH FORM ── */
.add-dish-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; padding-top: 14px; border-top: 1px dashed var(--border); }
.add-dish-form .f { flex: 2; min-width: 100px; }
.add-dish-form .f-sm { flex: 1; min-width: 70px; }
.add-dish-form label { display: block; font-size: 10px; font-weight: 700; color: var(--muted); margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.6px; }
.f-optional { font-weight: 500; text-transform: none; letter-spacing: normal; color: #9AA096; }
.add-dish-form input, .add-dish-form select { width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; background: var(--surface); outline: none; font-family: var(--font-body); transition: border-color 0.2s, box-shadow 0.2s; }
.add-dish-form input:focus, .add-dish-form select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }

/* ── ADD SECTION ── */
.add-section-area { background: var(--surface); border: 1.5px dashed var(--border); border-radius: var(--radius); padding: 14px; display: flex; gap: 8px; align-items: center; margin-top: 18px; transition: border-color 0.2s ease; }
.add-section-area:focus-within { border-color: var(--accent); }
.add-section-area input { flex: 1; padding: 11px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; outline: none; font-family: var(--font-body); }
.add-section-area input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }

/* ── UTILITIES ── */
.empty { text-align: center; padding: 34px 16px; color: var(--muted); font-size: 13.5px; }

/* ── LOADING & TOAST ── */
#loading { position: fixed; inset: 0; background: var(--bg); display: flex; align-items: center; justify-content: center; z-index: 999; }
.spinner { border: 2.5px solid var(--border); border-top: 2.5px solid var(--accent); border-radius: 50%; width: 26px; height: 26px; animation: spin 0.8s linear infinite; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(10px); background: var(--accent-dark); color: #fff; border-radius: var(--radius-sm); padding: 11px 18px; font-size: 13px; font-weight: 600; z-index: 9999; opacity: 0; box-shadow: var(--shadow-lg); transition: all 0.3s ease; pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── RESPONSIVE OVERRIDES DINAMICI ── */
@media (max-width: 600px) {
  /* Protegge lo spazio in alto a destra esclusivamente per le frecce di movimento */
  .dish-list .dish-row {
    padding-right: 75px !important;
    flex-wrap: wrap !important;
    gap: 8px 12px !important;
  }
  
  /* Il nome prende tutto lo spazio orizzontale a disposizione prima delle frecce */
  .dish-list .dish-row .dish-name {
    flex: 1 1 100% !important;
    width: 100% !important;
  }

  /* Il prezzo va a inizio riga sotto al nome */
  .dish-list .dish-row .dish-price {
    margin-left: 0 !important;
  }

  /* Il blocco controlli si adatta in basso a sinistra seguendo prezzo e tag */
  .dish-list .dish-actions {
    position: static !important;
    display: flex !important;
    gap: 8px !important;
    align-items: center !important;
    margin-left: 0 !important;
    z-index: auto !important;
  }

  /* Estrae solo le frecce per riposizionarle assolute in alto a destra rispetto a .dish-row */
  .dish-list .dish-row .btn-move {
    position: absolute !important;
    top: 11px !important;
    right: 13px !important;
  }

  /* Se ci sono due freccette (su e giù), la prima scala a sinistra di 29px per far spazio alla seconda */
  .dish-list .dish-row .btn-move:has(+ .btn-move) {
    right: 42px !important;
  }
}
/* ── SOTTOSEZIONI (es. dentro "Vini": Cantina Rossi, Cantina Bianchi...) ──
   Reso volutamente più "pesante" del semplice nome piatto: sfondo tinto,
   bordo laterale spesso e un'etichetta "Sottosezione" sopra il nome, così
   non si confonde mai con una riga piatto quando si scorre l'elenco. ── */
/* Le sottosezioni vivono DENTRO una sezione: devono leggersi come un livello
   subordinato (rientro + bordo sottile), mai più "pesanti" della sezione che
   le contiene (niente sfondo colorato, niente bordo spesso, niente scritte
   tutte maiuscole in grassetto). */
.subsections-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.subsection-card {
  border: 1px solid var(--border);
  border-left: 3px solid #C9DBD2;
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.subsection-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--border);
  background: #FAFAF7;
  flex-wrap: wrap;
}
.subsection-name-wrap { flex: 1 1 200px; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.subsection-eyebrow {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  margin-bottom: 2px;
}
.subsection-name-input {
  font-family: var(--font-display);
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text);
  border: none;
  background: transparent;
  outline: none;
  width: 100%;
  padding: 1px 22px 3px 0;
}
.subsection-name-en-input { flex: 1 1 160px; min-width: 0; border: none; border-bottom: 1px dashed transparent; background: transparent; font-size: 11px; color: var(--muted); font-family: var(--font-body); padding: 1px 0; outline: none; }
.subsection-name-en-input::placeholder { color: #ADB3A6; font-style: italic; }
.subsection-name-en-input:focus { border-bottom-color: var(--accent); }
.subsection-actions { display: flex; gap: 4px; flex-shrink: 0; }
.subsection-body { padding: 12px; background: var(--surface); border-radius: 0 0 var(--radius-sm) var(--radius-sm); }
.add-subsection-area { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.add-subsection-area input { flex: 1; padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; outline: none; font-family: var(--font-body); }
.add-subsection-area input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
.add-subsection-hint { margin-top: 10px; }
.add-subsection-link { font-size: 12px; font-weight: 600; color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }

@media (max-width: 600px) {
  /* Invece di impilare in colonna ogni elemento (nome, nome EN, pulsanti)
     su righe separate — che allunga troppo l'header — teniamo il nome e i
     pulsanti sulla stessa riga, e mandiamo a capo solo il campo EN, che
     diventa una seconda riga a piena larghezza. Risultato: 2 righe invece di 3-4. */
  .subsection-header { flex-wrap: wrap; align-items: center; row-gap: 6px; }
  .subsection-name-wrap { flex: 1 1 140px; min-width: 0; }
  .subsection-actions { flex: 0 0 auto; }
  .subsection-name-en-input { flex: 1 1 100%; order: 3; }
  .subsection-eyebrow { display: none; }
}