/* ========================================
   HISTORY.CSS — Ride History Page
   Mobile-first + Desktop responsive
   2-col list / 2→4 col grid
   ======================================== */

/* ── Header Banner ── */
.history-header-wrap {
  background: linear-gradient(135deg, #123068 0%, #194390 60%, #163a7d 100%);
  padding: 28px 20px 32px;
  position: relative;
  overflow: hidden;
}
.history-header-wrap::before {
  content: '';
  position: absolute;
  width: 260px; height: 260px;
  background: radial-gradient(circle, rgba(215,156,31,0.22), transparent 70%);
  top: -100px; right: -60px;
  pointer-events: none;
}
.history-header-wrap::after {
  content: '';
  position: absolute;
  width: 180px; height: 180px;
  background: radial-gradient(circle, rgba(222,171,62,0.12), transparent 70%);
  bottom: -60px; left: -40px;
  pointer-events: none;
}
.history-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
}
.history-page-title {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 800;
  color: #ffffff;
  line-height: 1.1;
  letter-spacing: -0.3px;
  text-shadow: 0 2px 12px rgba(0,0,0,0.3);
}
.history-page-sub {
  font-size: 0.82rem;
  color: rgba(255,255,255,0.60);
  margin-top: 5px;
  font-weight: 500;
}

/* ── Stat Cards ── */
.stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}
.stat-card {
  background: rgba(255,255,255,0.09);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 16px;
  padding: 16px 10px;
  text-align: center;
  backdrop-filter: blur(12px);
  transition: all 0.25s;
}
.stat-card:active { transform: scale(0.96); }
.stat-icon { font-size: 1.25rem; margin-bottom: 8px; }
.stat-num {
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 800;
  color: #ffffff;
  line-height: 1;
}
.stat-label {
  font-size: 0.6rem;
  font-weight: 700;
  color: rgba(255,255,255,0.50);
  letter-spacing: 0.8px;
  text-transform: uppercase;
  margin-top: 5px;
}
.stat-card.active-card {
  background: rgba(215,156,31,0.22);
  border-color: rgba(215,156,31,0.40);
  box-shadow: 0 4px 20px rgba(215,156,31,0.18);
}
.stat-card.active-card .stat-num   { color: #E8BB5B; }
.stat-card.active-card .stat-label { color: rgba(232,187,91,0.70); }

/* ── Filter Bar ── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px 10px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  background: var(--bg);
}
.filter-bar::-webkit-scrollbar { display: none; }
.filter-chip {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 15px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  border: 1.5px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  font-family: var(--font-body);
}
.filter-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 4px 14px rgba(215,156,31,0.32);
}

/* ── Month Label ── */
.month-label {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--text-muted);
  letter-spacing: 1.2px;
  text-transform: uppercase;
  padding: 16px 16px 8px;
  font-family: var(--font-display);
}

/* ════════════════════════════════
   LIST VIEW — 2 cards per row
   ════════════════════════════════ */
.rides-list-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 0 12px;
}
@media (min-width: 480px) {
  .rides-list-grid { padding: 0 16px; gap: 12px; }
}
@media (min-width: 768px) {
  .rides-list-grid { grid-template-columns: repeat(4, 1fr); gap: 14px; }
}

/* ── Ride Card (list view) ── */
.ride-card {
  background: var(--bg-card);
  border-radius: 16px;
  border: 1.5px solid var(--border);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  position: relative;
}
.ride-card:active  { transform: scale(0.97); box-shadow: none; }
.ride-card:hover   { box-shadow: 0 8px 24px rgba(13,36,76,0.12); border-color: var(--primary); transform: translateY(-2px); }

