@import url("./tokens.css");

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

[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
}

/* ── LOGIN ── */
.login-wrap {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 400px;
}

.login-brand {
  text-align: center;
  margin-bottom: 2rem;
}

.login-brand h1 {
  margin: 0 0 0.25rem;
  font-size: 1.5rem;
  letter-spacing: -0.02em;
}

.login-brand p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.login-hint {
  margin: 1.25rem 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
}

.login-hint code {
  color: var(--text);
  background: var(--bg);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.8rem;
}

/* ── FORM ── */
.form-grid {
  display: grid;
  gap: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.error-msg {
  margin: 0;
  font-size: 0.875rem;
  color: #f87171;
}

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.75rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
  font-family: inherit;
  text-decoration: none;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: white;
}

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

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

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

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

.btn-success {
  background: rgba(34, 197, 94, 0.12);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.35);
  padding: 0.925rem;
  font-size: 1rem;
}

.btn-success:hover {
  background: rgba(34, 197, 94, 0.22);
}

.btn-ghost {
  background: none;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.btn-sm {
  padding: 0.45rem 0.875rem;
  font-size: 0.85rem;
}

.btn-full {
  width: 100%;
}

/* ── APP SHELL ── */
.aux-app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.aux-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

.aux-brand {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.aux-user {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

/* ── VIEWS ── */
.aux-view {
  display: none;
}

.aux-view.active {
  display: block;
}

.view-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.view-title {
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}

.view-sub {
  margin: -0.5rem 0 0;
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* ── SCAN BUTTON ── */
.scan-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
  padding: 2rem 1.5rem;
  background: rgba(59, 130, 246, 0.07);
  border: 2px dashed rgba(59, 130, 246, 0.35);
  border-radius: var(--radius);
  color: var(--accent);
  font: 600 1rem var(--font);
  cursor: pointer;
  transition: background 0.2s;
}

.scan-btn:hover {
  background: rgba(59, 130, 246, 0.13);
}

.scan-icon {
  font-size: 2.5rem;
  line-height: 1;
}

/* ── SCAN OVERLAY ── */
.scan-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1.5rem;
}

.scan-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  width: 100%;
  max-width: 380px;
}

.scan-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.95rem;
}

.btn-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.35rem;
  cursor: pointer;
  line-height: 1;
  padding: 0;
}

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

#qr-reader {
  width: 100%;
  min-height: 260px;
}

.scan-error {
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
}

.scan-footer {
  padding: 0.875rem 1rem;
  border-top: 1px solid var(--border);
}

/* ── SEARCH MODAL ── */
.search-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: flex-end;
  z-index: 100;
}

.search-modal {
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-height: 85dvh;
  display: flex;
  flex-direction: column;
}

.search-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.search-input-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon-input {
  position: absolute;
  left: 0.875rem;
  font-size: 0.875rem;
  pointer-events: none;
  line-height: 1;
}

#search-input {
  width: 100%;
  padding: 0.65rem 0.875rem 0.65rem 2.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font: inherit;
  font-size: 1rem;
}

#search-input:focus {
  outline: none;
  border-color: var(--accent);
}

.search-list {
  flex: 1;
  overflow-y: auto;
}

.search-item {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 1rem 1.25rem;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-family: inherit;
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
}

.search-item:last-child {
  border-bottom: none;
}

.search-item:hover {
  background: var(--surface-hover);
}

.search-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
}

.search-item-name {
  font-weight: 600;
  font-size: 0.975rem;
}

.search-item-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

.search-empty {
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ── DIVIDER ── */
.divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── UTENTE BAR ── */
.utente-bar {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.875rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.btn-back {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
}

.btn-back:hover {
  color: var(--text);
}

.utente-name {
  font-weight: 700;
  font-size: 1.05rem;
}

.utente-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ── CHECKLIST ── */
#checklist {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.check-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.2s;
}

.check-card.on {
  border-color: rgba(34, 197, 94, 0.4);
}

.check-card-main {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
}

.check-icon {
  font-size: 1.35rem;
  line-height: 1;
  flex-shrink: 0;
}

.check-label {
  flex: 1;
  font-weight: 500;
  font-size: 0.95rem;
}

.check-toggle {
  padding: 0.375rem 0.875rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  font: 600 0.825rem var(--font);
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
  flex-shrink: 0;
  min-width: 52px;
}

.check-card.on .check-toggle {
  background: rgba(34, 197, 94, 0.12);
  color: #4ade80;
  border-color: rgba(34, 197, 94, 0.4);
}

.check-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0 1rem 0.875rem;
}

.option-pill {
  padding: 0.35rem 0.875rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font: 500 0.85rem var(--font);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.option-pill.active {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border-color: rgba(59, 130, 246, 0.4);
}

.check-expand {
  padding: 0 1rem 0.875rem;
}

.check-text {
  width: 100%;
  padding: 0.65rem 0.875rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  resize: vertical;
}

.check-text:focus {
  outline: none;
  border-color: var(--accent);
}

/* ── SENT BANNER ── */
.sent-banner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.95rem;
}

.sent-banner-success {
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: #4ade80;
}

.sent-banner-warning {
  background: rgba(234, 179, 8, 0.1);
  border: 1px solid rgba(234, 179, 8, 0.3);
  color: #facc15;
}

.sent-banner-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

/* ── OBSERVATIONS ── */
.obs-group textarea {
  resize: vertical;
}

/* ── SAVE BUTTON ── */
.btn-save {
  padding: 0.925rem;
  font-size: 1rem;
}

/* ── TOAST ── */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(140%);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.875rem 1.5rem;
  border-radius: 999px;
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  opacity: 0;
  transition: transform 0.3s, opacity 0.3s;
  pointer-events: none;
  z-index: 300;
  white-space: nowrap;
}

.toast.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast-success {
  border-color: rgba(34, 197, 94, 0.4);
  color: #4ade80;
}

.toast-warning {
  border-color: rgba(234, 179, 8, 0.4);
  color: #facc15;
}
