/* ============================================================
   modals.css — Modal base, scan, scelta metodo, recensione
   ============================================================ */

/* ── Struttura base modal ──────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 1rem;
}
.modal {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 18px; padding: 2rem;
  width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow);
}
.modal h2 { font-family: var(--font-display); font-size: 1.5rem; color: var(--accent); margin-bottom: 1rem; }

.modal-actions { display: flex; gap: .7rem; margin-top: 1rem; justify-content: flex-end; }

/* Pulsante × chiusura modal */
.modal-close-btn {
  position: absolute; top: 1rem; right: 1rem;
  background: none; border: none; color: var(--text-muted);
  font-size: 1.5rem; cursor: pointer; line-height: 1;
  transition: color var(--transition);
}
.modal-close-btn:hover { color: var(--text); }

/* ── Modal Scan — padding ridotto per stare in schermata ───── */
#modal-scan .modal         { padding: 1.2rem; }
#modal-scan .modal h2      { margin-bottom: .6rem; }
#modal-scan .scan-options  { margin-top: .5rem; }
#modal-scan .modal-actions { margin-top: .6rem; }

/* ── Modal "Aggiungi libro" — scelta metodo ────────────────── */
.modal-choice { max-width: 400px; }
.choice-btns  { display: flex; flex-direction: column; gap: .75rem; }
.choice-btn {
  display: flex; align-items: center; gap: 1rem;
  padding: 1rem 1.2rem;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius); cursor: pointer; text-align: left;
  font-family: var(--font-body);
  transition: border-color var(--transition), background var(--transition);
}
.choice-btn:hover { border-color: var(--moss); background: var(--bg-card); }
.choice-icon  { font-size: 1.8rem; flex-shrink: 0; }
.choice-label { display: block; font-size: 1rem; font-weight: 700; color: var(--text); margin-bottom: .15rem; }
.choice-desc  { display: block; font-size: .8rem; color: var(--text-muted); }

/* ── Modal Scan ────────────────────────────────────────────── */
/* #scanner-video è direttamente il tag <video> nell'HTML, non un
   contenitore — nessun elemento <video>/<canvas> annidato al suo interno */
#scanner-video { width: 100%; border-radius: var(--radius-sm); overflow: hidden; background: #000; height: 280px; object-fit: cover; display: block; }

/* Pulsante scatta foto */
.btn-capture {
  width: 100%; margin-top: .5rem; padding: .6rem;
  background: var(--moss); color: #fff; border: none;
  border-radius: var(--radius-sm); font-family: var(--font-body);
  font-size: .9rem; font-weight: 600; cursor: pointer;
  transition: background var(--transition);
}
.btn-capture:hover { background: var(--forest); }

/* Scelta metodo (fotocamera / ISBN manuale) */
.scan-method-choice { display: flex; gap: .75rem; margin-bottom: .8rem; }
.scan-method-btn {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; gap: .4rem; padding: .9rem;
  background: var(--bg-input); border: 1.5px solid var(--border);
  border-radius: var(--radius); cursor: pointer;
  font-family: var(--font-body); font-size: .88rem; font-weight: 600; color: var(--text);
  transition: all var(--transition);
}
.scan-method-btn:hover { border-color: var(--moss); color: var(--moss); }
.scan-method-icon { font-size: 1.6rem; }

/* Barra ISBN rilevato */
.scanner-isbn-bar {
  background: var(--bg-input); padding: .6rem 1rem;
  border-radius: var(--radius-sm); font-family: monospace;
  color: var(--accent); margin-top: .8rem;
}

/* Input ISBN manuale */
.scan-manual { display: flex; gap: .5rem; margin-top: 1rem; }
.scan-manual input {
  flex: 1; padding: .6rem .9rem;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-family: var(--font-body);
  transition: border-color var(--transition);
}
.scan-manual input:focus { outline: none; border-color: var(--moss); }
.scan-manual button {
  padding: .6rem 1rem;
  background: var(--moss); color: #fff;
  border: none; border-radius: var(--radius-sm);
  cursor: pointer; font-family: var(--font-body); font-weight: 600;
}