/* Top color banner */
.ride-card-banner {
  height: 3px; width: 100%; flex-shrink: 0;
}
.active    { background: linear-gradient(90deg, #91712d, #775c20); }
.confirmed { background: linear-gradient(90deg, #deab3e, #b5892a); }
.pending   { background: linear-gradient(90deg, #cb9521, #b18420); }
.completed { background: linear-gradient(90deg, #b8903a, #91712d); }
.cancelled { background: linear-gradient(90deg, #515763, #183f88); }

.ride-card-top {
  display: flex;
  flex-direction: column;
  padding: 10px 10px 0;
  gap: 8px;
}
.ride-vehicle-img {
  width: 100%; height: 110px;
  border-radius: 10px;
  object-fit: contain;
  object-position: center;
  background: var(--bg);
  flex-shrink: 0;
}
.ride-vehicle-img-placeholder {
  width: 100%; height: 80px;
  border-radius: 10px;
  background: linear-gradient(135deg, #f3f3f3, #ececec);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem;
}
.ride-info { flex: 1; min-width: 0; }
.ride-vehicle-name {
  font-family: var(--font-display);
  font-size: 0.88rem; font-weight: 800;
  color: var(--text-main);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 3px;
}
.ride-date-line {
  font-size: 0.68rem; color: var(--text-muted);
  display: flex; align-items: center; gap: 3px;
  font-weight: 600;
}
.ride-dur-line {
  font-size: 0.66rem; color: var(--text-muted);
  font-weight: 600; margin-top: 2px;
}
.ride-amount-col {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 0 4px;
}
.ride-amount {
  font-family: var(--font-display);
  font-size: 1rem; font-weight: 900;
  color: var(--primary);
}
.ride-status-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 10px;
  border-top: 1px solid var(--border);
  background: #fafafa;
  margin-top: auto;
}
.ride-id-text { font-size: 0.6rem; color: var(--text-light); font-weight: 700; letter-spacing: 0.5px; font-family: monospace; }
.ride-view-btn { font-size: 0.65rem; font-weight: 800; color: var(--primary); }

/* ════════════════════════════════
   GRID VIEW — 2→3→4 per row
   ════════════════════════════════ */
.rides-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 0 12px;
}
@media (min-width: 480px) { .rides-grid { grid-template-columns: repeat(3, 1fr); gap: 12px; padding: 0 16px; } }
@media (min-width: 768px) { .rides-grid { grid-template-columns: repeat(4, 1fr); gap: 14px; } }

.ride-grid-card {
  background: var(--bg-card);
  border-radius: 16px;
  border: 1.5px solid var(--border);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  display: flex; flex-direction: column;
}
.ride-grid-card:active { transform: scale(0.97); box-shadow: none; }
.ride-grid-card:hover  { box-shadow: 0 8px 24px rgba(13,36,76,0.12); border-color: var(--primary); transform: translateY(-2px); }

/* Top colored banner */
.rgc-banner-top { height: 3px; width: 100%; flex-shrink: 0; }

.rgc-img {
  width: 100%; height: 90px; object-fit: cover;
  background: var(--bg); display: block;
}
.rgc-img-ph {
  width: 100%; height: 90px;
  background: linear-gradient(135deg, #f3f3f3, #ececec);
  display: flex; align-items: center; justify-content: center; font-size: 2rem;
}
.rgc-body { padding: 10px; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.rgc-name {
  font-family: var(--font-display); font-size: 0.88rem; font-weight: 800;
  color: var(--text-main); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rgc-meta-row { display: flex; flex-direction: column; gap: 2px; }
.rgc-date { font-size: 0.64rem; color: var(--text-muted); font-weight: 600; }
.rgc-dur  { font-size: 0.62rem; color: var(--text-muted); font-weight: 600; }
.rgc-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 6px; border-top: 1px solid var(--border); margin-top: auto;
}
.rgc-amount {
  font-family: var(--font-display); font-size: 0.95rem; font-weight: 900;
  color: var(--primary);
}

/* ── Status Pills ── */
.status-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 999px;
  font-size: 0.62rem; font-weight: 800; letter-spacing: 0.2px;
  white-space: nowrap;
}
.status-pill .dot { width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0; }
.pill-active    { background: #f8f0e0; color: #5e491c; }
.pill-active .dot    { background: #91712d; animation: blink 1.2s ease-in-out infinite; }
.pill-confirmed { background: #ececec; color: #9e7a2b; }
.pill-confirmed .dot { background: #d39c27; }
.pill-pending   { background: #eccb85; color: #745616; }
.pill-pending .dot   { background: #a97d1e; }
.pill-completed { background: #fbf8f2; color: #4b3b1a; }
.pill-completed .dot { background: #b8903a; }
.pill-cancelled { background: #f0f0f0; color: #112c60; }
.pill-cancelled .dot { background: #515763; }
@keyframes blink {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(1.5); }
}

/* ── Shimmer ── */
.shimmer-card {
  margin: 0 12px 12px; border-radius: var(--radius);
  overflow: hidden; border: 1.5px solid var(--border); background: var(--bg-card);
}
@media (min-width: 480px) { .shimmer-card { margin: 0 16px 12px; } }
.shimmer-top    { display: flex; gap: 12px; padding: 14px; align-items: center; }
.shimmer-img    { width: 72px; height: 54px; border-radius: var(--radius-sm); flex-shrink: 0; }
.shimmer-lines  { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.shimmer-line   { height: 12px; border-radius: 6px; }
.shimmer-line.w60 { width: 60%; }
.shimmer-line.w40 { width: 40%; }
.shimmer-bottom { height: 36px; }
.skeleton { background: linear-gradient(90deg, #f3f3f3 25%, #ececec 50%, #f3f3f3 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ── Empty State ── */
.history-empty { text-align: center; padding: 64px 24px; color: var(--text-muted); }
.history-empty-icon { font-size: 3.5rem; margin-bottom: 16px; opacity: 0.4; }
.history-empty h3 { font-size: 1.05rem; color: var(--text-main); margin-bottom: 8px; font-family: var(--font-display); }
.history-empty p  { font-size: 0.85rem; }

/* ── Refresh Button ── */
.refresh-btn {
  background: rgba(255,255,255,0.12);
  border: 1.5px solid rgba(255,255,255,0.20);
  border-radius: 50%; width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: #fff; transition: all 0.22s; flex-shrink: 0;
}
.refresh-btn:active { transform: rotate(180deg) scale(0.9); }
.refresh-btn svg    { width: 18px; height: 18px; }
.refresh-btn.spinning { animation: spin360 0.6s ease; }
@keyframes spin360 { to { transform: rotate(360deg); } }

/* ── Scroll to Top ── */
#scroll-top-btn {
  position: fixed; bottom: 90px; right: 16px;
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-primary); cursor: pointer; border: none;
  transition: all 0.25s; opacity: 0; pointer-events: none; z-index: 500;
}
#scroll-top-btn.visible { opacity: 1; pointer-events: auto; }
#scroll-top-btn:active  { transform: scale(0.92); }

/* ── Calendar Header Button ── */
.cal-header-btn {
  width: 38px; height: 38px; border-radius: 10px;
  background: rgba(13,36,76,0.06); border: 1px solid rgba(13,36,76,0.15);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: #0d244c; position: relative; transition: background 0.18s;
  flex-shrink: 0;
}
.cal-header-btn:active { background: rgba(13,36,76,0.14); }
.cal-header-btn .cal-dot {
  position: absolute; top: 5px; right: 5px; width: 7px; height: 7px;
  border-radius: 50%; background: #B7851A; display: none;
}

/* ── Calendar Dropdown ── */
.cal-dropdown {
  display: none; position: fixed; top: 68px; right: 16px;
  width: min(320px, calc(100vw - 32px)); background: #fff;
  border-radius: 18px; box-shadow: 0 8px 40px rgba(13,36,76,0.22);
  border: 1px solid var(--border); z-index: 9999; overflow: hidden;
  animation: calDrop 0.2s cubic-bezier(0.34,1.3,0.64,1);
}
.cal-dropdown.open { display: block; }
@keyframes calDrop { from{opacity:0;transform:translateY(-10px) scale(0.97);}to{opacity:1;transform:translateY(0) scale(1);} }
.cal-drop-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 10px; border-bottom: 1px solid var(--border);
}
.cal-drop-title { font-family: var(--font-display); font-size: 0.95rem; font-weight: 800; color: var(--text-main); }
.cal-nav-row { display: flex; align-items: center; gap: 6px; }
.cal-nav-btn {
  width: 30px; height: 30px; border-radius: 50%; background: var(--bg);
  border: 1px solid var(--border); display: flex; align-items: center;
  justify-content: center; cursor: pointer; color: var(--text-main);
}
.cal-nav-btn:active { background: var(--primary-light); }
.cal-drop-grid { display: grid; grid-template-columns: repeat(7,1fr); gap: 2px; padding: 10px 12px 4px; }
.cal-lbl { text-align: center; font-size: 0.62rem; font-weight: 700; color: var(--text-muted); font-family: var(--font-display); text-transform: uppercase; padding-bottom: 6px; }
.cal-cell {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  border-radius: 8px; font-size: 0.78rem; font-weight: 500;
  color: var(--text-main); cursor: pointer; transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.cal-cell:active:not(.cal-empty) { transform: scale(0.88); }
.cal-cell.cal-empty { cursor: default; pointer-events: none; }
.cal-cell:hover:not(.cal-empty):not(.cal-today):not(.cal-sel) { background: var(--primary-light, #fcf7eb); }
.cal-cell.cal-today { background: var(--primary); color: #fff; font-weight: 800; border-radius: 50%; }
.cal-cell.cal-sel:not(.cal-today) { background: #61512e; color: #fff; font-weight: 700; border-radius: 50%; }
.cal-cell.cal-has-b { position: relative; font-weight: 800; color: var(--primary); }
.cal-cell.cal-has-b::after { content: ''; width: 4px; height: 4px; border-radius: 50%; background: var(--primary); position: absolute; bottom: 1px; left: 50%; transform: translateX(-50%); }
.cal-cell.cal-today.cal-has-b, .cal-cell.cal-sel.cal-has-b { color: #fff; }
.cal-cell.cal-today.cal-has-b::after, .cal-cell.cal-sel.cal-has-b::after { background: rgba(255,255,255,0.75); }
.cal-drop-footer { padding: 8px 12px 12px; display: flex; gap: 8px; }
.cal-clear-btn { flex: 1; padding: 9px; border-radius: 10px; background: var(--bg); border: 1px solid var(--border); font-size: 0.8rem; font-weight: 700; color: var(--text-muted); cursor: pointer; font-family: var(--font-body); }
.cal-apply-btn { flex: 2; padding: 9px; border-radius: 10px; background: var(--primary); border: none; font-size: 0.8rem; font-weight: 700; color: #fff; cursor: pointer; font-family: var(--font-body); }

/* ── Date Strip ── */
.date-strip {
  display: none; align-items: center; justify-content: space-between;
  background: #fdf9f0; border: 1px solid rgba(215,156,31,0.2);
  border-radius: 10px; padding: 8px 12px; margin: 4px 16px 0;
  font-size: 0.8rem; font-weight: 600; color: var(--primary);
}
.date-strip.show { display: flex; }
.date-strip-clear {
  background: none; border: none; font-size: 0.75rem; font-weight: 700;
  color: var(--primary); cursor: pointer; font-family: var(--font-body); text-decoration: underline;
}

/* ── Toolbar ── */
.history-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px 2px;
}
.result-count-text { font-size: 0.75rem; color: var(--text-muted); font-weight: 600; }
.view-toggle-wrap { display: flex; gap: 4px; align-items: center; }
.vt-btn {
  width: 32px; height: 28px; border-radius: 7px; border: 1.5px solid var(--border);
  background: var(--bg-card); cursor: pointer; color: var(--text-muted);
  display: flex; align-items: center; justify-content: center; transition: all 0.18s;
}
.vt-btn svg { width: 15px; height: 15px; }
.vt-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ══════════════════════════════════════
   DETAIL OVERLAY — Full screen slide-up
══════════════════════════════════════ */
.detail-overlay {
  position: fixed; inset: 0; z-index: 9000;
  background: var(--bg);
  transform: translateY(100%);
  transition: transform 0.38s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.detail-overlay.open { transform: translateY(0); }
.detail-overlay-topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(135deg, #123068 0%, #194390 100%);
  padding: 0 16px; height: 60px;
  box-shadow: 0 2px 16px rgba(0,0,0,0.18);
}
.detail-back-btn {
  background: rgba(255,255,255,0.10); border: 1.5px solid rgba(255,255,255,0.18);
  border-radius: 50%; width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: #fff; transition: all 0.2s; flex-shrink: 0;
}
.detail-back-btn:active { transform: scale(0.92); }
.detail-overlay-title {
  font-family: var(--font-display); font-size: 1rem; font-weight: 800;
  color: #fff; letter-spacing: 0.2px;
}
.detail-overlay .page-content {
  padding: 16px 14px 100px; max-width: 600px; margin: 0 auto;
}
@media (min-width: 480px) { .detail-overlay .page-content { padding: 20px 20px 100px; } }

/* ── Bottom Padding ── */
#rides-container, #empty-state, #loading-state { padding-bottom: 100px; }

/* ── Desktop ── */
@media (min-width: 768px) {
  .history-page-title { font-size: 2rem; }
  .detail-overlay-topbar { height: 68px; padding: 0 28px; }
  .detail-overlay-title  { font-size: 1.1rem; }
}