/* =====================================================================
   Piese Auto — style.css
   Tokenuri de design (LIGHT MODE), reset, tipografie, layout de bază și componente
   fundamentale (butoane, formulare, badge-uri, toast, breadcrumbs, paginare).
   Mobile-first. Media queries suplimentare: responsive.css.
   NU redefiniți tokenurile în alte fișiere.
   ===================================================================== */


:root {
  /* LIGHT MODE — direcție: eMAG (comercial, clar) + Apple (alb, aerisit, rafinat).
     Paleta verde din brief e păstrată ca accent de brand. */
  --bg:            #FFFFFF;          /* fundal pagină */
  --bg-2:          #F5F5F7;          /* secțiuni alternative, inputuri, zone gri (gri Apple) */
  --card:          #FFFFFF;          /* carduri */
  --card-hover:    #FAFAFB;
  --green:         #426B4D;          /* CTA principal, stări active */
  --green-2:       #365A40;          /* hover CTA */
  --green-pale:    #2F5D3B;          /* text/link accentuat (verde lizibil pe alb) */
  --green-tint:    #EDF3EE;          /* fundal accent discret (selecții, badge-uri) */
  --green-line:    #A2B8A3;          /* linii/contururi decorative verzi */
  --on-accent:     #FFFFFF;          /* text pe fundal verde */
  --text:          #1D1D1F;          /* text principal */
  --text-2:        #5E6360;          /* text secundar */
  --text-3:        #8B908C;          /* meta, placeholder */
  --border:        rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.16);
  --success:       #2F8A4E;
  --error:         #C7433A;
  --warning:       #A86A12;
  --success-tint:  #EAF5EE;
  --error-tint:    #FCEDEC;
  --warning-tint:  #FBF3E6;
  --overlay:       rgba(0, 0, 0, 0.4);

  /* Tipografie: fontul de sistem (SF Pro pe Apple, Segoe UI pe Windows, Roboto pe Android) */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --fs-xs:   0.75rem;   /* 12 */
  --fs-sm:   0.875rem;  /* 14 */
  --fs-base: 1rem;      /* 16 */
  --fs-md:   1.125rem;  /* 18 */
  --fs-lg:   1.375rem;  /* 22 */
  --fs-xl:   1.75rem;   /* 28 */
  --fs-2xl:  2.25rem;   /* 36 */
  --fs-3xl:  clamp(2.25rem, 1.4rem + 3.6vw, 4rem); /* titluri hero */
  --tracking-tight: -0.022em;   /* titluri mari, stil Apple */

  /* Spațiere (scală de 4px) */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px; --s-5: 20px;
  --s-6: 24px; --s-8: 32px; --s-10: 40px; --s-12: 48px; --s-16: 64px; --s-20: 80px; --s-24: 96px;

  /* Forme */
  --r-sm: 6px;
  --r:    10px;
  --r-lg: 16px;
  --r-pill: 999px;

  --shadow:    0 1px 2px rgba(0,0,0,.04), 0 4px 14px rgba(0,0,0,.06);
  --shadow-lg: 0 2px 6px rgba(0,0,0,.06), 0 16px 40px rgba(0,0,0,.12);

  --container: 1320px;
  --gutter: 16px;
  --header-h: 64px;

  --ease: cubic-bezier(.2, .7, .2, 1);
  --t-fast: 140ms;
  --t: 220ms;
}

/* ---------------------------------------------------------------------
   Reset
   --------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1 0 auto; }
img, svg, video { display: block; max-width: 100%; }
img { height: auto; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
p { margin: 0 0 var(--s-4); }
h1, h2, h3, h4 { margin: 0 0 var(--s-4); line-height: 1.15; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: var(--fs-2xl); letter-spacing: var(--tracking-tight); }
h2 { font-size: var(--fs-xl); letter-spacing: var(--tracking-tight); }
h3 { font-size: var(--fs-lg); }
h4 { font-size: var(--fs-md); }
ul, ol { margin: 0; padding: 0; }
table { border-collapse: collapse; width: 100%; }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--s-8) 0; }
::selection { background: var(--green-tint); color: var(--text); }

:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; border-radius: 4px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; scroll-behavior: auto !important; }
}

/* ---------------------------------------------------------------------
   Utilitare
   --------------------------------------------------------------------- */
.container { width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: var(--gutter); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--text-2); }
.small { font-size: var(--fs-sm); }
.text-success { color: var(--success); }
.text-error { color: var(--error); }
.stack > * + * { margin-top: var(--s-4); }
.flex { display: flex; gap: var(--s-3); align-items: center; }
.flex-between { display: flex; gap: var(--s-3); align-items: center; justify-content: space-between; flex-wrap: wrap; }
[hidden] { display: none !important; }

