/* =============================================================================
   PORTALE CLIENTI — Identita visiva Piscopiello Ponteggi srl
   Palette, tipografia e componenti ispirati al sito piscopielloponteggi.it
   ============================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;600;700&family=Roboto+Slab:wght@500;600;700&display=swap');

:root {
  --brand-primary:   #E46E70;
  --brand-dark:      #c95557;
  --brand-darker:    #b04345;
  --ink:             #1a1a1a;
  --ink-soft:        #55605a;
  --bg:              #ffffff;
  --bg-soft:         #f7faf4;
  --bg-muted:        #eef2ea;
  --border:          #e7ede0;
  --border-strong:   #d0d8c9;
  --danger:          #D14343;
  --success:         #5FA86B;
  --accent:          #CBCE61;

  --font-body:  'Roboto', sans-serif;
  --font-display: 'Roboto Slab', serif;
  --radius:     8px;
  --radius-lg:  12px;
  --radius-pill: 24px;
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.06);
  --shadow-md:  0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg:  0 8px 24px rgba(0,0,0,0.10);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg-soft);
  font-family: var(--font-body);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* ─── LOGIN ───────────────────────────────────────────────────── */
.login-wrap {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, var(--bg-soft) 0%, var(--bg-muted) 100%);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 36px 32px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.login-logo {
  display: block;
  max-width: 220px;
  height: auto;
  margin: 0 auto 24px;
}

.login-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 4px;
  color: var(--ink);
}

.login-sub {
  font-size: 13.5px;
  color: var(--ink-soft);
  margin: 0 0 28px;
  line-height: 1.5;
}

/* ─── FORM ELEMENTS ───────────────────────────────────────────── */
.field {
  margin-bottom: 18px;
  text-align: left;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 6px;
}

.field input,
.field select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 11px 14px;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%237A7A7A' fill='none' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(228, 110, 112, 0.15);
}

.field-help {
  display: block;
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 4px;
}

.field-checkbox {
  display: flex;
  align-items: center;
}

.field-checkbox label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
}

.field-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--brand-primary);
}

/* ─── BUTTONS ─────────────────────────────────────────────────── */
.btn-primary {
  width: 100%;
  background: var(--brand-primary);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-pill);
  padding: 12px 24px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.btn-primary:hover { background: var(--brand-dark); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:focus-visible { outline: 2px solid var(--brand-primary); outline-offset: 2px; }

.btn-primary.btn-inline {
  width: auto;
  display: inline-block;
  padding: 12px 28px;
}

.btn-cancel {
  display: inline-block;
  padding: 12px 28px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  color: var(--ink-soft);
  text-decoration: none;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.btn-cancel:hover { border-color: var(--ink-soft); color: var(--ink); }

/* ─── ALERTS ──────────────────────────────────────────────────── */
.alert {
  background: rgba(209, 67, 67, 0.08);
  border: 1px solid rgba(209, 67, 67, 0.25);
  color: #c0392b;
  font-size: 13px;
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 20px;
}

.alert-success {
  background: rgba(95, 168, 107, 0.08);
  border: 1px solid rgba(95, 168, 107, 0.25);
  color: #2d7a3f;
  font-size: 13px;
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 20px;
}

.login-footer {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--ink-soft);
  text-align: center;
}

/* ─── DASHBOARD / HEADER ──────────────────────────────────────── */
.dash-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 32px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
}

.dash-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.dash-brand .brand-logo {
  height: 36px;
  width: auto;
}

.dash-brand .client-name {
  font-size: 14px;
  color: var(--ink-soft);
  font-weight: 400;
  padding-left: 12px;
  border-left: 1px solid var(--border);
}

.btn-logout {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  padding: 8px 18px;
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.btn-logout:hover { border-color: var(--brand-primary); color: var(--brand-primary); }

/* ─── ADMIN NAV ───────────────────────────────────────────────── */
.admin-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.nav-link {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  text-decoration: none;
  transition: all 0.15s ease;
}
.nav-link:hover { color: var(--ink); background: var(--bg-muted); }
.nav-link.active { color: var(--brand-primary); background: rgba(228,110,112,0.08); }

/* ─── DASHBOARD MAIN ──────────────────────────────────────────── */
.dash-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 32px 80px;
}

.dash-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 4px;
  color: var(--ink);
}

.dash-sub {
  color: var(--ink-soft);
  font-size: 14px;
  margin: 0 0 32px;
}

.dash-sub a {
  color: var(--brand-primary);
  text-decoration: none;
  font-weight: 500;
}
.dash-sub a:hover { text-decoration: underline; }

