/* RideRoute Custom Styles */

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background-color: var(--bs-body-bg);
  color: var(--bs-body-color);
}

.navbar-brand {
  font-size: 1.4rem;
  letter-spacing: 0.5px;
}

/* ── Auth pages — animated gradient background ────────────────────────────── */
@keyframes gradientShift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

body.auth-bg {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(-45deg, #0d1b2a, #1b2a1b, #0a3d2e, #023e8a, #1d3557, #0d1b2a);
  background-size: 400% 400%;
  animation: gradientShift 18s ease infinite;
}

body.auth-bg .container-fluid {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 2rem 1rem;
  position: relative;
  z-index: 1;
}

body.auth-bg .flex-grow-1 {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Frosted glass card */
.auth-card {
  max-width: 520px;
  width: 100%;
  border-radius: 1.25rem;
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.45);
}

[data-bs-theme="light"] body.auth-bg .auth-card,
body.auth-bg .auth-card {
  background: rgba(255, 255, 255, 0.78) !important;
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
}

[data-bs-theme="dark"] body.auth-bg .auth-card {
  background: rgba(14, 22, 38, 0.72) !important;
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border-color: rgba(100, 140, 220, 0.3);
}

/* Inputs inside auth card — light */
body.auth-bg .auth-card .form-control,
body.auth-bg .auth-card .form-select {
  background-color: rgba(255, 255, 255, 0.60) !important;
  border-color: rgba(100, 130, 200, 0.4) !important;
  color: #1a1a2e !important;
}
body.auth-bg .auth-card .form-control:focus,
body.auth-bg .auth-card .form-select:focus {
  background-color: rgba(255, 255, 255, 0.82) !important;
  border-color: rgba(13, 110, 253, 0.7) !important;
  box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.2) !important;
}

/* Inputs inside auth card — dark */
[data-bs-theme="dark"] body.auth-bg .auth-card .form-control,
[data-bs-theme="dark"] body.auth-bg .auth-card .form-select {
  background-color: rgba(20, 30, 50, 0.80) !important;
  border-color: rgba(100, 140, 220, 0.4) !important;
  color: #c8d4f0 !important;
}
[data-bs-theme="dark"] body.auth-bg .auth-card .form-control:focus,
[data-bs-theme="dark"] body.auth-bg .auth-card .form-select:focus {
  background-color: rgba(30, 45, 75, 0.90) !important;
  border-color: #6699ff !important;
  box-shadow: 0 0 0 0.2rem rgba(80, 120, 255, 0.25) !important;
}
[data-bs-theme="dark"] body.auth-bg .auth-card label,
[data-bs-theme="dark"] body.auth-bg .auth-card .form-label {
  color: #c8d4f0;
}

/* Floating orbs */
body.auth-bg::before,
body.auth-bg::after {
  content: '';
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.18;
  pointer-events: none;
  z-index: 0;
}
body.auth-bg::before {
  width: 500px; height: 500px;
  background: #4fc3f7;
  top: -100px; right: -100px;
  animation: orbFloat 20s ease-in-out infinite alternate;
}
body.auth-bg::after {
  width: 400px; height: 400px;
  background: #43a047;
  bottom: -80px; left: -80px;
  animation: orbFloat 25s ease-in-out infinite alternate-reverse;
}

@keyframes orbFloat {
  0%   { transform: translate(0, 0) scale(1); }
  100% { transform: translate(40px, 30px) scale(1.1); }
}

/* ── Navbar theming ───────────────────────────────────────────────────────── */
[data-bs-theme="light"] .navbar.bg-dark {
  background-color: #1b4332 !important;
}
[data-bs-theme="dark"] .navbar.bg-dark {
  background-color: #0d1f14 !important;
  border-bottom: 2px solid #2d6a4f;
  box-shadow: 0 3px 16px rgba(0,0,0,0.7) !important;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
[data-bs-theme="light"] .btn-dark {
  background-color: #1b4332;
  border-color: #1b4332;
}
[data-bs-theme="light"] .btn-dark:hover {
  background-color: #145228;
  border-color: #145228;
}

/* ── Page animations ──────────────────────────────────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(22px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-18px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.animate-up   { animation: fadeInUp   0.45s ease both; }
.animate-down { animation: fadeInDown 0.40s ease both; }
.animate-fade { animation: fadeIn     0.40s ease both; }

.animate-stagger {
  animation: fadeInUp 0.42s ease both;
  animation-delay: var(--stagger-delay, 0ms);
}

body { transition: opacity 0.2s ease; }
body.page-leaving { opacity: 0; }

@media (prefers-reduced-motion: reduce) {
  .animate-up, .animate-down, .animate-fade,
  .animate-stagger, body { animation: none !important; transition: none !important; }
}

/* ── Cards ────────────────────────────────────────────────────────────────── */
[data-bs-theme="dark"] .card {
  border: 1px solid rgba(255,255,255,0.08) !important;
}

/* ── Form controls ────────────────────────────────────────────────────────── */
[data-bs-theme="light"] .form-control,
[data-bs-theme="light"] .form-select {
  border-color: #93a3c0;
}
[data-bs-theme="light"] .form-control:focus,
[data-bs-theme="light"] .form-select:focus {
  border-color: #1b4332;
  box-shadow: 0 0 0 0.2rem rgba(27,67,50,0.2);
}

/* ── Theme toggle ─────────────────────────────────────────────────────────── */
[data-bs-theme="dark"] #theme-toggle {
  border-color: rgba(255,255,255,0.25);
  color: #52b788;
}
[data-bs-theme="light"] #theme-toggle {
  border-color: rgba(255,255,255,0.25);
  color: #d8f3dc;
}

