/* BidMyRoute — shared styles */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --brand:        #1a4f8a;
  --brand-light:  #2563b0;
  --brand-dark:   #0f3262;
  --accent:       #f59e0b;
  --accent-hover: #d97706;
  --bg:           #f1f5f9;
  --surface:      #ffffff;
  --border:       #cbd5e1;
  --text:         #1e293b;
  --text-muted:   #64748b;
  --danger:       #dc2626;
  --success:      #16a34a;
  --radius:       6px;
  --shadow:       0 1px 4px rgba(0,0,0,.12);
  --shadow-lg:    0 4px 16px rgba(0,0,0,.14);
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  padding-bottom: 40px;  /* clear fixed site-footer */
}

/* ── Nav ── */
nav {
  background: var(--brand);
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 32px;
  height: 56px;
  box-shadow: var(--shadow-lg);
}

nav .logo {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  letter-spacing: -.3px;
}

nav .logo span { color: var(--accent); }

nav a {
  color: rgba(255,255,255,.82);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 4px 0;
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
}

nav a:hover, nav a.active {
  color: #fff;
  border-bottom-color: var(--accent);
}

/* ── Page shell ── */
.page-header {
  background: var(--brand-dark);
  color: #fff;
  padding: 20px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.page-header h1 { font-size: 20px; font-weight: 600; }
.page-header p  { font-size: 13px; color: rgba(255,255,255,.7); margin-top: 2px; }

main { padding: 28px 32px; max-width: 1100px; }

/* ── Card / section ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}

.card-header {
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: var(--radius) var(--radius) 0 0;
}

.card-header h2 { font-size: 14px; font-weight: 600; color: var(--brand); }

.section-badge {
  background: var(--brand);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: .4px;
  text-transform: uppercase;
}

.card-body { padding: 20px; }

/* ── Form grid ── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px 20px;
}

.form-group { display: flex; flex-direction: column; gap: 5px; }

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .4px;
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--brand-light);
  box-shadow: 0 0 0 3px rgba(37,99,176,.15);
}

/* ── Detail rows table ── */
.detail-table-wrap { overflow-x: auto; }

.detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.detail-table thead th {
  background: #f1f5f9;
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .4px;
  white-space: nowrap;
}

.detail-table tbody tr:hover { background: #f8fafc; }

.detail-table td {
  border: 1px solid var(--border);
  padding: 4px 6px;
  vertical-align: middle;
}

.detail-table td input,
.detail-table td select {
  border: none;
  background: transparent;
  width: 100%;
  padding: 4px 4px;
  font-size: 13px;
  color: var(--text);
}

.detail-table td input:focus,
.detail-table td select:focus {
  outline: 2px solid var(--brand-light);
  border-radius: 3px;
  background: #fff;
}

.detail-table td.row-actions {
  text-align: center;
  width: 40px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .1s;
  text-decoration: none;
}

.btn:active { transform: scale(.97); }

.btn-primary   { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-light); }

.btn-accent    { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-hover); }

.btn-ghost     { background: transparent; color: var(--brand); border: 1px solid var(--brand); }
.btn-ghost:hover { background: #eff6ff; }

.btn-danger    { background: transparent; color: var(--danger); border: 1px solid currentColor; }
.btn-danger:hover { background: #fef2f2; }

.btn-sm { padding: 4px 10px; font-size: 12px; }

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--danger);
  font-size: 16px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 3px;
}
.btn-icon:hover { background: #fef2f2; }

/* ── Toolbar ── */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.toolbar-left, .toolbar-right { display: flex; gap: 10px; align-items: center; }

/* ── Listing table ── */
.listing-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.listing-table thead th {
  background: var(--brand);
  color: #fff;
  padding: 10px 14px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .3px;
  white-space: nowrap;
}

.listing-table thead th:first-child { border-radius: var(--radius) 0 0 0; }
.listing-table thead th:last-child  { border-radius: 0 var(--radius) 0 0; }

.listing-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}

.listing-table tbody tr:hover { background: #eff6ff; }

.listing-table td {
  padding: 10px 14px;
  vertical-align: middle;
}

.listing-table td:last-child {
  white-space: nowrap;
  text-align: right;
}

/* ── Status badge ── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .3px;
}

.badge-draft    { background: #fef9c3; color: #92400e; }
.badge-active   { background: #dcfce7; color: #15803d; }
.badge-pending  { background: #ffedd5; color: #c2410c; }
.badge-closed   { background: #f1f5f9; color: #64748b; }
.badge-awarded  { background: #d1fae5; color: #065f46; }

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}

.empty-state svg { opacity: .35; margin-bottom: 12px; }
.empty-state p   { font-size: 15px; margin-bottom: 16px; }

/* ── Toast ── */
#toast-container {
  position: fixed;
  bottom: 52px;  /* above fixed site-footer */
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
}