.skip-link { position: absolute; left: var(--s-4); top: -100px; z-index: 1000; background: var(--green); color: var(--on-accent); padding: var(--s-2) var(--s-4); border-radius: var(--r); }
.skip-link:focus { top: var(--s-2); }

/* Secțiuni de pagină */
.section { padding-block: var(--s-12); }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-4); margin-bottom: var(--s-6); flex-wrap: wrap; }
.section-head h2 { margin: 0; }
.section-head .link { color: var(--green-pale); font-size: var(--fs-sm); font-weight: 500; }
.section-head .link:hover { color: var(--text); }
.page-head { padding-block: var(--s-6) var(--s-4); }
.page-head h1 { margin-bottom: var(--s-2); }

/* ---------------------------------------------------------------------
   Butoane
   .btn + .btn-primary | .btn-secondary | .btn-ghost | .btn-danger
   Mărimi: .btn-sm | .btn-lg ; .btn-block = lățime completă ; .btn-icon = pătrat doar cu icon
   Stare încărcare: atributul [aria-busy="true"]
   --------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: 44px; padding: 0 var(--s-5);
  border: 1px solid transparent; border-radius: var(--r);
  font-size: var(--fs-sm); font-weight: 600; line-height: 1; white-space: nowrap;
  background: transparent; color: var(--text);
  transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
  user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; transform: none; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-primary { background: var(--green); color: var(--on-accent); }
.btn-primary:hover { background: var(--green-2); }
.btn-secondary { background: var(--card); border-color: var(--border-strong); color: var(--text); }
.btn-secondary:hover { background: var(--bg-2); border-color: var(--text-3); }
.btn-ghost { color: var(--text-2); }
.btn-ghost:hover { color: var(--text); background: var(--bg-2); }
.btn-danger { background: transparent; border-color: rgba(199,67,58,.4); color: var(--error); }
.btn-danger:hover { background: var(--error-tint); }
.btn-sm { min-height: 36px; padding: 0 var(--s-3); font-size: var(--fs-xs); }
.btn-lg { min-height: 52px; padding: 0 var(--s-6); font-size: var(--fs-base); }
.btn-block { width: 100%; }
.btn-icon { width: 44px; padding: 0; }
.btn-icon.btn-sm { width: 36px; }
.btn[aria-busy="true"] { position: relative; color: transparent !important; pointer-events: none; }
.btn[aria-busy="true"]::after {
  content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; color: inherit; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.link { color: var(--green-pale); text-decoration: underline; text-decoration-color: rgba(47,93,59,.35); text-underline-offset: 3px; }
.link:hover { color: var(--text); text-decoration-color: currentColor; }
.link-button { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }

/* ---------------------------------------------------------------------
   Formulare
   <div class="field">
     <label for="x">Etichetă</label>
     <input id="x" class="input" name="x">
     <p class="field-error" data-error-for="x"></p>     ← main.js completează erorile
   </div>
   .field-row = câmpuri pe două coloane (de la 640px)
   --------------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--s-4); min-width: 0; }
.field label, .label { font-size: var(--fs-sm); font-weight: 500; color: var(--text-2); }
.field .hint { font-size: var(--fs-xs); color: var(--text-3); margin: 0; }
.field-error { font-size: var(--fs-xs); color: var(--error); margin: 0; min-height: 0; }
.field-error:empty { display: none; }
.field-row { display: grid; gap: 0 var(--s-4); grid-template-columns: 1fr; }

.input, .select, .textarea {
  width: 100%; min-height: 46px; padding: 0 var(--s-4);
  background: var(--card); border: 1px solid var(--border-strong); border-radius: var(--r);
  color: var(--text); font-size: var(--fs-base);
  transition: border-color var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease);
}
.textarea { padding: var(--s-3) var(--s-4); min-height: 120px; resize: vertical; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:hover, .select:hover, .textarea:hover { border-color: rgba(0,0,0,.28); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--green); background: var(--card); box-shadow: 0 0 0 3px var(--green-tint); }
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--error); }
.select {
  appearance: none; padding-right: 40px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23A0AAA1' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}
.select:disabled, .input:disabled { opacity: .5; cursor: not-allowed; }
.select option { background: var(--card); color: var(--text); }

/* Checkbox & radio custom */
.check { display: flex; align-items: flex-start; gap: var(--s-3); cursor: pointer; font-size: var(--fs-sm); color: var(--text); line-height: 1.4; }
.check input { appearance: none; flex: none; width: 20px; height: 20px; margin: 0; border: 1.5px solid var(--border-strong); border-radius: 5px; background: var(--card); display: grid; place-content: center; transition: background-color var(--t-fast), border-color var(--t-fast); cursor: pointer; }
.check input[type="radio"] { border-radius: 50%; }
.check input:checked { background: var(--green); border-color: var(--green); }
.check input[type="checkbox"]:checked::after { content: ""; width: 10px; height: 6px; border: 2px solid var(--on-accent); border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); }
.check input[type="radio"]:checked::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--on-accent); }
.check input:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