#scan-error { color: var(--red); font-size: .88rem; margin-top: .5rem; min-height: 1.2em; }

/* Blocco "libro non trovato" */
.scan-not-found {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 14px 16px; margin: 4px 0;
  background: var(--bg-card); border: 1.5px solid var(--border);
  border-radius: 10px; text-align: center;
}
.scan-not-found-msg { font-size: .88rem; color: var(--text-muted); margin: 0; }
.btn-add-manually {
  font-family: var(--font-body); font-size: .85rem; font-weight: 600;
  padding: 7px 18px; border: 1.5px solid var(--moss); border-radius: 20px;
  background: transparent; color: var(--moss);
  cursor: pointer; transition: all var(--transition);
}
.btn-add-manually:hover { background: var(--moss); color: var(--cream); }

/* Anteprima libro trovato via ISBN */
.scan-preview {
  background: var(--bg-input); border-radius: var(--radius);
  padding: 1rem; display: flex; gap: 1rem; align-items: flex-start; margin-top: 1rem;
}
.preview-cover  { width: 70px; height: 105px; object-fit: cover; border-radius: var(--radius-sm); flex-shrink: 0; }
.preview-badge  { font-size: .75rem; color: var(--text-muted); margin-bottom: .3rem; }
.preview-title  { font-weight: 700; line-height: 1.3; margin-bottom: .2rem; }
.preview-author { font-size: .85rem; color: var(--text-muted); }
.preview-year   { font-size: .8rem; color: var(--text-muted); }

/* Opzioni scan (stato + scaffale) */
.scan-options        { margin-top: 1rem; display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.scan-options select {
  padding: .5rem .8rem;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-family: var(--font-body);
}

/* ── Scelta destinazione (libreria / lista desideri) ───────── */
.destination-choice { margin-top: 1rem; }
.destination-label  {
  font-size: .82rem; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .05em; margin-bottom: .6rem;
}
.destination-btns { display: flex; gap: .5rem; margin-bottom: .8rem; }

.destination-btn {
  flex: 1; padding: .6rem 1rem;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-muted);
  font-size: .88rem; font-weight: 600; cursor: pointer; font-family: var(--font-body);
  transition: all var(--transition);
}
.destination-btn:hover  { border-color: var(--moss); color: var(--text); }
.destination-btn.active { background: var(--moss); border-color: var(--moss); color: #fff; }

.library-options { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; padding-top: .4rem; }
.library-options select {
  padding: .5rem .8rem;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-family: var(--font-body);
}

/* ── Modal recensione standalone ───────────────────────────── */
.star-rating { display: flex; gap: .3rem; margin: .8rem 0 1rem; }
.star {
  font-size: 1.8rem; cursor: pointer; color: var(--border);
  transition: color var(--transition), transform var(--transition);
  user-select: none;
}
.star:hover, .star.selected { color: var(--accent); transform: scale(1.15); }

#review-text {
  width: 100%; min-height: 120px; padding: .8rem 1rem;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  font-family: var(--font-body); font-size: .95rem; resize: vertical;
}
#review-text:focus { outline: none; border-color: var(--moss); }

.choice-icon-img {
  width: 30px; height: 30px; object-fit: contain; flex-shrink: 0;
}

@keyframes focusFade {
  0%   { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.4); }
}

@media (max-width: 768px) {
  .modal-backdrop {
    align-items: flex-start;
    padding-top: 60px;
  }
  .modal {
    max-height: calc(100vh - 130px);
    border-radius: 18px;
    width: 100%;
    max-width: 100%;
  }
  .library-options select {
    width: 100%;
    font-size: .8rem;
    padding: .4rem .5rem;
  }
  .library-options {
    grid-template-columns: auto minmax(0,1fr) auto minmax(0,1fr);
  }
  #scanner-video {
    width: 100%;
    height: auto;
    aspect-ratio: 4/3;
    object-fit: cover;
  }
}