/* ─────────────────────────────────────────────────────────
   RFMX Quote Tool — Mobile-first stylesheet
   ───────────────────────────────────────────────────────── */

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
button { font-family: inherit; }

/* Design tokens */
:root {
  --navy:        #00599D;
  --navy-dark:   #004480;
  --navy-light:  #1a6fba;
  --gold:        #F5B800;
  --gold-dark:   #D9A000;
  --white:       #FFFFFF;
  --bg:          #EEF2F8;
  --card-bg:     #FFFFFF;
  --text:        #1A1A1A;
  --text-muted:  #6B7280;
  --border:      #D1D9E6;
  --success:     #1B6B2A;
  --radius:      10px;
  --radius-sm:   6px;
  --shadow:      0 2px 10px rgba(27,58,107,.10);
  --shadow-lg:   0 6px 24px rgba(27,58,107,.16);
  --transition:  0.15s ease;
}

/* Base */
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  line-height: 1.5;
}

.hidden  { display: none !important; }
.screen  { min-height: 100dvh; }

/* ── LOGIN ──────────────────────────────────────────────── */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}

.login-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 44px 32px 40px;
  text-align: center;
  width: 100%;
  max-width: 380px;
}

.login-logo {
  width: 200px;
  height: auto;
  margin: 0 auto 20px;
  display: block;
}

.login-subtitle {
  font-size: 15px;
  color: var(--text-muted);
  margin-bottom: 32px;
  font-weight: 500;
}

.btn-ms-login {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 14px 20px;
  background: var(--navy);
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.btn-ms-login:hover  { background: var(--navy-dark); }
.btn-ms-login:active { background: var(--navy-dark); opacity: 0.9; }

/* ── APP HEADER ─────────────────────────────────────────── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--navy);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
  min-height: 56px;
}

.header-logo-wrap {
  background: var(--white);
  border-radius: var(--radius-sm);
  padding: 3px 8px;
  display: flex;
  align-items: center;
}

.header-logo {
  height: 34px;
  width: auto;
  display: block;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

#user-name {
  color: rgba(255,255,255,.75);
  font-size: 12px;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#btn-logout {
  background: rgba(255,255,255,.15);
  color: var(--white);
  border: 1px solid rgba(255,255,255,.3);
  border-radius: var(--radius-sm);
  padding: 6px 11px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition);
  -webkit-tap-highlight-color: transparent;
}
#btn-logout:hover { background: rgba(255,255,255,.25); }

/* ── MAIN CONTENT ───────────────────────────────────────── */
main {
  padding: 12px 12px 40px;
  max-width: 680px;
  margin: 0 auto;
}

/* ── CARDS ──────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}

.card-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--navy);
  margin-bottom: 11px;
}

/* ── SERVICE TYPE TABS ──────────────────────────────────── */
.tab-group {
  display: flex;
  gap: 8px;
}

.tab {
  flex: 1;
  padding: 11px 8px;
  border: 2px solid var(--border);
  background: var(--white);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
  text-align: center;
}
.tab:hover       { border-color: var(--navy-light); color: var(--navy); }
.tab.active      { background: var(--navy); border-color: var(--navy); color: var(--white); }
.tab:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* ── DESTINATION SEARCH ─────────────────────────────────── */
.search-wrap { position: relative; }

#destination-input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px; /* ≥16px prevents iOS auto-zoom */
  color: var(--text);
  background: var(--white);
  outline: none;
  transition: border-color var(--transition);
  -webkit-appearance: none;
}
#destination-input:focus { border-color: var(--navy); }
#destination-input::placeholder { color: var(--text-muted); }

/* Dropdown */
.dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--white);
  border: 2px solid var(--navy);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: 300;
  max-height: 280px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.dropdown-item:last-child { border-bottom: none; }
.dropdown-item:hover,
.dropdown-item:focus { background: #EEF3FB; outline: none; }

.di-dest  { flex: 1; font-size: 15px; font-weight: 600; color: var(--text); }
.di-rate  { font-size: 15px; font-weight: 700; color: var(--success); white-space: nowrap; }
.di-miles { font-size: 12px; color: var(--text-muted); white-space: nowrap; }

/* Rate display after selection */
.rate-display {
  margin-top: 12px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.rate-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.rate-label { font-size: 14px; color: var(--text-muted); }

.rate-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--navy);
}

.fsc-row .rate-label { font-size: 13px; }
.fsc-value           { font-size: 16px; color: var(--text-muted); }

