*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #1565C0;
  --primary-light: #1976D2;
  --primary-dark: #0D47A1;
  --secondary: #42A5F5;
  --success: #2E7D32;
  --danger: #C62828;
  --warning: #E65100;
  --bg: #ECEFF1;
  --card-bg: #FFFFFF;
  --calc-bg: #E3F2FD;
  --calc-border: #90CAF9;
  --text: #212121;
  --text-light: #757575;
  --border: #CFD8DC;
  --shadow: 0 2px 8px rgba(0,0,0,0.12);
  --radius: 8px;
}

body {
  font-family: 'Segoe UI', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

/* ===== HEADER ===== */
header {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  color: white;
  padding: 14px 24px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.3);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 20px;
  justify-content: space-between;
}

header h1 {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.3px;
  line-height: 1.4;
  flex: 1;
  text-transform: uppercase;
}

.header-nav {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  align-items: center;
}

/* ===== MAIN ===== */
main {
  max-width: 1200px;
  margin: 24px auto;
  padding: 0 16px 60px;
}

/* ===== CARD ===== */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}

.card h2 {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  border-bottom: 2px solid var(--secondary);
  padding-bottom: 10px;
  margin-bottom: 20px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.card h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-light);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ===== FORM GRID ===== */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

.form-group.two-thirds {
  grid-column: span 2;
}

.form-group > label,
.field-label {
  font-weight: 600;
  font-size: 12px;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.form-group select,
.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="email"] {
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  background: white;
  transition: border-color 0.15s, box-shadow 0.15s;
  color: var(--text);
  appearance: auto;
}

.form-group select:focus,
.form-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.12);
}

.form-group input.readonly-field {
  background: var(--calc-bg);
  border-color: var(--calc-border);
  color: var(--primary);
  font-weight: 700;
  cursor: default;
}

/* ===== TOGGLE ===== */
.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.toggle-group {
  display: flex;
  border-radius: 6px;
  overflow: hidden;
  border: 1.5px solid var(--border);
  width: fit-content;
}

.toggle-btn {
  padding: 8px 22px;
  border: none;
  background: white;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.15s, color 0.15s;
  font-family: inherit;
  color: var(--text-light);
}

.toggle-btn:not(:last-child) {
  border-right: 1.5px solid var(--border);
}

.toggle-btn.active-nu {
  background: #455A64;
  color: white;
}

.toggle-btn.active-da {
  background: var(--primary);
  color: white;
}

.toggle-btn:hover:not(.active-nu):not(.active-da) {
  background: #f5f5f5;
}

/* ===== HIDDEN ===== */
.hidden { display: none !important; }

/* ===== INSERIERE NUMERICA ===== */
.inseriere-details {
  margin-top: 14px;
  padding: 16px;
  background: #F8F9FA;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.inseriere-grid {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.inseriere-grid .form-group {
  flex: 1;
  min-width: 160px;
  max-width: 240px;
}

/* ===== CULORI GRID ===== */
.culori-section-inner {
  margin-top: 10px;
  padding: 16px;
  background: #F8F9FA;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.culori-grid {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.culori-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 150px;
}

.culori-item > label {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
}

/* ===== PRETURI SECTION ===== */
.preturi-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pret-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  border-radius: 8px;
  border: 1px solid var(--border);
  flex-wrap: wrap;
  background: #FAFAFA;
  transition: border-color 0.15s;
}

.pret-row.highlight {
  background: var(--calc-bg);
  border-color: var(--calc-border);
}

