/* ============================================================
   Invoice Factoring Platform — Stile globale
   Palette: blu navy professionale + accenti oro
   ============================================================ */

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

:root {
  --navy:       #0f1e3d;
  --navy-mid:   #1a2f5a;
  --navy-light: #243d72;
  --gold:       #c9a227;
  --gold-light: #e8c060;
  --white:      #ffffff;
  --gray-50:    #f8f9fb;
  --gray-100:   #eef0f4;
  --gray-200:   #dde1e9;
  --gray-400:   #9aa3b2;
  --gray-600:   #5a6478;
  --gray-800:   #2c3347;
  --success:    #1a7f4b;
  --success-bg: #e6f7ef;
  --danger:     #c0392b;
  --danger-bg:  #fdf0ee;
  --warning:    #b7791f;
  --warning-bg: #fef7e6;
  --info:       #1565c0;
  --info-bg:    #e3eefe;

  --sidebar-w:  260px;
  --radius:     8px;
  --shadow-sm:  0 1px 3px rgba(0,0,0,.08);
  --shadow:     0 4px 16px rgba(0,0,0,.10);
  --shadow-lg:  0 8px 32px rgba(0,0,0,.14);
  --transition: .2s ease;
  --font:       'Inter', system-ui, sans-serif;
  --font-mono:  'DM Mono', monospace;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body { font-family: var(--font); background: var(--gray-50); color: var(--gray-800); line-height: 1.6; }
a { color: var(--navy-light); text-decoration: none; }
a:hover { color: var(--gold); }
img { max-width: 100%; }

/* ── Layout ── */
body.has-sidebar { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--navy);
  color: var(--white);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 24px 20px 20px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--gold);
  border-bottom: 1px solid rgba(255,255,255,.08);
  line-height: 1.4;
}

.sidebar-brand span { display: block; color: rgba(255,255,255,.5); font-weight: 400; margin-top: 2px; }

.sidebar-nav { flex: 1; padding: 12px 0; }
.sidebar-section { padding: 16px 20px 6px; font-size: .68rem; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase; color: rgba(255,255,255,.3); }

.sidebar-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 20px;
  color: rgba(255,255,255,.7);
  font-size: .87rem;
  transition: var(--transition);
  border-left: 3px solid transparent;
}
.sidebar-nav a:hover, .sidebar-nav a.active {
  color: var(--white);
  background: rgba(255,255,255,.06);
  border-left-color: var(--gold);
}
.sidebar-nav a svg { flex-shrink: 0; opacity: .8; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: .82rem;
  color: rgba(255,255,255,.5);
}

.content-wrapper {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  padding: 0 32px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.topbar-title { font-size: 1rem; font-weight: 600; color: var(--gray-800); }

.topbar-actions { display: flex; align-items: center; gap: 16px; }

.notif-bell { position: relative; cursor: pointer; color: var(--gray-600); }
.notif-bell .badge {
  position: absolute; top: -4px; right: -4px;
  background: var(--danger); color: #fff;
  font-size: .65rem; font-weight: 700;
  width: 16px; height: 16px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}

.main { padding: 32px; flex: 1; }

/* ── Cards ── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
}
.card-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--gray-100);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card-title { font-size: 1rem; font-weight: 600; color: var(--gray-800); }
.card-body { padding: 24px; }

/* ── Stat cards ── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.stat-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--gray-400); font-weight: 600; }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--navy); line-height: 1.2; margin-top: 4px; }
.stat-sub { font-size: .8rem; color: var(--gray-400); margin-top: 2px; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
thead th {
  background: var(--gray-50);
  padding: 10px 14px;
  text-align: left;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--gray-600);
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--gray-50); }

/* ── Badge status ── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .73rem;
  font-weight: 600;
  letter-spacing: .03em;
  white-space: nowrap;
}
.badge-pending   { background: var(--warning-bg); color: var(--warning); }
.badge-approved  { background: var(--success-bg); color: var(--success); }
.badge-rejected  { background: var(--danger-bg);  color: var(--danger); }
.badge-open      { background: #e8f0fe; color: #1565c0; }
.badge-scheduled { background: #fff8e1; color: #f57f17; }
.badge-closed    { background: var(--gray-100); color: var(--gray-600); }
.badge-awarded   { background: #f3e5f5; color: #6a1b9a; }
.badge-cancelled { background: var(--danger-bg); color: var(--danger); }
.badge-active    { background: var(--success-bg); color: var(--success); }
.badge-outbid    { background: var(--gray-100);   color: var(--gray-600); }
.badge-won       { background: #fff8e1; color: var(--warning); }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius);
  font-size: .88rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  white-space: nowrap;
  text-decoration: none;
}
.btn-primary   { background: var(--navy); color: var(--white); }
.btn-primary:hover { background: var(--navy-light); color: var(--white); }
.btn-gold      { background: var(--gold); color: var(--white); }
.btn-gold:hover { background: var(--gold-light); }
.btn-success   { background: var(--success); color: var(--white); }
.btn-danger    { background: var(--danger); color: var(--white); }
.btn-outline   { background: transparent; border: 1.5px solid var(--gray-200); color: var(--gray-800); }
.btn-outline:hover { border-color: var(--navy); color: var(--navy); }
.btn-sm        { padding: 5px 12px; font-size: .8rem; }
.btn-lg        { padding: 12px 28px; font-size: 1rem; }

/* ── Forms ── */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: .85rem; font-weight: 500; color: var(--gray-800); margin-bottom: 6px; }
.form-label .req { color: var(--danger); }
.form-control, .form-select {
  width: 100%;
  padding: 9px 13px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: .9rem;
  font-family: var(--font);
  color: var(--gray-800);
  background: var(--white);
  transition: border-color var(--transition);
  outline: none;
}
.form-control:focus, .form-select:focus { border-color: var(--navy-light); box-shadow: 0 0 0 3px rgba(26,47,90,.08); }
.form-control.is-invalid { border-color: var(--danger); }
.form-hint { font-size: .78rem; color: var(--gray-400); margin-top: 4px; }
.invalid-feedback { font-size: .78rem; color: var(--danger); margin-top: 4px; }

