/* shipping-quote.css
 * Styles for the shipping quote form, skeleton loader, and result card.
 */

/* ---------------------------------------------------------------------------
 * Optional label
 * --------------------------------------------------------------------------- */
.sq-optional {
  font-size: 0.8em;
  color: #888;
  font-weight: 400;
}

/* ---------------------------------------------------------------------------
 * Submit button loading state
 * --------------------------------------------------------------------------- */
.sq-submit-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  pointer-events: none;
}

/* ---------------------------------------------------------------------------
 * Turnstile
 * --------------------------------------------------------------------------- */
.sq-turnstile-wrap {
  min-height: 65px;
  margin-bottom: 4px;
}

.sq-turnstile-msg {
  font-size: 0.82rem;
  margin: 0 0 8px;
  padding: 6px 10px;
  border-radius: 4px;
  background: #fff3cd;
  border: 1px solid #ffc107;
  color: #856404;
}

.sq-turnstile-msg--error {
  background: #f8d7da;
  border-color: #f5c6cb;
  color: #721c24;
}

/* ---------------------------------------------------------------------------
 * Panel switching — fade-in + no-jerk-resize
 *
 * .sq-panel-enter is added by JS (showOnly) each time a panel is revealed.
 * The min-height lock in showOnly() prevents layout jump during the swap;
 * this animation makes the transition feel smooth rather than abrupt.
 * --------------------------------------------------------------------------- */
@keyframes sq-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0);   }
}

.sq-panel-enter {
  animation: sq-fade-in 0.22s ease-out both;
}

@media (prefers-reduced-motion: reduce) {
  .sq-panel-enter { animation: none; }
}

/* ---------------------------------------------------------------------------
 * Skeleton loader
 * --------------------------------------------------------------------------- */
@keyframes sq-shimmer {
  0%   { background-position: -700px 0; }
  100% { background-position:  700px 0; }
}

.sq-skeleton {
  padding: 24px 0;
}

.sq-skel-header,
.sq-skel-cell,
.sq-skel-total {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 700px 100%;
  animation: sq-shimmer 1.4s infinite linear;
  border-radius: 4px;
}

.sq-skel-header {
  height: 32px;
  width: 60%;
  margin-bottom: 20px;
}

.sq-skel-row {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

.sq-skel-cell {
  height: 20px;
  flex: 1;
}

.sq-skel-wide { flex: 2; }

.sq-skel-total {
  height: 48px;
  margin-top: 20px;
  border-radius: 6px;
}

/* ---------------------------------------------------------------------------
 * Result card
 * --------------------------------------------------------------------------- */
.sq-result {
  padding: 8px 0;
}

.sq-result-header {
  border-bottom: 2px solid #DF0A0A;
  padding-bottom: 12px;
  margin-bottom: 16px;
}

.sq-result-title-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.sq-result-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #1a1a1a;
  margin: 0;
}

.sq-quote-id {
  font-size: 0.78rem;
  color: #666;
  font-family: 'IBM Plex Mono', 'Courier New', monospace;
  background: #f3f3f3;
  padding: 2px 7px;
  border-radius: 3px;
}

.sq-route-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  color: #333;
  flex-wrap: wrap;
}

.sq-arrow {
  color: #DF0A0A;
  font-size: 1.1rem;
}

/* ---------------------------------------------------------------------------
 * Flag images
 *
 * Explicit width/height are set here AND as HTML attributes in buildCountryHtml
 * so mobile browsers that do not infer SVG intrinsic dimensions still render
 * the flags at the correct size without layout shift.
 * --------------------------------------------------------------------------- */
.sq-flag {
  display: inline-block;
  width: 20px;
  height: 14px;
  min-width: 20px;   /* guard against flex/grid collapsing the image */
  object-fit: cover;
  border-radius: 2px;
  vertical-align: middle;
  margin-right: 5px;
  border: 1px solid #ddd;
  /* Force hardware-composited layer on mobile to avoid SVG rasterisation glitch */
  transform: translateZ(0);
}

/* ---------------------------------------------------------------------------
 * Package details grid
 * --------------------------------------------------------------------------- */
.sq-detail-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.sq-detail-cell {
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 6px;
  padding: 8px 14px;
  min-width: 110px;
  flex: 1 1 110px;
}

.sq-detail-label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #888;
  margin-bottom: 2px;
}

.sq-detail-val {
  font-size: 0.92rem;
  font-weight: 600;
  color: #222;
  word-break: break-word;
}

/* ---------------------------------------------------------------------------
 * Fee breakdown table
 * --------------------------------------------------------------------------- */