.pret-row.total-row {
  background: linear-gradient(135deg, #E8F5E9, #C8E6C9);
  border-color: #81C784;
}

.pret-number {
  font-size: 13px;
  font-weight: 700;
  color: white;
  background: var(--primary);
  border-radius: 50%;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.pret-row.total-row .pret-number {
  background: var(--success);
}

.pret-label {
  font-weight: 600;
  font-size: 14px;
  flex: 1;
  min-width: 200px;
}

.pret-value {
  font-size: 20px;
  font-weight: 800;
  color: var(--primary);
  min-width: 160px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.pret-row.total-row .pret-value {
  color: var(--success);
}

.pret-value.not-set {
  color: var(--text-light);
  font-size: 14px;
  font-weight: 400;
  font-style: italic;
}

.pret-value.pret-warning {
  color: var(--warning);
  font-size: 13px;
  font-weight: 600;
}

/* ===== DISCOUNT ===== */
.discount-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.discount-input-wrap input {
  width: 90px;
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  text-align: right;
}

.discount-input-wrap input:focus {
  outline: none;
  border-color: var(--primary);
}

.discount-input-wrap span {
  font-weight: 700;
  font-size: 16px;
  color: var(--text-light);
}

/* ===== BUTTONS ===== */
.btn {
  padding: 9px 18px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  transition: all 0.15s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-primary {
  background: var(--primary-light);
  color: white;
}
.btn-primary:hover { background: var(--primary); }

.btn-success {
  background: var(--success);
  color: white;
}
.btn-success:hover { background: #1b5e20; }

.btn-secondary {
  background: rgba(255,255,255,0.18);
  color: white;
  border: 1.5px solid rgba(255,255,255,0.4);
}
.btn-secondary:hover { background: rgba(255,255,255,0.3); }

.btn-outline {
  background: transparent;
  color: var(--text-light);
  border: 1.5px solid var(--border);
}
.btn-outline:hover { background: #f0f0f0; color: var(--text); }

.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover { background: #b71c1c; }

.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
}

.btn-lg {
  padding: 12px 24px;
  font-size: 14px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ===== ALERT ===== */
.alert {
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 12px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert-warning {
  background: #FFF8E1;
  border: 1px solid #FFE082;
  color: #E65100;
}

.alert-info {
  background: var(--calc-bg);
  border: 1px solid var(--calc-border);
  color: var(--primary);
}

.alert-success {
  background: #E8F5E9;
  border: 1px solid #A5D6A7;
  color: var(--success);
}

/* ===== SETTINGS NAV ===== */
.settings-nav {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.nav-tab {
  padding: 10px 18px;
  border-radius: 6px;
  border: 2px solid transparent;
  background: white;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  color: var(--text-light);
  transition: all 0.15s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.nav-tab.active {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--calc-bg);
}

.nav-tab:hover:not(.active) {
  border-color: var(--border);
  color: var(--text);
}

.settings-section { display: none; }
.settings-section.active { display: block; }

/* ===== TAG LIST ===== */
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  background: #FAFAFA;
  min-height: 54px;
  align-items: center;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: var(--primary);
  color: white;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
}

.tag-remove {
  background: rgba(255,255,255,0.25);
  border: none;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  cursor: pointer;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
  transition: background 0.15s;
  padding: 0;
  font-family: inherit;
}

.tag-remove:hover {
  background: rgba(255,255,255,0.45);
}

.tag-empty {
  color: #999;
  font-size: 12px;
  font-style: italic;
}

.add-item-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.add-item-row input {
  flex: 1;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
}

.add-item-row input:focus {
  outline: none;
  border-color: var(--primary);
}

/* ===== OPTIUNE BLOCK (Settings) ===== */
.optiune-block {
  margin-bottom: 16px;
  padding: 18px;
  background: white;
  border-radius: 8px;
  border: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.optiune-block h3 {
  margin-bottom: 10px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

/* ===== PRICE TABLE ===== */
.price-filter-bar {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 12px 16px;
  background: var(--calc-bg);
  border-radius: 6px;
  border: 1px solid var(--calc-border);
}

.price-filter-bar label {
  font-weight: 700;
  font-size: 13px;
  color: var(--primary);
}

.price-filter-bar select {
  padding: 7px 12px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  background: white;
}

.price-filter-bar select:focus {
  outline: none;
  border-color: var(--primary);
}

.price-table-wrap {
  overflow-x: auto;
  border-radius: 6px;
  border: 1px solid var(--border);
}

table.price-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
}

table.price-table th {
  background: var(--primary);
  color: white;
  padding: 10px 14px;
  text-align: center;
  font-weight: 700;
  white-space: nowrap;
  border: 1px solid rgba(255,255,255,0.2);
}

table.price-table td {
  border: 1px solid var(--border);
  padding: 7px 10px;
  text-align: center;
  background: white;
}

table.price-table tr:nth-child(even) td {
  background: #F8F9FA;
}

table.price-table td.row-header {
  font-weight: 700;
  background: var(--calc-bg) !important;
  color: var(--primary);
  text-align: left;
  white-space: nowrap;
  padding: 7px 12px;
}

table.price-table input[type="number"] {
  width: 90px;
  padding: 6px 8px;
  border: 1.5px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
  text-align: right;
  font-family: inherit;
  background: white;
}

table.price-table input[type="number"]:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
}

table.price-table input[type="number"]:not(:placeholder-shown) {
  border-color: #66BB6A;
  background: #F1F8E9;
}

/* ===== COMPANY FORM ===== */
.company-form {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.company-form .form-group input {
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  background: white;
}

.company-form .form-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.1);
}

/* ===== ADAOS ===== */
.adaos-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.adaos-wrap input {
  width: 110px;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 18px;
  font-weight: 700;
  font-family: inherit;
  text-align: center;
  color: var(--primary);
}

.adaos-wrap input:focus {
  outline: none;
  border-color: var(--primary);
}

.adaos-unit {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-light);
}

.adaos-preview {
  padding: 10px 14px;
  background: var(--calc-bg);
  border-radius: 6px;
  border: 1px solid var(--calc-border);
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  margin-top: 12px;
}

/* ===== SAVE BAR ===== */
.save-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  padding: 12px 24px;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.12);
  display: flex;
  justify-content: center;
  gap: 12px;
  z-index: 200;
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  color: white;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast-success { background: #2E7D32; }
.toast-error { background: #C62828; }
.toast-warning { background: #E65100; }
.toast-info { background: var(--primary); }

/* ===== SETTINGS SECTION INFO ===== */
.section-info {
  padding: 10px 14px;
  background: var(--calc-bg);
  border-radius: 6px;
  border-left: 4px solid var(--secondary);
  color: var(--primary);
  font-size: 13px;
  margin-bottom: 16px;
}

/* ===== SEPARATOR ===== */
.separator {
  height: 1px;
  background: var(--border);
  margin: 24px 0;
}

/* ===== PRINT STYLES ===== */
@media print {
  body { background: white; }
  header, .save-bar, .btn, .header-nav, #alertContainer { display: none !important; }
}

/* ===== COMPACT LAYOUT (index.html) ===== */
.main-layout {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

.options-card {
  flex: 1;
  min-width: 340px;
}

.prices-card {
  flex: 1;
  min-width: 340px;
}

.opt-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.opt-row:last-child {
  border-bottom: none;
}

.opt-label {
  flex: 0 0 200px;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-light);
}

.opt-select {
  flex: 1;
  padding: 7px 10px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  background: #fff;
}

.opt-select:focus {
  border-color: var(--primary);
  outline: none;
}

.opt-select-sm {
  padding: 5px 8px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
}

.culori-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 6px 0;
}

.culoare-inline-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-light);
}

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

/* --- Tablet landscape: stack two-column layout --- */
@media (max-width: 960px) {
  .main-layout {
    flex-direction: column;
  }
  .options-card,
  .prices-card {
    min-width: unset;
    width: 100%;
  }
}

/* --- Tablet portrait / large phone --- */
@media (max-width: 680px) {
  header {
    padding: 10px 14px;
    position: sticky;
    top: 0;
  }
  .header-content {
    flex-wrap: wrap;
    gap: 6px;
  }
  header h1 {
    font-size: 10px;
    width: 100%;
    line-height: 1.4;
  }
  .header-nav {
    margin-left: auto;
  }
  main {
    margin: 12px auto;
    padding: 0 10px 80px;
  }
  .card {
    padding: 16px;
    margin-bottom: 14px;
  }
  .opt-label {
    flex: 0 0 150px;
    font-size: 12px;
  }
  .pret-value {
    font-size: 16px;
    min-width: 110px;
  }
  .pret-label {
    min-width: 0;
    font-size: 13px;
  }
  .settings-nav {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 4px;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
  }
  .nav-tab {
    white-space: nowrap;
    flex-shrink: 0;
    padding: 8px 12px;
    font-size: 12px;
  }
  .company-form {
    grid-template-columns: 1fr;
  }
  .save-bar {
    padding: 10px 14px;
  }
  .pret-row {
    padding: 12px 14px;
    gap: 12px;
  }
}

/* --- Phone --- */
@media (max-width: 480px) {
  header h1 {
    font-size: 9px;
  }
  .header-nav .btn {
    padding: 7px 12px;
    font-size: 12px;
  }
  /* Stack opt-row label above input */
  .opt-row {
    flex-direction: column;
    align-items: stretch;
    gap: 5px;
    padding: 10px 0;
  }
  .opt-label {
    flex: none;
    font-size: 12px;
    font-weight: 700;
    color: var(--primary);
  }
  .opt-select {
    width: 100%;
  }
  /* Culori grid wraps tighter */
  .culori-inline {
    gap: 8px;
  }
  .culoare-inline-item {
    font-size: 12px;
  }
  /* Pret rows: price value full-width below label+number */
  .pret-label {
    flex: 1;
    min-width: 0;
  }
  .pret-value {
    width: 100%;
    text-align: left;
    font-size: 15px;
    min-width: unset;
  }
  .pret-row .btn {
    width: 100%;
    justify-content: center;
  }
  /* Bigger touch targets for toggle */
  .toggle-btn {
    padding: 10px 24px;
  }
  /* Inseriere details stack vertically */
  .inseriere-details {
    padding: 12px;
  }
  .inseriere-grid {
    flex-direction: column;
    gap: 10px;
  }
  .inseriere-grid .form-group {
    max-width: unset;
    min-width: unset;
    width: 100%;
  }
  .discount-input-wrap input {
    width: 75px;
  }
  /* Settings: sections below tabs */
  .optiune-block {
    padding: 14px;
  }
  .add-item-row {
    flex-wrap: wrap;
  }
  .add-item-row input {
    min-width: 0;
    flex: 1 1 150px;
  }
  /* Price table: horizontal scroll */
  .price-table-wrap {
    -webkit-overflow-scrolling: touch;
  }
  /* Inputs in price table: narrower */
  table.price-table input[type="number"] {
    width: 72px;
    padding: 5px 6px;
    font-size: 12px;
  }
  table.price-table th,
  table.price-table td {
    padding: 6px 8px;
    font-size: 12px;
  }
  .section-info {
    font-size: 12px;
  }
}

/* --- Small phone (iPhone SE, Galaxy A13 etc.) --- */
@media (max-width: 360px) {
  .card h2 {
    font-size: 12px;
  }
  .pret-row {
    padding: 10px;
  }
  .pret-number {
    width: 22px;
    height: 22px;
    font-size: 11px;
  }
  .pret-value {
    font-size: 14px;
  }
  .toggle-btn {
    padding: 9px 18px;
    font-size: 12px;
  }
  .btn-sm {
    padding: 6px 10px;
    font-size: 11px;
  }
}