.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 16px; }
.form-section { margin-bottom: 32px; }
.form-section-title {
  font-size: .78rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--gold);
  border-bottom: 1px solid var(--gray-200);
  padding-bottom: 8px; margin-bottom: 18px;
}

/* Upload zone */
.upload-zone {
  border: 2px dashed var(--gray-200);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  background: var(--gray-50);
}
.upload-zone:hover, .upload-zone.dragover { border-color: var(--navy-light); background: var(--info-bg); }
.upload-zone input[type=file] { display: none; }
.upload-icon { font-size: 2.4rem; margin-bottom: 8px; }
.upload-label { font-size: .9rem; color: var(--gray-600); }
.upload-label strong { color: var(--navy); }
.upload-hint { font-size: .78rem; color: var(--gray-400); margin-top: 4px; }
.upload-preview { margin-top: 12px; font-size: .85rem; color: var(--success); display: none; }

/* ── Alerts ── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: .88rem;
  margin-bottom: 16px;
  border-left: 4px solid;
}
.alert-success { background: var(--success-bg); border-color: var(--success); color: var(--success); }
.alert-error   { background: var(--danger-bg);  border-color: var(--danger);  color: var(--danger); }
.alert-warning { background: var(--warning-bg); border-color: var(--warning); color: var(--warning); }
.alert-info    { background: var(--info-bg);    border-color: var(--info);    color: var(--info); }

/* ── Bid UI ── */
.bid-panel {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
  color: var(--white);
  border-radius: var(--radius);
  padding: 28px;
}
.bid-panel-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 20px; color: var(--gold); }

.bid-current {
  background: rgba(255,255,255,.07);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
}
.bid-current-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: rgba(255,255,255,.5); }
.bid-current-value { font-size: 2.2rem; font-weight: 700; font-family: var(--font-mono); color: var(--gold-light); }
.bid-current-sub   { font-size: .82rem; color: rgba(255,255,255,.5); margin-top: 2px; }

.bid-input-group { display: flex; gap: 10px; align-items: flex-end; }
.bid-input-group .form-control {
  background: rgba(255,255,255,.1);
  border-color: rgba(255,255,255,.2);
  color: var(--white);
  font-size: 1.2rem;
  font-family: var(--font-mono);
  text-align: right;
}
.bid-input-group .form-control::placeholder { color: rgba(255,255,255,.3); }
.bid-input-group .form-control:focus { border-color: var(--gold); }
.bid-suffix { color: rgba(255,255,255,.6); font-size: 1rem; padding-bottom: 9px; }

.bid-status-msg { margin-top: 12px; font-size: .85rem; }
.bid-status-msg.success { color: var(--gold-light); }
.bid-status-msg.error   { color: #ff8a80; }

/* Countdown asta */
.auction-countdown {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--gold-light);
  letter-spacing: .05em;
}
.auction-countdown.danger { color: #ff5252; }

/* Timeline offerte */
.bid-list { max-height: 320px; overflow-y: auto; }
.bid-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--gray-100);
  font-size: .85rem;
  transition: var(--transition);
}
.bid-row:hover { background: var(--gray-50); }
.bid-row.is-mine { background: var(--info-bg); }
.bid-row.is-best { background: var(--success-bg); }
.bid-pct { font-family: var(--font-mono); font-weight: 700; font-size: 1rem; color: var(--navy); }
.bid-who { color: var(--gray-600); }
.bid-time { color: var(--gray-400); font-size: .78rem; }

/* ── Login page ── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 60%, #1e3a8a 100%);
  display: flex; align-items: center; justify-content: center;
}
.login-box {
  background: var(--white);
  border-radius: 16px;
  padding: 48px 44px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo h1 { font-size: 1.3rem; font-weight: 700; color: var(--navy); line-height: 1.3; }
.login-logo p  { font-size: .82rem; color: var(--gray-400); margin-top: 4px; }
.login-box h2  { font-size: 1.4rem; font-weight: 700; color: var(--gray-800); margin-bottom: 24px; }

/* ── Utilities ── */
.text-muted  { color: var(--gray-400); }
.text-sm     { font-size: .82rem; }
.text-mono   { font-family: var(--font-mono); }
.text-right  { text-align: right; }
.text-center { text-align: center; }
.fw-600      { font-weight: 600; }
.fw-700      { font-weight: 700; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.gap-2 { gap: 8px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.w-100 { width: 100%; }
.divider { border: none; border-top: 1px solid var(--gray-200); margin: 24px 0; }
.empty-state { text-align: center; padding: 48px 24px; color: var(--gray-400); }
.empty-state svg { margin-bottom: 12px; opacity: .4; }
.empty-state p { font-size: .9rem; }

/* ── Responsive ── */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .content-wrapper { margin-left: 0; }
  .main { padding: 20px 16px; }
  .form-row { grid-template-columns: 1fr; }
}