.sq-fees-section {
  margin-bottom: 20px;
  /* Horizontal scroll on narrow viewports prevents the table from breaking
     the card width on mobile */
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.sq-fees-title {
  font-size: 0.88rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #555;
  margin-bottom: 8px;
}

.sq-fee-table {
  width: 100%;
  min-width: 280px; /* ensures table is readable before scrolling kicks in */
  border-collapse: collapse;
  font-size: 0.83rem;
}

.sq-fee-table th {
  background: #f3f3f3;
  border-bottom: 2px solid #ddd;
  padding: 6px 10px;
  text-align: left;
  font-weight: 700;
  color: #444;
  white-space: nowrap;
}

.sq-fee-table th.text-right,
.sq-fee-table td.text-right {
  text-align: right;
}

.sq-fee-table td {
  padding: 6px 10px;
  border-bottom: 1px solid #eee;
  vertical-align: top;
  color: #333;
}

.sq-fee-table tbody tr:last-child td { border-bottom: none; }
.sq-fee-table tbody tr:hover td      { background: #fafafa; }

.sq-fee-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 1px 5px;
  border-radius: 3px;
  margin-right: 6px;
  vertical-align: middle;
  background: #e9ecef;
  color: #495057;
}

.sq-fee-base      { background: #cfe2ff; color: #084298; }
.sq-fee-tax       { background: #fff3cd; color: #664d03; }
.sq-fee-customs   { background: #d1e7dd; color: #0f5132; }
.sq-fee-addon     { background: #f8d7da; color: #842029; }
.sq-fee-insurance { background: #d0f4de; color: #155724; }
.sq-fee-surcharge { background: #fde8d8; color: #7c3700; }

.sq-fee-name {
  font-weight: 600;
  vertical-align: middle;
}

.sq-fee-desc {
  display: block;
  color: #777;
  font-size: 0.78rem;
  margin-top: 2px;
}

.sq-no-fees {
  text-align: center;
  color: #aaa;
  font-style: italic;
  padding: 12px;
}

/* ---------------------------------------------------------------------------
 * Totals strip
 * --------------------------------------------------------------------------- */
.sq-total-strip {
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  padding: 14px 18px;
  margin-bottom: 18px;
}

.sq-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  font-size: 0.9rem;
  color: #444;
  border-bottom: 1px dashed #e0e0e0;
  gap: 12px;
}

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

.sq-total-grand {
  font-size: 1rem;
  font-weight: 700;
  color: #1a1a1a;
}

.sq-total-label { flex: 1; }

.sq-total-val {
  font-family: 'IBM Plex Mono', 'Courier New', monospace;
  font-size: 0.95rem;
  text-align: right;
  white-space: nowrap;
}

/* ---------------------------------------------------------------------------
 * Action bar
 * --------------------------------------------------------------------------- */
.sq-action-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.sq-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  font-size: 0.85rem;
  font-weight: 600;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.sq-action-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.sq-action-btn:not(:disabled):hover {
  opacity: 0.88;
  transform: translateY(-1px);
}

.sq-btn-pdf   { background: #DF0A0A; color: #fff; }
.sq-btn-email { background: #212529; color: #fff; }
.sq-btn-new   { background: #f0f0f0; color: #333; border: 1px solid #ccc; }

/* ---------------------------------------------------------------------------
 * Action message
 * --------------------------------------------------------------------------- */
.sq-action-msg {
  font-size: 0.85rem;
  padding: 8px 12px;
  border-radius: 4px;
  margin-top: 6px;
}

.sq-action-msg--ok {
  background: #d1e7dd;
  border: 1px solid #badbcc;
  color: #0f5132;
}

.sq-action-msg--error {
  background: #f8d7da;
  border: 1px solid #f5c6cb;
  color: #721c24;
}

/* ---------------------------------------------------------------------------
 * Error state
 * --------------------------------------------------------------------------- */
.sq-error-state {
  padding: 24px 0;
  text-align: center;
}

.sq-error-msg {
  font-size: 0.9rem;
  color: #721c24;
  background: #f8d7da;
  border: 1px solid #f5c6cb;
  border-radius: 5px;
  padding: 10px 16px;
  margin-bottom: 14px;
}

/* ---------------------------------------------------------------------------
 * Inline field-level errors
 * --------------------------------------------------------------------------- */
.sq-field-error {
  display: block;
  font-size: 0.78rem;
  color: #dc3545;
  margin-top: 4px;
  line-height: 1.3;
}

.sq-field-error:empty,
.sq-field-error[hidden] {
  display: none !important;
}

/* ---------------------------------------------------------------------------
 * Dynamic rows (Declared Value, Office Pickup)
 * --------------------------------------------------------------------------- */
.sq-dynamic-row[hidden] {
  display: none !important;
}

/* ---------------------------------------------------------------------------
 * Office Pickup row
 *
 * Hidden by default via CSS — independent of the [hidden] HTML attribute.
 * JS (handleDestinationChange) adds .sq-pickup-visible when the selected
 * destination country has has_office_pickup=true.
 *
 * Using both the [hidden] attribute (semantics + accessibility) and this
 * CSS class (visual control) guards against Bootstrap utilities or
 * third-party libraries that may interfere with the [hidden] attribute alone.
 * --------------------------------------------------------------------------- */
#sqPickupRow {
  display: none !important;
}

#sqPickupRow.sq-pickup-visible {
  display: block !important;
}

/* ---------------------------------------------------------------------------
 * Responsive
 * --------------------------------------------------------------------------- */
@media (max-width: 576px) {
  .sq-result-title  { font-size: 1rem; }
  .sq-quote-id      { font-size: 0.72rem; }

  .sq-detail-cell   { min-width: 90px; flex: 1 1 90px; }
  .sq-detail-label  { font-size: 0.68rem; }
  .sq-detail-val    { font-size: 0.85rem; }

  .sq-total-val     { font-size: 0.85rem; }
  .sq-total-grand   { font-size: 0.95rem; }

  .sq-action-bar    { flex-direction: column; }
  .sq-action-btn    { width: 100%; justify-content: center; }

  /* Flags: force explicit render size on narrow viewports */
  .sq-flag {
    width: 18px;
    height: 12px;
    min-width: 18px;
  }
}

/* ---------------------------------------------------------------------------
 * Disabled/inactive country options
 * --------------------------------------------------------------------------- */
.sq-country-inactive { color: #aaa; font-style: italic; }
select option:disabled { color: #bbb; }