/* ── Trip cards ───────────────────────────────────────────────────────────── */
.trip-card { transition: transform 0.15s ease, box-shadow 0.15s ease; }
.trip-card:hover { transform: translateY(-2px); box-shadow: 0 6px 24px rgba(0,0,0,.12) !important; }

/* ── Map page (trip_map.html) ─────────────────────────────────────────────── */
body.map-page .container-fluid { padding: 0 !important; }
body.map-page footer { display: none !important; }
body.map-page .flex-grow-1 { padding: 0 !important; }

/* ── Tracking mode ────────────────────────────────────────────────────────── */
body.tracking-mode {
  overflow: hidden;
}
body.tracking-mode > nav,
body.tracking-mode .navbar,
body.tracking-mode .rr-tab-bar {
  display: none !important;
}
body.tracking-mode .container-fluid {
  padding: 0 !important;
  min-height: 100vh !important;
  max-height: 100vh !important;
  overflow: hidden;
}
body.tracking-mode footer  { display: none !important; }
body.tracking-mode .flex-grow-1 { padding: 0 !important; }

#tracking-map {
  position: fixed;
  inset: 0;
  z-index: 1;
}

/* Status bar — compact floating pill (top-left, not full-width) */
.tracking-status-bar {
  position: fixed;
  top: max(10px, env(safe-area-inset-top));
  left: 10px;
  right: auto;
  width: auto;
  z-index: 200;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px 5px 5px;
  background: rgba(15, 20, 25, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #fff;
  border-radius: 28px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.5);
  font-size: 0.8rem;
  white-space: nowrap;
}
.tracking-back-btn {
  background: rgba(255,255,255,0.12);
  border: none;
  color: #fff;
  width: 34px; height: 34px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  cursor: pointer;
  touch-action: manipulation;
}
.tracking-back-btn:hover { background: rgba(255,255,255,0.22); }

.tracking-status-info {
  display: flex;
  flex-direction: row;   /* horizontal: state · time · dist */
  align-items: center;
  gap: 8px;
}
.tracking-state-label {
  font-weight: 700;
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  color: #6b7280;
  text-transform: uppercase;
}
.tracking-stat {
  font-weight: 700;
  font-size: 0.9rem;
  color: #e5e7eb;
}
/* Separator dots between stats */
.tracking-stat + .tracking-stat::before {
  content: '·';
  margin-right: 8px;
  color: #4b5563;
}
.tracking-ride-name { display: none; } /* removed from pill — saves space */

/* Control bar */
.tracking-ctrl-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 100;
  padding: 12px 12px max(12px, env(safe-area-inset-bottom));
  background: rgba(15, 20, 25, 0.90);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.ctrl-group {
  display: flex;
  gap: 10px;
  align-items: stretch;
}
.ctrl-btn {
  flex: 1;
  min-height: 70px;
  border: none;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: filter 0.12s ease, transform 0.08s ease;
  color: #fff;
}
.ctrl-btn i { font-size: 1.6rem; }
.ctrl-btn:active { transform: scale(0.95); filter: brightness(0.85); }
.ctrl-btn:disabled { opacity: 0.5; pointer-events: none; }