/* ─── KPI CARDS ───────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 36px;
}

.kpi-grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.kpi-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 20px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s ease;
}

.kpi-card:hover {
  box-shadow: var(--shadow-md);
}

.kpi-value {
  display: block;
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 6px;
}

.kpi-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
}

.kpi-card.kpi-alert {
  border-color: rgba(209, 67, 67, 0.3);
}
.kpi-card.kpi-alert .kpi-value { color: var(--danger); }

.kpi-card.kpi-ok {
  border-color: rgba(95, 168, 107, 0.3);
}
.kpi-card.kpi-ok .kpi-value { color: var(--success); }

/* ─── ADMIN SECTIONS ──────────────────────────────────────────── */
.admin-section {
  margin-bottom: 40px;
}

.section-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 16px;
  color: var(--ink);
}

.section-subtitle {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  margin: 32px 0 16px;
  color: var(--brand-primary);
}

.section-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

/* ─── MANIFEST TABLE ──────────────────────────────────────────── */
.manifest {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg);
  box-shadow: var(--shadow-sm);
}

.manifest-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto auto auto;
  gap: 18px;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  transition: background 0.1s ease;
}
.manifest-row:last-child { border-bottom: none; }
.manifest-row:not(.head):hover { background: var(--bg-soft); }

.manifest-row.head {
  background: var(--bg-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  padding: 12px 20px;
}

.file-name {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
  word-break: break-all;
}

.file-meta {
  font-size: 12.5px;
  color: var(--ink-soft);
  white-space: nowrap;
}

.text-danger { color: var(--danger) !important; }

.link-sito {
  color: var(--brand-primary);
  text-decoration: none;
  font-size: 12px;
  font-weight: 500;
}
.link-sito:hover { text-decoration: underline; }

.link-inline {
  color: var(--brand-primary);
  text-decoration: none;
  font-weight: 500;
}
.link-inline:hover { text-decoration: underline; }

.btn-download {
  font-size: 12px;
  font-weight: 600;
  color: #ffffff;
  background: var(--brand-primary);
  border: none;
  border-radius: var(--radius-pill);
  padding: 8px 18px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s ease;
}
.btn-download:hover { background: var(--brand-dark); }

.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 14px;
}
.empty-state .icon {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--brand-primary);
  display: block;
  margin-bottom: 8px;
}

/* ─── ACTION BUTTONS ──────────────────────────────────────────── */
.actions-cell {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.btn-sm {
  font-size: 12px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--ink-soft);
  transition: all 0.15s ease;
}
.btn-sm:hover { border-color: var(--ink); color: var(--ink); }

.btn-sm.btn-toggle {
  border-color: rgba(228, 110, 112, 0.3);
  color: var(--brand-primary);
}
.btn-sm.btn-toggle:hover {
  background: rgba(228, 110, 112, 0.08);
  border-color: var(--brand-primary);
}

.btn-sm.btn-danger {
  border-color: rgba(209, 67, 67, 0.3);
  color: var(--danger);
}
.btn-sm.btn-danger:hover {
  background: rgba(209, 67, 67, 0.08);
  border-color: var(--danger);
}

.row-inactive {
  opacity: 0.5;
}

/* ─── BADGES ──────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
}

.badge-ok { background: rgba(95,168,107,0.12); color: #2d7a3f; }
.badge-off { background: rgba(209,67,67,0.12); color: #c0392b; }
.badge-upload { background: rgba(228,110,112,0.12); color: var(--brand-primary); }
.badge-url { background: rgba(85,96,90,0.12); color: var(--ink-soft); }

.badge-login_fallito { background: rgba(209,67,67,0.12); color: #c0392b; }
.badge-login_admin_fallito { background: rgba(209,67,67,0.12); color: #c0392b; }
.badge-login_disattivato { background: rgba(203,206,97,0.15); color: #8a8b3e; }
.badge-download_negato { background: rgba(209,67,67,0.12); color: #c0392b; }
.badge-download_errore { background: rgba(209,67,67,0.12); color: #c0392b; }

.badge-nuovi_prodotti { background: rgba(95,168,107,0.12); color: #2d7a3f; }
.badge-prodotti_rimossi { background: rgba(209,67,67,0.12); color: #c0392b; }
.badge-prezzo_modificato { background: rgba(203,206,97,0.15); color: #8a8b3e; }
.badge-nessuna_modifica { background: rgba(85,96,90,0.08); color: var(--ink-soft); }
.badge-prima_analisi { background: rgba(85,96,90,0.12); color: var(--ink-soft); }

/* ─── ADMIN FORM ──────────────────────────────────────────────── */
.admin-form {
  max-width: 600px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  margin-bottom: 32px;
  box-shadow: var(--shadow-sm);
}

.dash-form-wrap {
  max-width: 800px;
}

.form-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 24px;
}

.field-or {
  text-align: center;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 16px 0;
}

/* ─── FILTER FORM ─────────────────────────────────────────────── */
.filter-form {
  max-width: 100%;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.filter-group {
  flex: 1;
  min-width: 150px;
}

.filter-group label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  margin-bottom: 6px;
}

.filter-group select,
.filter-group input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 10px 12px;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 13px;
}