.miles-row .rate-miles { font-size: 14px; color: var(--text-muted); font-weight: 500; }

/* ── ACCESSORIAL TOGGLES ────────────────────────────────── */
.muted-hint {
  font-size: 14px;
  color: var(--text-muted);
  font-style: italic;
}

.toggle-all {
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--navy);
  padding-bottom: 10px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
  -webkit-tap-highlight-color: transparent;
}

#acc-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-height: 240px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.acc-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 4px;
  border-radius: 4px;
  transition: background var(--transition);
}
.acc-row:hover { background: #F5F8FF; }

.acc-toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  font-size: 14px;
  flex: 1;
  min-width: 0;
  -webkit-tap-highlight-color: transparent;
}

.acc-price-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.acc-name  { flex: 1; font-weight: 500; min-width: 0; }
.acc-price { color: var(--success); font-weight: 600; font-size: 13px; white-space: nowrap; }

/* Per-accessorial override input */
.acc-override {
  width: 80px;
  padding: 4px 6px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text);
  background: var(--white);
  outline: none;
  text-align: right;
  -webkit-appearance: none;
}
.acc-override:focus  { border-color: var(--navy); }
.acc-override::placeholder { color: #BBBBBB; font-style: italic; }

/* ── RATE ADJUSTMENTS ───────────────────────────────────── */
.adj-divider {
  height: 1px;
  background: var(--border);
  margin: 14px 0 12px;
}

.adj-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.adj-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.adj-hint {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
}

.currency-input {
  display: flex;
  align-items: center;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex-shrink: 0;
}

.currency-input span {
  padding: 8px 8px 8px 10px;
  background: #F4F6F9;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  border-right: 1px solid var(--border);
  line-height: 1;
}

.currency-input input {
  width: 90px;
  padding: 8px 10px;
  border: none;
  outline: none;
  font-size: 15px;
  font-weight: 600;
  color: var(--navy);
  background: var(--white);
  -webkit-appearance: none;
  -moz-appearance: textfield;
}
.currency-input input::placeholder { color: #CCCCCC; font-weight: 400; }
.currency-input:focus-within { border-color: var(--navy); }

input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--navy);
  cursor: pointer;
  flex-shrink: 0;
}

/* ── GENERATE BUTTON ────────────────────────────────────── */
.btn-generate {
  width: 100%;
  padding: 15px;
  background: var(--gold);
  color: var(--text);
  border: none;
  border-radius: var(--radius);
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: .3px;
  transition: background var(--transition), transform var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.btn-generate:hover:not(:disabled)  { background: var(--gold-dark); }
.btn-generate:active:not(:disabled) { transform: scale(.98); }
.btn-generate:disabled { opacity: .45; cursor: not-allowed; }

/* ── QUOTE PREVIEW ──────────────────────────────────────── */
#quote-scroll-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 14px;
  border-radius: 4px;
}

.export-row {
  display: flex;
  gap: 10px;
  margin-bottom: 8px;
}

.btn-export {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 13px 10px;
  border: 2px solid var(--navy);
  background: var(--white);
  color: var(--navy);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.btn-export:hover  { background: var(--navy); color: var(--white); }
.btn-export:active { transform: scale(.97); }
.btn-export.success { background: var(--success); border-color: var(--success); color: var(--white); }

.export-hint {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  min-height: 16px;
}

/* ── LOADING OVERLAY ────────────────────────────────────── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.52);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 9999;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255,255,255,.25);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: spin .75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay p {
  color: var(--white);
  font-size: 16px;
  font-weight: 500;
}

/* ── TOAST ──────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1A1A1A;
  color: var(--white);
  padding: 12px 20px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 8888;
  white-space: nowrap;
  max-width: calc(100vw - 32px);
  text-align: center;
  animation: toast-in .2s ease;
}
.toast.error { background: #B91C1C; }
@keyframes toast-in { from { opacity:0; transform: translateX(-50%) translateY(8px); } to { opacity:1; transform: translateX(-50%) translateY(0); } }

/* ── RESPONSIVE ─────────────────────────────────────────── */
@media (min-width: 480px) {
  main { padding: 16px 16px 48px; }
  .card { padding: 20px; margin-bottom: 12px; }
  .rate-value { font-size: 26px; }
}

@media (min-width: 680px) {
  main { padding: 20px 20px 60px; }
}
