/* ============================================================
   WAVE — Design System
   Rosa & Ronchi S.r.l.
   ============================================================ */

/* --- Tokens ------------------------------------------------ */
:root {
  /* ── Brand palette ── */
  --navy:        #1e3144;   /* sfondo sidebar / header */
  --navy-mid:    #2a4259;   /* hover sidebar */
  --navy-light:  #3d5a73;   /* slate brand / bordi sidebar */
  --accent:      #F0A020;   /* arancione brand */
  --accent-dark: #d4880a;   /* arancione scuro (hover) */
  --accent-gold: #E8C040;   /* oro brand */
  --slate:       #3D5A73;   /* blu slate logo */
  --bg:          #f2f4f7;
  --surface:     #ffffff;
  --border:      #dde4ed;
  --border-light:#f0f4f8;
  --text:        #1a2e44;
  --text-mid:    #445566;
  --text-muted:  #889aaa;
  --green:       #0b7a50;
  --green-bg:    #e6f7f0;
  --orange:      #b85c00;
  --orange-bg:   #fff3e0;
  --red:         #c0392b;
  --red-bg:      #fdecea;

  --radius-sm:   8px;
  --radius-md:   12px;
  --radius-lg:   16px;
  --radius-xl:   24px;

  --shadow-sm:   0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:   0 4px 12px rgba(0,0,0,.08);

  --font: 'Outfit', system-ui, sans-serif;
  --transition: .18s ease;
}

/* --- Reset ------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { overflow-x: hidden; }
html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  width: 100%;
}
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  position: relative;
  width: 100%;
  line-height: 1.5;
  min-height: 100vh;
}
a { color: var(--accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { display: block; }
button, input, select, textarea { font-family: var(--font); font-size: 1rem; }

/* --- Typography -------------------------------------------- */
h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -.5px; line-height: 1.2; }
h2 { font-size: 1.25rem; font-weight: 600; letter-spacing: -.3px; }
h3 { font-size: 1rem;    font-weight: 600; }
.text-sm   { font-size: .875rem; }
.text-xs   { font-size: .75rem;  }
.text-muted { color: var(--text-muted); }
.text-mid   { color: var(--text-mid); }
.font-semibold { font-weight: 600; }
.font-medium   { font-weight: 500; }

/* --- Layout ------------------------------------------------ */
.container { width: 100%; max-width: 1100px; margin: 0 auto; padding: 0 20px; }

/* App shell — sidebar + main */
.app-shell {
  display: flex;
  min-height: 100vh;
  min-width: 0;
  overflow-x: hidden;
}

