/* ============================================================
   Proposal Management Platform — Shared Stylesheet
   ============================================================ */

/* --- Auth / Nav user widget --- */
#nav-user-widget button:focus { outline: 2px solid rgba(255,255,255,.5); }
.viewer-banner {
  background: #fef9c3;
  border-bottom: 2px solid #f59e0b;
  text-align: center;
  padding: 6px 16px;
  font-size: 12px;
  font-weight: 600;
  color: #92400e;
}

/* --- Variables --- */
:root {
  --primary: #1e3a5f;
  --primary-light: #2a5298;
  --accent: #0a84ff;
  --amber: #f59e0b;
  --green: #10b981;
  --red: #ef4444;
  --indigo: #4f46e5;
  --bg: #f0f4f8;
  --card: #ffffff;
  --border: #d1d9e6;
  --text: #1a202c;
  --muted: #6b7280;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; min-height: 100vh; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* --- Navigation --- */
.nav {
  background: var(--primary);
  padding: 0 24px;
  display: flex;
  align-items: center;
  height: 54px;          /* fixed navbar height — logo cannot push this taller */
  min-height: 54px;
  max-height: 54px;
  gap: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
  position: sticky;
  top: 0;
  z-index: 100;
  overflow: hidden;      /* clip anything that tries to overflow */
}
.nav-brand {
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 20px 0 0;
  border-right: 1px solid rgba(255,255,255,.2);
  margin-right: 12px;
  text-decoration: none;
  flex-shrink: 0;
}
.nav-logo {
  height: 32px;          /* explicit pixel height — never grows larger */
  max-height: 32px;
  width: auto;
  max-width: 180px;      /* cap width so wide logos don't overflow */
  display: block;
  background: #fff;
  border-radius: 5px;
  padding: 3px 8px;
  object-fit: contain;
  flex-shrink: 0;
}
.nav-links {
  display: flex;
  align-items: center;
  height: 100%;
  gap: 0;
}
.nav-links a {
  color: rgba(255,255,255,.8);
  padding: 0 16px;
  height: 100%;
  display: flex;
  align-items: center;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: all .2s;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
}
.nav-links a:hover, .nav-links a.active {
  color: #fff;
  border-bottom-color: var(--accent);
  background: rgba(255,255,255,.07);
}

/* --- Page wrapper --- */
.page-wrapper { max-width: 1100px; margin: 0 auto; padding: 28px 20px 60px; }
.page-title { font-size: 22px; font-weight: 700; color: var(--primary); margin-bottom: 6px; }
.page-subtitle { color: var(--muted); font-size: 13px; margin-bottom: 24px; }

/* --- Card --- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.card-title { font-size: 15px; font-weight: 700; color: var(--primary); display: flex; align-items: center; gap: 8px; }
.card-title i { color: var(--accent); }

/* --- Form --- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.form-grid-4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  font-size: 13.5px;
  font-family: var(--font);
  color: var(--text);
  background: #fff;
  transition: border-color .2s, box-shadow .2s;
}
.form-control:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(10,132,255,.12); }
select.form-control { cursor: pointer; }
input[type="number"].form-control { text-align: right; }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: all .2s;
  white-space: nowrap;
  font-family: var(--font);
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover:not(:disabled) { background: var(--primary-light); }
.btn-accent { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-accent:hover:not(:disabled) { background: #0070dd; }
.btn-success { background: var(--green); color: #fff; border-color: var(--green); }
.btn-success:hover:not(:disabled) { background: #059669; }
.btn-amber { background: var(--amber); color: #fff; border-color: var(--amber); }
.btn-amber:hover:not(:disabled) { background: #d97706; }
.btn-danger { background: var(--red); color: #fff; border-color: var(--red); }
.btn-danger:hover:not(:disabled) { background: #dc2626; }
.btn-outline { background: transparent; color: var(--primary); border-color: var(--border); }
.btn-outline:hover:not(:disabled) { background: var(--bg); border-color: var(--primary); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 7px; border-radius: 6px; }
.history-row-actions .btn-sm { padding: 5px 8px; }

/* --- Badges / Pills --- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-blue  { background: #dbeafe; color: #1d4ed8; }
.badge-amber { background: #fef3c7; color: #92400e; }
.badge-green { background: #d1fae5; color: #065f46; }
.badge-red   { background: #fee2e2; color: #991b1b; }
.badge-indigo{ background: #e0e7ff; color: #3730a3; }
.badge-gray  { background: #f3f4f6; color: #374151; }

/* --- Table --- */
.table-responsive { overflow-x: auto; border-radius: 8px; border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead tr { background: var(--primary); color: #fff; }
thead th { padding: 11px 14px; text-align: left; font-weight: 600; font-size: 12px; letter-spacing: .4px; white-space: nowrap; }
thead th.num { text-align: right; }
tbody tr { border-bottom: 1px solid #f0f2f5; transition: background .15s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #f7f9fc; }
tbody td { padding: 10px 14px; vertical-align: middle; }
tbody td.num { text-align: right; font-variant-numeric: tabular-nums; }
tfoot tr { border-top: 2px solid var(--border); }
tfoot td { padding: 10px 14px; font-weight: 600; }
tfoot td.num { text-align: right; }

/* --- Product rows (quotation form) --- */
.product-rows { display: flex; flex-direction: column; gap: 12px; }

.product-row {
  background: #f8fafc;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  position: relative;
}
.product-row:hover { border-color: #b0c4de; }
.product-row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.product-row-num {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  background: #e2e8f0;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.product-row-actions { display: flex; gap: 6px; }
.product-row-fields { display: grid; grid-template-columns: 2fr 1fr 1fr 110px 90px 90px; gap: 10px; align-items: end; }

/* --- Discount section --- */
.discount-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.discount-type-toggle { display: flex; border: 1.5px solid var(--border); border-radius: 7px; overflow: hidden; }
.discount-type-toggle button {
  padding: 8px 18px;
  border: none;
  background: #fff;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: all .2s;
  font-family: var(--font);
}
.discount-type-toggle button.active { background: var(--primary); color: #fff; }

/* --- Summary Section --- */
#summary-section { margin-top: 32px; }

.summary-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  border-radius: 12px 12px 0 0;
  padding: 24px 28px;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.summary-header-left h2 { font-size: 20px; font-weight: 800; letter-spacing: .3px; }
.summary-header-left p { font-size: 12px; opacity: .8; margin-top: 2px; }
.summary-badge {
  background: rgba(255,255,255,.18);
  border: 1.5px solid rgba(255,255,255,.3);
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .6px;
  text-transform: uppercase;
}

.summary-meta {
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-top: none;
  padding: 14px 28px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.summary-meta-item label { font-size: 10px; font-weight: 700; text-transform: uppercase; color: var(--muted); letter-spacing: .5px; display: block; margin-bottom: 2px; }
.summary-meta-item span { font-size: 14px; font-weight: 600; color: var(--text); }

/* Summary table */
.summary-table-wrap {
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 12px 12px;
  overflow: hidden;
}
.summary-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.summary-table thead tr { background: #334155; }
.summary-table thead th { padding: 10px 14px; text-align: left; color: #e2e8f0; font-size: 11.5px; font-weight: 700; letter-spacing: .4px; white-space: nowrap; }
.summary-table thead th.num { text-align: right; }
.summary-table tbody td { padding: 10px 14px; border-bottom: 1px solid #f0f2f5; vertical-align: middle; }
.summary-table tbody td.num { text-align: right; font-variant-numeric: tabular-nums; }
/* country group header */
.summary-table tr.country-header td {
  background: #dbeafe;
  color: #1e3a5f;
  font-weight: 700;
  font-size: 13px;
  padding: 9px 14px;
  border-bottom: none;
}
.summary-table tr.country-header td:first-child { padding-left: 18px; }
/* alternating row */
.summary-table tr.product-row-even td { background: #fafafa; }
.summary-table tr.product-row-odd  td { background: #fff; }
.summary-table tr:hover:not(.country-header):not(.country-subtotal):not(.totals-row) td { background: #f0f7ff; }
/* country subtotal */
.summary-table tr.country-subtotal td {
  background: #e0e7ff;
  color: #3730a3;
  font-weight: 700;
  border-top: 1.5px solid #c7d2fe;
  border-bottom: 1.5px solid #c7d2fe;
  padding: 9px 14px;
}
.summary-table tr.country-subtotal td.num { text-align: right; }
/* totals rows */
.summary-table tr.totals-subtotal td { background: #f8fafc; font-weight: 700; padding: 10px 14px; }
.summary-table tr.totals-discount td { background: #fffbeb; font-weight: 700; color: #92400e; padding: 10px 14px; }
.summary-table tr.totals-discount td.num { text-align: right; }
.summary-table tr.totals-grandtotal td {
  background: linear-gradient(90deg, #1e3a5f 0%, #2a5298 100%);
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  padding: 14px 14px;
}
.summary-table tr.totals-grandtotal td.num { text-align: right; font-size: 18px; }

/* spacer row between country groups */
.summary-table tr.spacer td { padding: 4px 0; background: transparent; border: none; }

/* reg type pill in table */
.reg-type-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  background: #dbeafe;
  color: #1e40af;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

/* --- Summary action bar --- */
.summary-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

/* --- Toast notification --- */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1e293b;
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 6px 20px rgba(0,0,0,.25);
  z-index: 9999;
  opacity: 0;
  transform: translateY(12px);
  transition: all .3s;
  max-width: 360px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.toast-success { border-left: 4px solid var(--green); }
.toast.toast-error   { border-left: 4px solid var(--red); }
.toast.toast-info    { border-left: 4px solid var(--accent); }

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}
.modal-box {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.modal-header {
  background: var(--primary);
  color: #fff;
  padding: 18px 24px;
  border-radius: 12px 12px 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* --- Admin tabs --- */
.tabs { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 20px; gap: 2px; }
.tab-btn {
  padding: 10px 20px;
  border: none;
  background: transparent;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: all .2s;
  font-family: var(--font);
}
.tab-btn:hover { color: var(--primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* --- Stats cards --- */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.stat-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  text-align: center;
}
.stat-card .stat-val { font-size: 28px; font-weight: 800; color: var(--primary); }
.stat-card .stat-lbl { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* --- Search / filter bar --- */
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filter-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-pill {
  padding: 5px 13px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: #fff;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: all .2s;
}
.filter-pill:hover, .filter-pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* --- History --- */
.client-group { margin-bottom: 20px; }
.client-group-header {
  background: linear-gradient(90deg, var(--primary) 0%, var(--primary-light) 100%);
  color: #fff;
  padding: 12px 18px;
  border-radius: 10px 10px 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}
.client-group-header h3 { font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.client-group-body { border: 1px solid var(--border); border-top: none; border-radius: 0 0 10px 10px; overflow: hidden; }
.history-row { display: grid; grid-template-columns: minmax(140px,1fr) 110px 80px 130px 80px 320px; align-items: center; gap: 8px; padding: 11px 16px; border-bottom: 1px solid #f0f2f5; }
.history-row:last-child { border-bottom: none; }
.history-row:hover { background: #f7f9fc; }
.history-row-ref { font-weight: 600; color: var(--primary); }
.history-row-actions { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }

/* --- Quotation view modal content --- */
.view-summary-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.view-summary-table th { background: #334155; color: #e2e8f0; padding: 8px 12px; font-size: 11.5px; text-align: left; }
.view-summary-table th.num { text-align: right; }
.view-summary-table td { padding: 8px 12px; border-bottom: 1px solid #f0f2f5; }
.view-summary-table td.num { text-align: right; }
.view-summary-table tr.country-header td { background: #dbeafe; font-weight: 700; color: #1e3a5f; }
.view-summary-table tr.country-subtotal td { background: #e0e7ff; font-weight: 700; color: #3730a3; }
.view-summary-table tr.totals-discount td { background: #fffbeb; font-weight: 700; color: #92400e; }
.view-summary-table tr.totals-grandtotal td { background: #1e3a5f; color: #fff; font-weight: 800; font-size: 14px; }
.view-summary-table tr.totals-grandtotal td.num { text-align: right; }

/* --- Empty state --- */
.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-state i { font-size: 48px; margin-bottom: 14px; opacity: .4; }
.empty-state p { font-size: 15px; }

/* --- Import/export zone --- */
.drop-zone {
  border: 2.5px dashed var(--border);
  border-radius: 10px;
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
  color: var(--muted);
  font-size: 14px;
}
.drop-zone:hover, .drop-zone.drag-over { border-color: var(--accent); background: #eff6ff; color: var(--accent); }
.drop-zone i { font-size: 32px; margin-bottom: 8px; display: block; }

/* --- LAR Fee badges & pills --- */
.lar-type-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  background: #ccfbf1;
  color: #0f766e;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-lar-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  background: #0d9488;
  color: #fff;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

/* --- Section headers in summary table --- */
.summary-table tr.section-header-reg td {
  background: #e0e7ff;
  color: #1e3a5f;
  font-weight: 700;
  font-size: 12.5px;
  padding: 8px 14px;
  letter-spacing: .3px;
  border-bottom: none;
}
.summary-table tr.section-header-lar td {
  background: #ccfbf1;
  color: #0f766e;
  font-weight: 700;
  font-size: 12.5px;
  padding: 8px 14px;
  letter-spacing: .3px;
  border-bottom: none;
}
/* LAR subtotal row */
.summary-table tr.lar-subtotal td {
  background: #99f6e4;
  color: #0f766e;
  font-weight: 700;
  border-top: 1.5px solid #5eead4;
  border-bottom: 1.5px solid #5eead4;
  padding: 9px 14px;
}
.summary-table tr.lar-subtotal td.num { text-align: right; }

/* history view modal mirroring */
.view-summary-table tr.section-header-reg td { background: #e0e7ff; font-weight: 700; color: #1e3a5f; padding: 7px 12px; }
.view-summary-table tr.section-header-lar td { background: #ccfbf1; font-weight: 700; color: #0f766e; padding: 7px 12px; }
.view-summary-table tr.lar-subtotal td { background: #99f6e4; font-weight: 700; color: #0f766e; }

/* LAR product row tint */
.product-row.product-row-lar {
  background: #f0fdfa;
  border-color: #99f6e4;
}
.product-row.product-row-lar:hover { border-color: #5eead4; }

/* --- Print styles --- */
@media print {
  .nav, .page-title, .page-subtitle,
  #form-section, #generate-btn-wrap, .summary-actions,
  .no-print { display: none !important; }
  body { background: #fff; }
  .page-wrapper { padding: 0; max-width: 100%; }
  .summary-header { background: #1e3a5f !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .summary-table thead tr { background: #334155 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .summary-table tr.country-header td { background: #dbeafe !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .summary-table tr.country-subtotal td { background: #e0e7ff !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .summary-table tr.totals-grandtotal td { background: #1e3a5f !important; color: #fff !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .form-grid, .form-grid-3, .form-grid-4 { grid-template-columns: 1fr; }
  .product-row-fields { grid-template-columns: 1fr 1fr; }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .summary-meta { grid-template-columns: 1fr 1fr; }
  .history-row { grid-template-columns: 1fr 1fr; }
}