.ctrl-start  { background: #16a34a; }
.ctrl-pause  { background: #d97706; }
.ctrl-stop   { background: #dc2626; }
.ctrl-pin    { background: #2563eb; }
.ctrl-resume { background: #16a34a; }
.ctrl-view   { background: #2563eb; }
.ctrl-new-ride { background: #16a34a; }

/* ── Landscape phone — compact tracking UI ─────────────────────────────────── *
 * Portrait buttons (70px tall, icon over label) eat ~40% of a landscape phone.
 * In landscape we shrink everything so the map dominates.                       */
@media (orientation: landscape) and (max-height: 500px) {
  /* Status pill already compact; just tighten the back button in landscape */
  .tracking-back-btn { width: 28px; height: 28px; font-size: 0.85rem; }
  .tracking-stat { font-size: 0.8rem; }
  .tracking-state-label { display: none; } /* drop state label in landscape */

  /* Control bar — much less vertical padding */
  .tracking-ctrl-bar {
    padding: 5px 10px max(5px, env(safe-area-inset-bottom));
  }

  /* Buttons: halved height, icon + label side-by-side instead of stacked */
  .ctrl-btn {
    min-height: 44px;
    flex-direction: row;
    gap: 6px;
    font-size: 0.65rem;
    padding: 0 10px;
    border-radius: 10px;
  }
  .ctrl-btn i { font-size: 1.15rem; }

  /* Idle state: route selector and Start button on one row */
  #ctrl-idle {
    flex-direction: row !important;
    align-items: center !important;
    padding: 2px 0 !important;
    gap: 8px !important;
  }
  #ctrl-idle > div:first-child { flex: 1; min-width: 0; }
  #btn-start { flex: 0 0 auto; padding: 0 14px; }
}

/* Re-center button — shown when auto-follow is off */
#recenter-btn {
  position: fixed;
  right: 14px;
  bottom: 110px; /* above portrait control bar */
  z-index: 200;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.18);
  background: rgba(15, 20, 25, 0.88);
  color: #60a5fa;
  font-size: 1.25rem;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 12px rgba(0,0,0,0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  touch-action: manipulation;
}
#recenter-btn.visible { display: flex; }

@media (orientation: landscape) and (max-height: 500px) {
  #recenter-btn { bottom: 62px; }
}

/* Current position dot */
.current-pos-dot {
  width: 18px; height: 18px;
  background: #2563eb;
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(37,99,235,0.35), 0 2px 8px rgba(0,0,0,.4);
  animation: posPulse 2s ease-in-out infinite;
}
@keyframes posPulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(37,99,235,0.35), 0 2px 8px rgba(0,0,0,.4); }
  50%       { box-shadow: 0 0 0 8px rgba(37,99,235,0.12), 0 2px 8px rgba(0,0,0,.4); }
}

/* Waypoint panel */
.wp-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,0.45);
}
.waypoint-panel {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 201;
  background: var(--bs-body-bg, #fff);
  border-radius: 20px 20px 0 0;
  padding: 16px 20px max(20px, env(safe-area-inset-bottom));
  max-height: 80vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(.32,0,.67,0);
  box-shadow: 0 -4px 30px rgba(0,0,0,.25);
}
.waypoint-panel.open {
  transform: translateY(0);
  transition: transform 0.35s cubic-bezier(.33,1,.68,1);
}
.wp-panel-handle {
  width: 40px; height: 4px;
  background: rgba(128,128,128,.35);
  border-radius: 2px;
  margin: 0 auto 14px;
}
.wp-panel-title {
  font-weight: 700;
  margin-bottom: 16px;
}

/* Category grid */
.wp-category-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 4px;
}
@media (max-width: 400px) {
  .wp-category-grid { grid-template-columns: repeat(3, 1fr); }
}
.wp-cat-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 10px 4px 8px;
  border: 2px solid transparent;
  border-radius: 12px;
  background: var(--bs-secondary-bg, #f3f4f6);
  cursor: pointer;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--bs-body-color);
  transition: border-color 0.12s, background 0.12s;
  min-height: 64px;
}
.wp-cat-btn span { display: block; text-align: center; line-height: 1.2; }
.wp-cat-btn > :first-child { font-size: 1.4rem; }
.wp-cat-btn.selected {
  border-color: #2563eb;
  background: rgba(37, 99, 235, 0.1);
  color: #2563eb;
}
.wp-cat-transient.selected {
  border-color: #d97706;
  background: rgba(217, 119, 6, 0.1);
  color: #d97706;
}
.wp-cat-btn:active { transform: scale(0.93); }

/* ── Route Planner ─────────────────────────────────────────────────────────── */
body.planner-page .container-fluid { padding: 0 !important; }
body.planner-page footer { display: none !important; }
body.planner-page .flex-grow-1 { padding: 0 !important; }