/* Opțiune selectabilă mare (livrare, plată, tip client) */
.option-card { display: flex; gap: var(--s-3); align-items: flex-start; padding: var(--s-4); border: 1px solid var(--border-strong); border-radius: var(--r); cursor: pointer; transition: border-color var(--t-fast), background-color var(--t-fast); }
.option-card:hover { border-color: rgba(0,0,0,.28); }
.option-card:has(input:checked) { border-color: var(--green); background: var(--green-tint); }
.option-card input { margin-top: 2px; }

/* Selector cantitate: <div class="qty"><button data-qty="-1">−</button><input class="qty-input"><button data-qty="1">+</button></div> */
.qty { display: inline-flex; align-items: stretch; border: 1px solid var(--border-strong); border-radius: var(--r); overflow: hidden; height: 44px; background: var(--card); }
.qty button { width: 40px; border: 0; background: transparent; color: var(--text-2); font-size: 18px; line-height: 1; transition: background-color var(--t-fast), color var(--t-fast); }
.qty button:hover { background: var(--bg-2); color: var(--text); }
.qty button:disabled { opacity: .35; cursor: not-allowed; }
.qty input { width: 48px; border: 0; background: transparent; text-align: center; font-weight: 600; -moz-appearance: textfield; appearance: textfield; }
.qty input::-webkit-outer-spin-button, .qty input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.qty input:focus { outline: none; }

/* ---------------------------------------------------------------------
   Badge-uri, stoc, rating, preț
   --------------------------------------------------------------------- */
.badge { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: var(--r-sm); font-size: var(--fs-xs); font-weight: 600; line-height: 1; background: var(--bg-2); color: var(--text-2); border: 1px solid var(--border); }
.badge-sale { background: var(--green); color: var(--on-accent); border-color: transparent; }
.badge-new { background: var(--green-tint); color: var(--green-pale); border-color: transparent; }
.badge-success { color: var(--success); border-color: transparent; background: var(--success-tint); }
.badge-error { color: var(--error); border-color: transparent; background: var(--error-tint); }
.badge-warning { color: var(--warning); border-color: transparent; background: var(--warning-tint); }

.stock { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); font-weight: 500; }
.stock::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.stock.in-stock { color: var(--success); }
.stock.low-stock { color: var(--warning); }
.stock.out-of-stock { color: var(--error); }

