/* ============================================================
   Vanelli Matrice — Mobile-first CSS
   ============================================================ */

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue:      #1F3864;
  --blue-mid:  #2E5DA3;
  --blue-light:#EBF0F8;
  --green:     #00B050;
  --yellow:    #FFD966;
  --red:       #C00000;
  --gray-50:   #F8F9FA;
  --gray-100:  #EEF2F7;
  --gray-200:  #DEE2E6;
  --gray-400:  #ADB5BD;
  --gray-600:  #5f6878;   /* text secundar — contrast AA pe alb */
  --gray-700:  #495057;
  --gray-900:  #212529;
  --white:     #FFFFFF;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.12);
  --shadow:    0 2px 8px rgba(0,0,0,.16);
  --shadow-lg: 0 4px 20px rgba(0,0,0,.20);
  --radius:    10px;
  --radius-sm: 6px;

  /* campanii */
  --camp-blue:   #B3E5FC;
  --camp-green:  #B9F6CA;
  --camp-yellow: #FFF9C4;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Login ────────────────────────────────────────────────── */
.login-body {
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-mid) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}

.login-container {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 400px;
}

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

.login-logo-icon {
  width: 72px;
  height: 72px;
  background: var(--blue);
  color: var(--white);
  font-size: 2.2rem;
  font-weight: 700;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 0.75rem;
}

.login-logo h1 { font-size: 1.8rem; color: var(--blue); }
.login-logo p  { color: var(--gray-400); font-size: 0.9rem; margin-top: .2rem; }