/* --- Sidebar ---------------------------------------------- */
.sidebar {
  width: 240px;
  background: var(--navy);
  display: flex;
  flex-direction: column;
  padding: 20px 12px;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 20px;
  border-bottom: 1px solid var(--navy-light);
  margin-bottom: 16px;
}
.sidebar-logo-text { font-size: 1.4rem; font-weight: 700; color: #fff; letter-spacing: -.5px; }
.sidebar-logo-sub  { font-size: .65rem; color: #5e90b8; }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: #7aa3c0;
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: none;
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
  width: 100%;
  text-align: left;
}
.nav-item:hover { background: var(--navy-mid); color: #c8dcee; text-decoration: none; }
.nav-item.active { background: var(--navy-mid); color: #fff; }
.nav-item svg { flex-shrink: 0; }
.nav-divider { height: 1px; background: var(--navy-light); margin: 8px 4px; }
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 10px 0;
  border-top: 1px solid var(--navy-light);
  margin-top: auto;
}
.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; font-size: .8rem;
  flex-shrink: 0;
}
.avatar-lg { width: 44px; height: 44px; font-size: 1rem; }

/* --- Main content ----------------------------------------- */
.main-content {
  flex: 1;
  margin-left: 240px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
  overflow-x: hidden;
}
.page-header {
  background: var(--surface);
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.page-body { padding: 28px; flex: 1; min-width: 0; overflow-x: hidden; }

/* --- Cards ------------------------------------------------- */
.card {
  background: var(--surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  padding: 20px;
}
.card-sm { padding: 14px 16px; }
.card-flush { padding: 0; overflow: hidden; }
.card + .card { margin-top: 16px; }
.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-light);
  font-size: .875rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* --- Buttons ---------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  border: none;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--slate); color: #fff; }
.btn-primary:hover { background: #2e4a61; color: #fff; text-decoration: none; }
.btn-accent  { background: var(--accent); color: #fff; }
.btn-accent:hover  { background: var(--accent-dark); color: #fff; text-decoration: none; }
.btn-outline {
  background: none;
  color: var(--slate);
  border: 1.5px solid var(--slate);
}
.btn-outline:hover { background: #eef2f7; text-decoration: none; }
.btn-ghost  { background: none; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.btn-danger { background: var(--red); color: #fff; }
.btn-sm  { padding: 7px 14px; font-size: .8rem; }
.btn-lg  { padding: 14px 28px; font-size: 1rem; }
.btn-full { width: 100%; }

/* --- Form elements ---------------------------------------- */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.form-control {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .9375rem;
  background: #f8fafc;
  color: var(--text);
  outline: none;
  transition: border-color var(--transition), background var(--transition);
  -webkit-appearance: none;
}
.form-control:focus { border-color: var(--accent-dark); background: var(--surface); }
.form-control::placeholder { color: #aabbcc; }
.form-hint { font-size: .75rem; color: var(--text-muted); margin-top: 4px; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* --- Tables ----------------------------------------------- */
.table-wrap { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
.table th {
  font-size: .7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .8px;
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1.5px solid var(--border);
  background: #f8fafc;
  white-space: nowrap;
}
.table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: #fafcfe; }
.table-clickable tbody tr { cursor: pointer; }

/* --- Badges ----------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .7rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-green  { background: var(--green-bg);  color: var(--green); }
.badge-orange { background: var(--orange-bg); color: var(--orange); }
.badge-blue   { background: #e6f0fb;          color: var(--accent-dark); }
.badge-red    { background: var(--red-bg);    color: var(--red); }

/* --- Stats cards ------------------------------------------ */
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 24px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
}
.stat-label { font-size: .7rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .6px; margin-bottom: 6px; }
.stat-value { font-size: 1.75rem; font-weight: 700; color: var(--text); line-height: 1; }
.stat-value.orange { color: var(--orange); }
.stat-value.green  { color: var(--green); }

/* --- Product cards grid ----------------------------------- */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}
.product-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 12px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), transform var(--transition);
  text-decoration: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.product-card:hover { border-color: var(--accent-dark); background: #f0f6ff; transform: translateY(-1px); }
.product-card svg { color: var(--accent-dark); }
.product-card-name { font-size: .8rem; font-weight: 600; color: var(--text); line-height: 1.3; }

/* --- Radio options ---------------------------------------- */
.radio-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: #f8fafc;
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: 8px;
  font-size: .9rem;
  color: var(--text);
}
.radio-option:hover  { border-color: var(--accent-dark); }
.radio-option.active { border-color: var(--accent-dark); background: #f0f6ff; font-weight: 500; }
.radio-dot {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: border-color var(--transition);
}
.radio-option.active .radio-dot { border-color: var(--accent-dark); }
.radio-dot::after {
  content: '';
  width: 8px; height: 8px;
  border-radius: 50%;
  background: transparent;
  transition: background var(--transition);
}
.radio-option.active .radio-dot::after { background: var(--accent-dark); }

/* --- Split layout ----------------------------------------- */
.split-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  align-items: start;
}
.sticky-panel { position: sticky; top: 80px; }

/* --- Info box --------------------------------------------- */
.info-box {
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-size: .875rem;
  line-height: 1.6;
}
.info-box-blue   { background: #eef6fb; border: 1px solid #b8d4f0; color: #1a3a6a; }
.info-box-orange { background: var(--orange-bg); border: 1px solid #f5d49a; color: #7a4a00; }
.info-box-green  { background: var(--green-bg);  border: 1px solid #9fdbc5; color: #0a5a3c; }

/* --- Mobile bottom nav ------------------------------------ */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 200;
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav-inner { display: flex; height: 60px; }
.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: .65rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  text-decoration: none;
}
.bottom-nav-item.active { color: var(--accent-dark); }

/* --- Mobile header ---------------------------------------- */
.mobile-header {
  display: none;
  background: var(--navy);
  padding: 14px 18px 20px;
  flex-shrink: 0;
}
.mobile-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.progress-bar { height: 3px; background: var(--navy-mid); border-radius: 2px; margin-top: 12px; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width .3s ease; }

/* --- Back button ------------------------------------------ */
.btn-back {
  background: none;
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text-muted);
  font-size: .875rem;
  cursor: pointer;
  padding: 0;
  font-family: var(--font);
  font-weight: 500;
}
.btn-back:hover { color: var(--text); }
.btn-back-white { color: rgba(255,255,255,.7); }
.btn-back-white:hover { color: #fff; }

/* --- Utils ------------------------------------------------ */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.p-0  { padding: 0; }
.w-full { width: 100%; }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.truncate { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* --- Success / empty states ------------------------------- */
.success-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  flex: 1;
}
.success-icon {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: var(--green-bg);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 20px;
}
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}
.empty-state svg { margin: 0 auto 14px; opacity: .35; }

/* --- Order summary row ------------------------------------ */
.order-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 0;
  border-bottom: 1px solid var(--border-light);
}
.order-row:last-child { border-bottom: none; }
.order-row-label  { font-size: .75rem; color: var(--text-muted); margin-bottom: 2px; }
.order-row-value  { font-size: .9rem; font-weight: 500; color: var(--text); }
.order-row-qty    { font-size: .8rem; font-weight: 600; color: var(--accent-dark); }

/* --- Login page ------------------------------------------- */
.login-page {
  min-height: 100vh;
  display: flex;
  background: var(--navy);
}
.login-left {
  width: 420px;
  flex-shrink: 0;
  background: var(--navy);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 40px;
}
.login-right {
  flex: 1;
  background: linear-gradient(135deg, #0a1c2e 0%, #0d2137 40%, #0e3055 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.login-box {
  width: 100%;
  max-width: 360px;
}
.login-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 40px;
}
.login-logo-text { font-size: 2rem; font-weight: 700; color: #fff; letter-spacing: -1px; }
.login-logo-sub  { font-size: .7rem; color: #5e90b8; margin-top: 1px; }
.login-title { font-size: 1.5rem; font-weight: 700; color: #fff; margin-bottom: 6px; }
.login-sub   { font-size: .875rem; color: #7aa3c0; margin-bottom: 32px; }
.login-label {
  display: block;
  font-size: .7rem;
  font-weight: 700;
  color: #5e90b8;
  text-transform: uppercase;
  letter-spacing: .6px;
  margin-bottom: 6px;
}
.login-input {
  width: 100%;
  padding: 12px 14px;
  background: var(--navy-mid);
  border: 1.5px solid var(--navy-light);
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: .9375rem;
  font-family: var(--font);
  outline: none;
  transition: border-color var(--transition);
}
.login-input:focus { border-color: var(--accent); }
.login-input::placeholder { color: #3d6080; }
.login-alert {
  background: rgba(192,57,43,.15);
  border: 1px solid rgba(192,57,43,.4);
  color: #f1948a;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: .875rem;
  margin-bottom: 20px;
}
.login-alert-ok {
  background: rgba(11,122,80,.15);
  border: 1px solid rgba(11,122,80,.4);
  color: #58d68d;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: .875rem;
  margin-bottom: 20px;
}
.login-deco {
  position: absolute;
  pointer-events: none;
}

/* --- Hamburger (mobile) ----------------------------------- */
.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  padding: 4px;
  background: none;
  border: none;
}
.hamburger span {
  display: block;
  width: 22px; height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: all .2s ease;
}

/* --- Overlay (mobile sidebar) ----------------------------- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 99;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 900px) {
  /* Show hamburger, hide sidebar by default */
  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-md);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-overlay.open { display: block; }
  .hamburger { display: flex; }

  .main-content { margin-left: 0; }
  .page-header  { padding: 12px 16px; }
  .page-body    { padding: 12px 8px; }

  /* Show mobile header instead of sidebar header */
  .mobile-header { display: block; }

  /* Bottom nav */
  .bottom-nav { display: block; }
  .main-content { padding-bottom: 70px; }

  /* Hide desktop elements */
  .desktop-only { display: none !important; }

  /* Responsive grids */
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .split-layout { grid-template-columns: 1fr; }
  .form-grid-3 { grid-template-columns: 1fr 1fr; }

  /* Login page */
  .login-right { display: none; }
  .login-left  { width: 100%; padding: 40px 24px; }
}

@media (max-width: 480px) {
  .stats-grid  { grid-template-columns: 1fr; }
  .form-grid-2 { grid-template-columns: 1fr; }
  .product-grid { grid-template-columns: repeat(2, 1fr); }
  h1 { font-size: 1.4rem; }
}

/* --- Animations ------------------------------------------- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeIn .25s ease forwards; }

@keyframes spin {
  to { transform: rotate(360deg); }
}
.spinner {
  width: 20px; height: 20px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