.rating { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); color: var(--text-2); }
.stars { --pct: 0%; position: relative; display: inline-block; width: 76px; height: 14px; background: linear-gradient(90deg, #E8A317 var(--pct), #D9D9DE var(--pct)); -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='76' height='14' viewBox='0 0 76 14'%3E%3Cg fill='%23000'%3E%3Cpath id='s' d='M7 0l2.1 4.5 4.9.6-3.6 3.4.9 4.9L7 11l-4.3 2.4.9-4.9L0 5.1l4.9-.6z'/%3E%3Cuse href='%23s' x='15.5'/%3E%3Cuse href='%23s' x='31'/%3E%3Cuse href='%23s' x='46.5'/%3E%3Cuse href='%23s' x='62'/%3E%3C/g%3E%3C/svg%3E") no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='76' height='14' viewBox='0 0 76 14'%3E%3Cg fill='%23000'%3E%3Cpath id='s' d='M7 0l2.1 4.5 4.9.6-3.6 3.4.9 4.9L7 11l-4.3 2.4.9-4.9L0 5.1l4.9-.6z'/%3E%3Cuse href='%23s' x='15.5'/%3E%3Cuse href='%23s' x='31'/%3E%3Cuse href='%23s' x='46.5'/%3E%3Cuse href='%23s' x='62'/%3E%3C/g%3E%3C/svg%3E") no-repeat; }

.price { display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px var(--s-2); }
.price-current { font-size: var(--fs-md); font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.price-old { font-size: var(--fs-sm); color: var(--text-3); text-decoration: line-through; font-variant-numeric: tabular-nums; }
.price.is-sale .price-current { color: var(--error); }

/* ---------------------------------------------------------------------
   Panouri / carduri generice
   --------------------------------------------------------------------- */
.panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s-6); }
.panel-title { font-size: var(--fs-md); font-weight: 600; margin: 0 0 var(--s-4); }
.panel + .panel { margin-top: var(--s-4); }

/* Notificare inline: <div class="notice notice-success|notice-error|notice-info">...</div> */
.notice { padding: var(--s-3) var(--s-4); border-radius: var(--r); border: 1px solid var(--border-strong); background: var(--bg-2); font-size: var(--fs-sm); color: var(--text); }
.notice-success { border-color: rgba(47,138,78,.3); background: var(--success-tint); }
.notice-error { border-color: rgba(199,67,58,.3); background: var(--error-tint); }
.notice-info { border-color: var(--border-strong); }

/* Stare goală */
.empty-state { text-align: center; padding: var(--s-16) var(--s-4); color: var(--text-2); }
.empty-state svg { width: 48px; height: 48px; margin: 0 auto var(--s-4); color: var(--text-3); }
.empty-state h2, .empty-state h3 { color: var(--text); font-size: var(--fs-lg); margin-bottom: var(--s-2); }
.empty-state p { max-width: 42ch; margin-inline: auto; margin-bottom: var(--s-6); }

/* ---------------------------------------------------------------------
   Breadcrumbs: <nav class="breadcrumbs" aria-label="Breadcrumb"><ol><li><a>..</a></li><li aria-current="page">..</li></ol></nav>
   --------------------------------------------------------------------- */
.breadcrumbs { padding-top: var(--s-5); font-size: var(--fs-xs); color: var(--text-3); }
.breadcrumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.breadcrumbs li { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.breadcrumbs li + li::before { content: ""; width: 5px; height: 5px; border-top: 1.5px solid var(--text-3); border-right: 1.5px solid var(--text-3); transform: rotate(45deg); }
.breadcrumbs a { color: var(--text-2); }
.breadcrumbs a:hover { color: var(--text); }
.breadcrumbs [aria-current] { color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60vw; }

/* ---------------------------------------------------------------------
   Paginare: <nav class="pagination"><a class="page-link">1</a><span class="page-link is-current">2</span>...</nav>
   --------------------------------------------------------------------- */
.pagination { display: flex; flex-wrap: wrap; gap: var(--s-2); justify-content: center; margin-top: var(--s-10); }
.page-link { min-width: 40px; height: 40px; padding: 0 var(--s-3); display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--border-strong); border-radius: var(--r); font-size: var(--fs-sm); font-weight: 500; color: var(--text-2); font-variant-numeric: tabular-nums; transition: border-color var(--t-fast), color var(--t-fast); }
a.page-link:hover { border-color: var(--text-3); color: var(--text); }
.page-link.is-current { background: var(--green); border-color: var(--green); color: var(--on-accent); }
.page-link.is-disabled { opacity: .35; pointer-events: none; }

/* ---------------------------------------------------------------------
   Toast (main.js → toast(msg, type)). Fără modaluri.
   --------------------------------------------------------------------- */
.toast-region { position: fixed; z-index: 900; right: var(--s-4); bottom: var(--s-4); left: var(--s-4); display: flex; flex-direction: column; align-items: flex-end; gap: var(--s-2); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: var(--s-3); max-width: 420px; width: max-content; max-width: 100%; padding: var(--s-3) var(--s-4); background: #1D1D1F; border: 1px solid #1D1D1F; border-radius: var(--r); box-shadow: var(--shadow-lg); font-size: var(--fs-sm); color: #FFFFFF; animation: toast-in var(--t) var(--ease); }
.toast::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: #B9D3BD; }
.toast.toast-success::before { background: #6DAD7A; }
.toast.toast-error::before { background: #E07A72; }
.toast a { color: #B9D3BD; font-weight: 600; margin-left: auto; padding-left: var(--s-3); }
.toast.is-leaving { opacity: 0; transform: translateY(6px); transition: opacity var(--t) var(--ease), transform var(--t) var(--ease); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* Skeleton de încărcare */
.is-loading { opacity: .5; pointer-events: none; transition: opacity var(--t-fast); }

/* Tabel de date (comenzi, specificații) */
.table { width: 100%; font-size: var(--fs-sm); }
.table th { text-align: left; font-weight: 500; color: var(--text-2); padding: var(--s-3); border-bottom: 1px solid var(--border-strong); white-space: nowrap; }
.table td { padding: var(--s-3); border-bottom: 1px solid var(--border); vertical-align: top; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