.filter-actions {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex: 0;
  min-width: auto;
}

/* ─── ANALYSIS RESULT ─────────────────────────────────────────── */
.analysis-result {
  margin-top: 32px;
}

.detail-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-top: 16px;
  box-shadow: var(--shadow-sm);
}

.detail-box h4 {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 12px;
  color: var(--ink);
}

.detail-box.error-box {
  border-color: rgba(209, 67, 67, 0.3);
}
.detail-box.error-box h4 { color: var(--danger); }

.detail-box.change-box {
  border-color: rgba(203, 206, 97, 0.4);
}
.detail-box.change-box h4 { color: #8a8b3e; }

.detail-box.info-box {
  border-color: var(--border);
}

.error-list {
  margin: 0;
  padding: 0 0 0 18px;
  list-style: none;
}

.error-list li {
  font-size: 13px;
  color: #c0392b;
  padding: 3px 0;
  position: relative;
}

.error-list li::before {
  content: "!";
  color: var(--danger);
  font-weight: 700;
  position: absolute;
  left: -16px;
}

.detail-box ul {
  margin: 0;
  padding: 0 0 0 18px;
  list-style: none;
}

.detail-box ul li {
  font-size: 13px;
  color: var(--ink-soft);
  padding: 4px 0;
}

.tag {
  display: inline-block;
  font-size: 12px;
  padding: 4px 10px;
  margin: 2px 4px 2px 0;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--ink-soft);
}

.more-info {
  font-size: 12px;
  color: var(--ink-soft);
  font-style: italic;
  margin-top: 12px;
}

/* ─── PAGINATION ──────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 24px;
}

.page-info {
  font-size: 13px;
  color: var(--ink-soft);
}

/* ─── RESPONSIVE ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  .manifest-row { grid-template-columns: 1fr; gap: 8px; }
  .manifest-row.head { display: none; }
  .btn-download { justify-self: start; }
  .dash-main { padding: 28px 18px 60px; }
  .dash-header { padding: 14px 18px; }
  .admin-nav { gap: 2px; }
  .nav-link { padding: 6px 10px; font-size: 12px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi-grid-3 { grid-template-columns: 1fr; }
  .filter-form { flex-direction: column; }
  .admin-form { padding: 20px; }
  .actions-cell { flex-direction: column; }
  .section-top { flex-direction: column; gap: 12px; align-items: flex-start; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .admin-nav { display: none; }
}

/* ─── FOOTER ───────────────────────────────────────────────────── */
.site-footer {
  background: var(--ink);
  color: rgba(255,255,255,0.7);
  padding: 32px 32px 24px;
  margin-top: 40px;
  font-size: 13px;
  line-height: 1.6;
}
.footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
.footer-inner h4 {
  color: #fff;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 8px;
}
.footer-inner p { margin: 0 0 4px; }
.footer-social a { color: var(--brand-primary); text-decoration: none; }
.footer-social a:hover { text-decoration: underline; }
.footer-copy {
  grid-column: 1 / -1;
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-top: 16px;
  margin-top: 8px;
  font-size: 12px;
  text-align: center;
}

/* ─── LOADING OVERLAY ──────────────────────────────────────────── */
.loading-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(26,26,26,0.75);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.loading-overlay.active {
  opacity: 1;
  pointer-events: all;
}
.loading-box {
  background: #fff;
  border-radius: 12px;
  padding: 40px 48px 32px;
  text-align: center;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 16px 48px rgba(0,0,0,0.3);
}
.loading-box .lead {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 6px;
}
.loading-box .sub {
  font-size: 13px;
  color: var(--ink-soft);
  margin: 0 0 28px;
}
.progress-track {
  width: 100%;
  height: 10px;
  background: var(--bg-muted);
  border-radius: 5px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--brand-primary), var(--accent));
  border-radius: 5px;
  animation: progressIndeterminate 2s ease-in-out infinite;
}
@keyframes progressIndeterminate {
  0%   { width: 0%; margin-left: 0; }
  50%  { width: 70%; margin-left: 0; }
  100% { width: 0%; margin-left: 100%; }
}
.loading-box .sync-steps {
  margin-top: 20px;
  font-size: 12px;
  color: var(--ink-soft);
  text-align: left;
}
.loading-box .sync-steps div {
  padding: 4px 0;
  opacity: 0.5;
}
.loading-box .sync-steps div.active {
  opacity: 1;
  color: var(--brand-primary);
  font-weight: 500;
}

/* ─── ADMIN LOGIN BADGE ────────────────────────────────────────── */
.admin-login-badge {
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--ink);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
}

/* ─── CLIENT STATS ─────────────────────────────────────────────── */
.client-stats {
  font-size: 13px;
  color: var(--ink-soft);
  margin-bottom: 24px;
  padding: 16px 20px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.client-stats strong { color: var(--ink); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .spinner { animation: none; }
}