/* ── Forms ────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }
.form-group label {
  display: block;
  font-weight: 600;
  font-size: 0.875rem;
  margin-bottom: .4rem;
  color: var(--gray-700);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select, textarea {
  width: 100%;
  padding: .7rem .9rem;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  color: var(--gray-900);
  background: var(--white);
  transition: border-color .15s;
  -webkit-appearance: none;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--blue-mid);
  box-shadow: 0 0 0 3px rgba(46,93,163,.15);
}

.input-password-wrap { position: relative; }
.input-password-wrap input { padding-right: 3rem; }
.btn-show-pass {
  position: absolute;
  right: .7rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0;
  line-height: 1;
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .65rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all .15s;
  text-decoration: none;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.btn-primary  { background: var(--blue); color: var(--white); }
.btn-primary:hover:not(:disabled) { background: var(--blue-mid); }

.btn-success  { background: var(--green); color: var(--white); }
.btn-success:hover:not(:disabled) { background: #008c40; }

.btn-danger   { background: var(--red); color: var(--white); }
.btn-danger:hover:not(:disabled) { background: #9c0000; }

.btn-outline  { background: var(--white); color: var(--blue); border: 2px solid var(--blue); }
.btn-outline:hover:not(:disabled) { background: var(--blue-light); }

.btn-ghost    { background: transparent; color: var(--gray-700); }
.btn-ghost:hover:not(:disabled) { background: var(--gray-100); }

.btn-sm  { padding: .4rem .85rem; font-size: .85rem; }
.btn-full { width: 100%; }
.btn-icon { padding: .5rem; }

/* ── Alerts ───────────────────────────────────────────────── */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  margin-bottom: 1rem;
}
.alert-error   { background: #FDECEA; color: #C62828; border-left: 4px solid #C62828; }
.alert-success { background: #E8F5E9; color: #2E7D32; border-left: 4px solid #2E7D32; }
.alert-info    { background: var(--blue-light); color: var(--blue); border-left: 4px solid var(--blue); }
.alert-warn    { background: #FFF8E1; color: #F57F17; border-left: 4px solid #F9A825; }

/* ── App Layout ───────────────────────────────────────────── */
.app-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Top Bar ──────────────────────────────────────────────── */
.topbar {
  background: var(--blue);
  color: var(--white);
  padding: 0 1rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.topbar-brand {
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: .5px;
}

.topbar-actions { display: flex; gap: .4rem; align-items: center; }
.topbar-user { font-size: .85rem; opacity: .85; }

/* ── Bottom Nav (mobile) ──────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--white);
  border-top: 1px solid var(--gray-200);
  display: flex;
  z-index: 100;
  box-shadow: 0 -2px 10px rgba(0,0,0,.1);
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: .5rem .25rem;
  color: var(--gray-400);
  font-size: .7rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  border: none;
  background: none;
  -webkit-tap-highlight-color: transparent;
  transition: color .15s;
}

.bottom-nav-item.active { color: var(--blue); }
.bottom-nav-item .nav-icon { font-size: 1.4rem; margin-bottom: 2px; }

/* ── Main content ─────────────────────────────────────────── */
.main-content {
  flex: 1;
  padding: 1rem;
  padding-bottom: 80px; /* space for bottom nav */
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

.page { display: none; }
.page.active { display: block; }

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header {
  padding: .9rem 1rem;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title { font-weight: 700; font-size: 1rem; color: var(--blue); }
.card-body { padding: 1rem; }

/* ── Summary Panel ────────────────────────────────────────── */
.summary-panel {
  background: var(--blue);
  color: var(--white);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: .6rem .4rem;

  /* sticky sub topbar */
  position: sticky;
  top: 61px;          /* 56px topbar + 5px spatiu */
  z-index: 50;
  box-shadow: 0 4px 12px rgba(31,56,100,.35);
}

.summary-item {}
.summary-label { font-size: .72rem; opacity: .8; text-transform: uppercase; letter-spacing: .5px; }
.summary-value { font-size: 1.1rem; font-weight: 700; }
.summary-value.highlight { color: var(--yellow); }

.summary-full { grid-column: 1 / -1; }

/* ── Discount Progress ────────────────────────────────────── */
.discount-bar-wrap { margin-top: .4rem; }
.discount-bar-bg {
  background: rgba(255,255,255,.25);
  border-radius: 99px;
  height: 8px;
  overflow: hidden;
}
.discount-bar-fill {
  height: 100%;
  background: #FFFFFF;
  border-radius: 99px;
  transition: width .4s ease, background .4s ease;
}

/* ── Client selector ──────────────────────────────────────── */
.client-row {
  display: flex;
  gap: .6rem;
  align-items: flex-end;
  margin-bottom: 1rem;
}
.client-row .form-group { flex: 1; margin: 0; }

/* ── Autocomplete dropdown ───────────────────────────────── */
.autocomplete-dropdown {
  display: none;
  position: absolute;
  left: 0; right: 0;
  top: 100%;
  z-index: 100;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  box-shadow: var(--shadow);
  max-height: 220px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.autocomplete-dropdown.open { display: block; }
.autocomplete-item {
  padding: .55rem .75rem;
  font-size: .9rem;
  cursor: pointer;
  border-bottom: 1px solid var(--gray-100);
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover,
.autocomplete-item.active {
  background: var(--blue-light);
  color: var(--blue);
}
.autocomplete-item .ac-agent {
  font-size: .72rem;
  color: var(--gray-600);
  margin-left: .4rem;
}

/* ── Search bar ───────────────────────────────────────────── */
.search-wrap {
  position: relative;
  margin-bottom: .75rem;
}
.search-wrap input {
  padding-left: 2.5rem;
}
.search-icon {
  position: absolute;
  left: .8rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
  pointer-events: none;
}

/* ── Category filter ──────────────────────────────────────── */
.category-tabs {
  display: flex;
  gap: .4rem;
  overflow-x: auto;
  padding-bottom: .3rem;
  margin-bottom: .75rem;
  scrollbar-width: none;
}
.category-tabs::-webkit-scrollbar { display: none; }

.cat-tab {
  flex-shrink: 0;
  padding: .35rem .8rem;
  border-radius: 99px;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid var(--gray-200);
  background: var(--white);
  color: var(--gray-700);
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.cat-tab.active {
  background: var(--blue);
  color: var(--white);
  border-color: var(--blue);
}

/* ── Campaign legend / filter ─────────────────────────────── */
.legend {
  display: flex;
  gap: .4rem;
  flex-wrap: wrap;
  margin-bottom: .75rem;
  font-size: .78rem;
  align-items: center;
}
.legend-filter {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .3rem .7rem;
  border-radius: 99px;
  border: 1.5px solid var(--gray-200);
  background: var(--white);
  color: var(--gray-700);
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s;
  -webkit-tap-highlight-color: transparent;
}
.legend-filter:hover { border-color: var(--gray-400); background: var(--gray-50); }
.legend-filter.active { border-color: var(--blue); background: var(--blue-light); color: var(--blue); }
.legend-filter.active-blue   { border-color: #29B6F6; background: var(--camp-blue);   color: #0277BD; }
.legend-filter.active-green  { border-color: var(--green); background: var(--camp-green); color: #1B5E20; }
.legend-filter.active-yellow { border-color: #F9A825; background: var(--camp-yellow); color: #795548; }

.legend-dot {
  width: 11px; height: 11px;
  border-radius: 3px;
  border: 1px solid rgba(0,0,0,.12);
  flex-shrink: 0;
}
.legend-dot.blue   { background: var(--camp-blue); }
.legend-dot.green  { background: var(--camp-green); }
.legend-dot.yellow { background: var(--camp-yellow); }

/* ── Product list ─────────────────────────────────────────── */
.product-list { display: flex; flex-direction: column; gap: .5rem; }

.product-card {
  background: var(--white);
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--gray-200);
  padding: .75rem;
  transition: border-color .15s;
}

.product-card.has-qty   { border-color: var(--blue-mid); background: var(--blue-light); }
.product-card.camp-blue   { border-left: 4px solid #29B6F6; }
.product-card.camp-green  { border-left: 4px solid var(--green); }
.product-card.camp-yellow { border-left: 4px solid #F9A825; }

.product-name {
  font-weight: 600;
  font-size: .95rem;
  margin-bottom: .25rem;
  color: var(--gray-900);
}

.product-info-row {
  display: flex;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .6rem;
}
.product-meta-left {
  display: flex;
  flex-direction: column;
  gap: .15rem;
  font-size: .78rem;
  color: var(--gray-600);
  flex: 1;
  min-width: 0;
}
.product-meta-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: .15rem;
  flex-shrink: 0;
}
.product-meta-right .price-main {
  font-weight: 700;
  color: var(--blue);
  font-size: 1.35rem;
}
.product-meta-right .price-vat {
  font-size: .78rem;
  color: var(--gray-600);
  font-weight: 400;
}
.product-meta-right .meta-detail {
  font-size: .78rem;
  color: var(--gray-600);
}
.product-meta-right .meta-detail b {
  color: var(--gray-900);
}

.product-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem .75rem;
  font-size: .78rem;
  color: var(--gray-600);
  margin-bottom: .6rem;
}

.product-badge {
  display: inline-block;
  padding: .1rem .45rem;
  border-radius: 99px;
  font-size: .72rem;
  font-weight: 600;
  background: var(--gray-100);
  color: var(--gray-700);
}
.product-badge.camp-blue   { background: var(--camp-blue);   color: #0277BD; }
.product-badge.camp-green  { background: var(--camp-green);  color: #1B5E20; }
.product-badge.camp-yellow { background: var(--camp-yellow); color: #795548; }

.product-price {
  font-weight: 700;
  color: var(--blue);
  font-size: .95rem;
}
.product-price-vat { font-size: .8rem; color: var(--gray-600); font-weight: 400; }

.product-qty-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: .4rem;
  margin-top: .5rem;
  align-items: end;
}

.qty-group { }
.qty-label { font-size: .7rem; color: var(--gray-600); margin-bottom: .2rem; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.qty-input {
  width: 100%;
  padding: .45rem .5rem;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
  color: var(--gray-900);
  background: var(--white);
}
.qty-input:focus { border-color: var(--blue-mid); outline: none; }
.qty-input.suggested {
  background: var(--gray-100);
  color: var(--gray-700);
}
.qty-bonus-agreed {
  border-color: var(--green);
  color: var(--green);
}

/* ── Simulari salvate ─────────────────────────────────────── */
.sim-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1rem;
  margin-bottom: .75rem;
  border-left: 4px solid var(--blue);
}

.sim-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: .5rem;
}
.sim-client { font-weight: 700; font-size: 1rem; }
.sim-date   { font-size: .78rem; color: var(--gray-600); }
.sim-agent  { font-size: .82rem; color: var(--gray-700); margin-bottom: .4rem; }

.sim-totals {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: .3rem;
  font-size: .82rem;
}
.sim-total-item { }
.sim-total-label { color: var(--gray-600); font-size: .72rem; }
.sim-total-value { font-weight: 700; color: var(--blue); }

.sim-actions { display: flex; gap: .4rem; margin-top: .75rem; flex-wrap: wrap; }

/* ── Admin ────────────────────────────────────────────────── */
.admin-section { margin-bottom: 1.5rem; }
.admin-section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--blue);
  margin-bottom: .75rem;
  padding-bottom: .4rem;
  border-bottom: 2px solid var(--blue-light);
}

.user-card {
  background: var(--white);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  padding: .85rem 1rem;
  margin-bottom: .5rem;
  display: flex;
  align-items: center;
  gap: .75rem;
}

.user-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--blue);
  color: var(--white);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
}
.user-avatar.admin-avatar { background: var(--red); }

.user-info { flex: 1; min-width: 0; }
.user-name { font-weight: 600; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-email { font-size: .78rem; color: var(--gray-400); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.badge {
  display: inline-block;
  padding: .15rem .55rem;
  border-radius: 99px;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
}
.badge-admin   { background: #FDECEA; color: var(--red); }
.badge-agent   { background: var(--blue-light); color: var(--blue); }
.badge-inactive { background: var(--gray-100); color: var(--gray-400); }

/* ── Modal ────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--white);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 1.5rem 1.25rem;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp .25s ease;
}

@media (min-width: 600px) {
  .modal-overlay { align-items: center; }
  .modal { border-radius: var(--radius); max-height: 85vh; }
}

@keyframes slideUp {
  from { transform: translateY(60px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--blue);
  margin-bottom: 1rem;
}
.modal-footer {
  display: flex;
  gap: .5rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}

/* ── Spinner ──────────────────────────────────────────────── */
.spinner {
  width: 36px; height: 36px;
  border: 4px solid var(--gray-200);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 2rem auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,.7);
  z-index: 300;
  align-items: center;
  justify-content: center;
}
.loading-overlay.show { display: flex; }

/* ── Toast ────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 70px;
  right: 1rem;
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: .4rem;
  max-width: 320px;
}
.toast {
  padding: .75rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--gray-900);
  color: var(--white);
  font-size: .88rem;
  box-shadow: var(--shadow);
  animation: fadeIn .2s ease;
}
.toast.success { background: var(--green); }
.toast.error   { background: var(--red); }
.toast.info    { background: var(--blue-mid); }
@keyframes fadeIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* ── Empty state ──────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--gray-400);
}
.empty-state-icon { font-size: 3rem; margin-bottom: .75rem; }
.empty-state p { font-size: .95rem; }

/* ── Utility ──────────────────────────────────────────────── */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--gray-600); font-size: .85rem; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.d-flex { display: flex; }
.gap-1  { gap: .5rem; }
.gap-2  { gap: 1rem; }
.flex-1 { flex: 1; }
.fw-bold { font-weight: 700; }

/* ── Campaign tooltip (click-based, mobile-friendly) ─────── */
.camp-popover-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 190;
}
.camp-popover-overlay.open { display: block; }

.camp-popover {
  display: none;
  position: fixed;
  z-index: 191;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 1rem 1.1rem;
  max-width: 280px;
  width: max-content;
  border-top: 4px solid var(--blue);
}
.camp-popover.open { display: block; }
.camp-popover.color-blue   { border-top-color: #29B6F6; }
.camp-popover.color-green  { border-top-color: var(--green); }
.camp-popover.color-yellow { border-top-color: #F9A825; }

.camp-popover-name {
  font-weight: 700;
  font-size: .95rem;
  color: var(--gray-900);
  margin-bottom: .35rem;
}
.camp-popover-desc {
  font-size: .85rem;
  color: var(--gray-600);
  line-height: 1.5;
}
.camp-popover-close {
  position: absolute;
  top: .5rem;
  right: .6rem;
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--gray-400);
  line-height: 1;
  padding: .1rem .2rem;
}
.camp-popover-close:hover { color: var(--gray-900); }

/* badge-ul de campanie pe produs — cursor pointer */
.product-badge[data-camp] { cursor: pointer; }
.product-badge[data-camp]:hover { filter: brightness(.93); }

/* ── Responsive tablet ────────────────────────────────────── */
@media (min-width: 600px) {
  .summary-panel { grid-template-columns: repeat(3, 1fr); }
  .product-qty-row { grid-template-columns: repeat(3, auto); }
  .main-content { padding: 1.25rem; }
}

@media (min-width: 900px) {
  .bottom-nav { display: none; }
  .main-content { padding-bottom: 1.5rem; }
}
