/* ============================================================
   FLEXO Expenses — Mobile-first CSS
   ============================================================ */

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

:root {
  --gold:       #F0C040;
  --gold-dk:    #C9960A;
  --dark:       #0F0F1A;
  --dark-2:     #14141F;
  --dark-3:     #1A1A2A;
  --dark-4:     #222235;
  --border:     rgba(255,255,255,.08);
  --white:      #FFFFFF;
  --text:       #E0E0EE;
  --text-muted: #8888AA;
  --green:      #10b981;
  --red:        #ef4444;
  --radius:     12px;
  --radius-sm:  8px;
  --shadow:     0 8px 32px rgba(0,0,0,.4);
}

html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
  background: var(--dark);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Navbar ───────────────────────────────────────────────── */
.navbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; height: 56px;
  background: rgba(15,15,26,.95); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.navbar-logo {
  font-size: 1.1rem; font-weight: 800;
  background: linear-gradient(135deg, var(--gold), #fff);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.navbar-lang { display: flex; gap: 4px; }
.lang-btn {
  background: none; border: 1px solid var(--border); color: var(--text-muted);
  border-radius: 6px; padding: 4px 10px; font-size: .78rem; cursor: pointer;
  transition: border-color .15s, color .15s;
}
.lang-btn.active, .lang-btn:hover { border-color: var(--gold); color: var(--gold); }
.hamburger {
  display: flex; flex-direction: column; gap: 5px; background: none; border: none;
  cursor: pointer; padding: 6px;
}
.hamburger span { display: block; width: 22px; height: 2px; background: var(--text); border-radius: 2px; transition: .2s; }

/* ── Drawer menu ──────────────────────────────────────────── */
.drawer {
  position: fixed; inset: 0; z-index: 200;
  display: none;
}
.drawer.open { display: block; }
.drawer-overlay { position: absolute; inset: 0; background: rgba(0,0,0,.5); }
.drawer-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: 260px;
  background: var(--dark-3); border-left: 1px solid var(--border);
  padding: 24px 20px; display: flex; flex-direction: column; gap: 8px;
  animation: slideIn .2s ease;
}
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
.drawer-close {
  align-self: flex-end; background: none; border: none; color: var(--text-muted);
  font-size: 1.4rem; cursor: pointer; margin-bottom: 12px;
}
.drawer-item {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px;
  border-radius: var(--radius-sm); color: var(--text); text-decoration: none;
  font-size: .95rem; font-weight: 500; cursor: pointer; background: none; border: none; width: 100%;
  transition: background .15s;
}
.drawer-item:hover { background: rgba(255,255,255,.05); }
.drawer-item .icon { font-size: 1.2rem; width: 24px; text-align: center; }
.drawer-sep { height: 1px; background: var(--border); margin: 8px 0; }

/* ── Main layout ──────────────────────────────────────────── */
.main { max-width: 600px; margin: 0 auto; padding: 20px 16px 80px; }

/* ── Hero actions ─────────────────────────────────────────── */
.hero-actions {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 24px;
}
.hero-actions .btn-full { grid-column: 1/-1; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 20px; border-radius: var(--radius-sm); font-size: .95rem; font-weight: 700;
  cursor: pointer; border: none; transition: opacity .15s, transform .1s;
  text-decoration: none; -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.97); }
.btn-gold  { background: var(--gold);  color: #0F0F1A; }
.btn-dark  { background: var(--dark-4); color: var(--text); border: 1px solid var(--border); }
.btn-red   { background: var(--red);   color: #fff; }
.btn-ghost { background: none; color: var(--text-muted); border: 1px solid var(--border); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn-lg { padding: 18px 24px; font-size: 1.05rem; }
.btn-sm { padding: 8px 14px; font-size: .85rem; }

/* ── Stats bar ────────────────────────────────────────────── */
.stats-bar {
  display: flex; gap: 12px; margin-bottom: 20px;
  background: var(--dark-3); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px;
}
.stat-item { flex: 1; text-align: center; }
.stat-value { font-size: 1.4rem; font-weight: 800; color: var(--gold); }
.stat-label { font-size: .72rem; color: var(--text-muted); margin-top: 2px; }

/* ── Scan form ────────────────────────────────────────────── */
.scan-card {
  background: var(--dark-3); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; margin-bottom: 20px; display: none;
}
.scan-card.visible { display: block; }

.drop-zone {
  border: 2px dashed var(--border); border-radius: var(--radius-sm);
  padding: 32px 16px; text-align: center; cursor: pointer;
  transition: border-color .2s; margin-bottom: 16px;
}
.drop-zone:hover, .drop-zone.drag-over { border-color: var(--gold); }
.drop-zone .drop-icon { font-size: 2.5rem; margin-bottom: 8px; }
.drop-zone p { color: var(--text-muted); font-size: .88rem; }
.drop-zone .file-name { color: var(--gold); font-weight: 600; margin-top: 6px; font-size: .9rem; }

.preview-img {
  max-width: 100%; max-height: 200px; border-radius: var(--radius-sm);
  margin-bottom: 16px; display: none;
}
.preview-img.visible { display: block; }

/* ── Form fields ──────────────────────────────────────────── */
.form-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px;
}
.form-grid .span-2 { grid-column: 1/-1; }

.field label { display: block; font-size: .75rem; font-weight: 600; color: var(--text-muted); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .05em; }
.field input, .field select {
  width: 100%; padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--dark-4); border: 1px solid var(--border); color: var(--text);
  font-size: .9rem; outline: none; transition: border-color .15s;
  -webkit-appearance: none;
}
.field input:focus, .field select:focus { border-color: var(--gold); }
.field .hint { font-size: .72rem; margin-top: 4px; }
.hint-high   { color: var(--green); }
.hint-medium { color: var(--gold); }
.hint-low    { color: var(--text-muted); }

/* ── Expenses table ───────────────────────────────────────── */
.expenses-section { display: none; }
.expenses-section.visible { display: block; }

.section-title {
  font-size: 1rem; font-weight: 700; color: var(--text); margin-bottom: 12px;
  display: flex; align-items: center; justify-content: space-between;
}

.expense-list { display: flex; flex-direction: column; gap: 8px; }

.expense-item {
  background: var(--dark-3); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 14px;
}
.expense-item-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 6px; }
.expense-fornitore { font-weight: 700; font-size: .95rem; }
.expense-totale { font-weight: 800; color: var(--gold); font-size: 1rem; }
.expense-meta { font-size: .78rem; color: var(--text-muted); display: flex; gap: 8px; flex-wrap: wrap; }
.expense-actions { display: flex; gap: 6px; margin-top: 10px; }