.toast {
  background: var(--text);
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  animation: slideIn .2s ease;
}

.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }

@keyframes slideIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Geocode autocomplete ── */

/* Dropdown is portaled to <body> with position:fixed so it escapes
   any overflow:hidden/auto ancestor (e.g. scrollable table wrappers).
   JS sets top/left/width via getBoundingClientRect(). */
.geo-dropdown {
  display: none;
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  list-style: none;
  margin: 0;
  padding: 4px 0;
  z-index: 9000;
  max-height: 240px;
  overflow-y: auto;
}

.geo-item {
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.geo-item:hover,
.geo-item--active {
  background: #eff6ff;
  color: var(--brand);
}

/* ── Auth pages ── */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
  padding: 24px;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  padding: 40px 36px;
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-logo {
  font-size: 26px;
  font-weight: 800;
  color: var(--brand);
  text-decoration: none;
  text-align: center;
  letter-spacing: -.4px;
}

.auth-logo span { color: var(--accent); }

.auth-heading {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  margin-bottom: 4px;
}

.auth-footer {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.auth-footer a { color: var(--brand); font-weight: 600; text-decoration: none; }
.auth-footer a:hover { text-decoration: underline; }

.site-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  background: var(--brand);
  color: rgba(255,255,255,.82);
  text-align: center;
  font-size: 11px;
  font-weight: 500;
  padding: 10px 16px;
  letter-spacing: 0.04em;
  box-shadow: 0 -2px 8px rgba(0,0,0,.18);
}

.form-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  color: var(--danger);
  font-size: 13px;
  padding: 8px 12px;
}

.form-success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius);
  color: var(--success);
  font-size: 13px;
  padding: 8px 12px;
}

/* ── Responsive ── */
@media (max-width: 680px) {
  main { padding: 16px; }
  nav { padding: 0 16px; gap: 16px; }

  .page-header {
    padding: 14px 16px;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .form-grid { grid-template-columns: 1fr; }
  .form-grid .form-group { grid-column: 1 !important; }

  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-left { flex-direction: column; }
  .toolbar-left input,
  .toolbar-left select { width: 100% !important; max-width: 100% !important; }

  .auth-card { padding: 28px 20px; }
}

@media (max-width: 720px) {
  /* ── Listing table → card layout ── */
  .listing-table thead { display: none; }
  .listing-table tbody tr {
    display: block;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 10px;
    padding: 10px 12px;
    background: var(--surface);
    box-shadow: var(--shadow);
  }
  .listing-table tbody tr:hover { background: var(--surface); }
  .listing-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
    border: none;
    border-bottom: 1px solid #f1f5f9;
    text-align: left !important;
  }
  .listing-table td:first-child {
    font-size: 14px;
    font-weight: 700;
    border-bottom: 2px solid var(--border);
    padding-bottom: 8px;
    margin-bottom: 2px;
    justify-content: flex-start;
  }
  .listing-table td:last-child {
    border-bottom: none;
    justify-content: flex-end;
    padding-top: 8px;
  }
  .listing-table td[data-label]::before {
    content: attr(data-label);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .3px;
    flex-shrink: 0;
    margin-right: 8px;
  }

  /* ── Read-only detail table → card layout (route-bidding) ── */
  .detail-table.card-on-mobile { border: none; }
  .detail-table.card-on-mobile thead { display: none; }
  .detail-table.card-on-mobile tbody tr {
    display: block;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 10px;
    padding: 10px 12px;
    background: var(--surface);
    box-shadow: var(--shadow);
  }
  .detail-table.card-on-mobile tbody tr:hover { background: var(--surface); }
  .detail-table.card-on-mobile td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 5px 0;
    border: none;
    border-bottom: 1px solid #f1f5f9;
    text-align: left !important;
  }
  .detail-table.card-on-mobile td:first-child {
    font-size: 14px;
    font-weight: 700;
    border-bottom: 2px solid var(--border);
    padding-bottom: 8px;
    margin-bottom: 2px;
    justify-content: flex-start;
  }
  .detail-table.card-on-mobile td:last-child {
    border-bottom: none;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding-top: 8px;
  }
  .detail-table.card-on-mobile td[data-label]::before {
    content: attr(data-label);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .3px;
    flex-shrink: 0;
    margin-right: 8px;
    min-width: 72px;
  }
}