.planner-layout {
  display: flex;
  height: calc(100vh - 56px);
  overflow: hidden;
}

.planner-sidebar {
  width: 340px;
  flex-shrink: 0;
  overflow-y: auto;
  background: var(--bs-body-bg);
  border-right: 1px solid var(--bs-border-color);
  display: flex;
  flex-direction: column;
}

#planner-map {
  flex: 1;
  min-width: 0;
}

.planner-sidebar-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bs-body-bg);
  border-bottom: 1px solid var(--bs-border-color);
}

/* Waypoint markers on the map */
.planner-wp-marker {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 0.8rem;
  border: 2px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

/* Small colored badge in the sidebar list */
.planner-wp-badge {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 0.65rem;
  flex-shrink: 0;
}

.planner-point-item {
  background: var(--bs-tertiary-bg, #f8f9fa);
  border-radius: 8px;
  padding: 6px 8px;
}
[data-bs-theme="dark"] .planner-point-item {
  background: rgba(255, 255, 255, 0.06);
}

.planner-step-num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  background: var(--bs-secondary-bg);
  border-radius: 50%;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--bs-body-color);
  flex-shrink: 0;
}

/* Map mode-hint pill (rendered as a Leaflet bottomleft control) */
.planner-mode-hint {
  background: rgba(15, 108, 189, 0.92);
  color: #fff;
  padding: 7px 14px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  pointer-events: none;
  white-space: nowrap;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  letter-spacing: 0.01em;
}

/* Mobile: stack map on top, sidebar below */
@media (max-width: 991.98px) {
  .planner-layout {
    flex-direction: column;
    height: auto;
  }
  #planner-map {
    height: 55vh;
    flex-shrink: 0;
  }
  .planner-sidebar {
    width: 100%;
    height: 45vh;
    border-right: none;
    border-top: 1px solid var(--bs-border-color);
  }
}

/* ── Bottom tab bar ────────────────────────────────────────────────────────── */
.rr-tab-bar {
  display: none; /* only shown on mobile */
}

@media (max-width: 767.98px) {
  .rr-tab-bar {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 60px;
    background: #1a1a2e;
    border-top: 1px solid rgba(255,255,255,0.1);
    z-index: 1030;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.25);
  }
  /* Extra bottom padding so content doesn't hide behind tab bar */
  body:not(.tracking-mode):not(.planner-page) .container-fluid {
    padding-bottom: 70px !important;
  }
}

.rr-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: rgba(255,255,255,0.55);
  text-decoration: none;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: color 0.15s;
  touch-action: manipulation; /* eliminates 300ms iOS tap delay */
  -webkit-tap-highlight-color: transparent;
}
.rr-tab i { font-size: 1.2rem; }
.rr-tab.active { color: #4ade80; }
/* hover only on real pointer devices — iOS keeps :hover sticky after tap */
@media (hover: hover) and (pointer: fine) {
  .rr-tab:hover { color: #4ade80; }
}

/* ── Home screen ────────────────────────────────────────────────────────────── */
.rr-ride-now-btn {
  background: #2d6a4f;
  color: #fff;
  font-size: 1.25rem;
  font-weight: 700;
  padding: 1.1rem;
  border-radius: 16px;
  border: none;
  box-shadow: 0 4px 20px rgba(45,106,79,0.4);
  letter-spacing: 0.02em;
}
.rr-ride-now-btn:hover, .rr-ride-now-btn:focus { background: #1b4332; color: #fff; }

/* ── Ride Now flow ───────────────────────────────────────────────────────────── */
.rr-mode-card {
  background: var(--bs-body-bg);
  border: 2px solid var(--bs-border-color);
  border-radius: 14px;
  padding: 1rem 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--bs-body-color);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  min-height: 90px;
}
.rr-mode-card:hover { border-color: #2d6a4f; }
.rr-mode-card.active {
  border-color: #2d6a4f;
  background: rgba(45,106,79,0.08);
  color: #2d6a4f;
}
[data-bs-theme="dark"] .rr-mode-card.active {
  background: rgba(74,222,128,0.1);
  color: #4ade80;
  border-color: #4ade80;
}
.rr-lets-ride-btn {
  background: #2d6a4f;
  color: #fff;
  font-size: 1.1rem;
  font-weight: 700;
  padding: 1rem;
  border-radius: 14px;
  border: none;
  min-height: 56px;
  box-shadow: 0 4px 16px rgba(45,106,79,0.35);
}
.rr-lets-ride-btn:hover { background: #1b4332; color: #fff; }
.rr-lets-ride-btn:disabled { background: #6c757d; box-shadow: none; }