/* ── Toast ────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--dark-4); border: 1px solid var(--border); color: var(--text);
  padding: 12px 20px; border-radius: 100px; font-size: .88rem;
  box-shadow: var(--shadow); z-index: 500; transition: opacity .3s;
  white-space: nowrap; max-width: 90vw;
}
.toast.success { border-color: var(--green); color: var(--green); }
.toast.error   { border-color: var(--red);   color: var(--red); }
.toast.hidden  { opacity: 0; pointer-events: none; }

/* ── Loading spinner ──────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px; border: 2px solid var(--border);
  border-top-color: var(--gold); border-radius: 50%;
  animation: spin .6s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Limit warning ────────────────────────────────────────── */
.limit-bar {
  height: 4px; background: var(--dark-4); border-radius: 2px; overflow: hidden; margin-top: 6px;
}
.limit-fill { height: 100%; background: var(--gold); border-radius: 2px; transition: width .3s; }
.limit-fill.warning  { background: #f97316; }
.limit-fill.exceeded { background: var(--red); }

/* ── Empty state ──────────────────────────────────────────── */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state p { font-size: .9rem; }

/* ── Bottom nav (mobile) ──────────────────────────────────── */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex; background: rgba(15,15,26,.98); border-top: 1px solid var(--border);
  z-index: 90;
}
.bottom-nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  padding: 10px 6px; color: var(--text-muted); font-size: .7rem; font-weight: 600;
  cursor: pointer; background: none; border: none; gap: 4px; transition: color .15s;
}
.bottom-nav-item .nav-icon { font-size: 1.4rem; }
.bottom-nav-item.active { color: var(--gold); }

/* ── Modal ────────────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 300;
}
.modal-overlay.open { display: flex; align-items: flex-end; justify-content: center; }
.modal {
  background: var(--dark-3); border: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0;
  padding: 24px 20px; width: 100%; max-width: 600px; max-height: 90vh; overflow-y: auto;
}
.modal-title { font-size: 1.05rem; font-weight: 800; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.modal-actions .btn { flex: 1; }

/* ── Email modal ──────────────────────────────────────────── */
.email-field { margin-bottom: 12px; }
.email-field label { display: block; font-size: .78rem; color: var(--text-muted); margin-bottom: 6px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.email-field input, .email-field textarea {
  width: 100%; padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--dark-4); border: 1px solid var(--border); color: var(--text);
  font-size: .9rem; outline: none; transition: border-color .15s; font-family: inherit;
}
.email-field input:focus, .email-field textarea:focus { border-color: var(--gold); }

.auth-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--dark-3); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 18px;
}
.auth-banner-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.auth-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px;
}
.auth-card {
  width: 100%; max-width: 420px; background: var(--dark-3); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px 20px; box-shadow: var(--shadow);
}
.auth-card h1 { font-size: 1.4rem; margin-bottom: 8px; }
.auth-subtitle { color: var(--text-muted); margin-bottom: 18px; font-size: .95rem; }
.auth-form { display: flex; flex-direction: column; gap: 10px; }
.auth-form label { font-size: .78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.auth-form input {
  width: 100%; padding: 12px; border-radius: var(--radius-sm); background: var(--dark-4);
  border: 1px solid var(--border); color: var(--text); font-size: .95rem;
}
.auth-form input:focus { outline: none; border-color: var(--gold); }
.auth-message { min-height: 22px; font-size: .85rem; }
.auth-message.error { color: var(--red); }
.auth-message.success { color: var(--green); }
.auth-links { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.auth-links a { color: var(--gold); text-decoration: none; }
.auth-lang { justify-content: flex-end; margin-bottom: 16px; }

@media (min-width: 600px) {
  .hero-actions { grid-template-columns: repeat(3, 1fr); }
  .hero-actions .btn-full { grid-column: auto; }
  .bottom-nav { display: none; }
  .main { padding-bottom: 40px; }
}
