/* ============ iOS NATIVE STYLE ============ */
:root {
  --bg: #ffffff;
  --card: #ffffff;
  --text: #000000;
  --text-secondary: #8e8e93;
  --blue: #007aff;
  --green: #34c759;
  --orange: #ff9500;
  --red: #ff3b30;
  --separator: rgba(60, 60, 67, 0.12);
  --map-placeholder: #f5f5f7;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  overscroll-behavior-y: contain;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro Display', sans-serif;
  min-height: 100vh;
  padding: 0;
  color: var(--text);
  background: var(--bg);
}

.container {
  max-width: 600px;
  margin: 0 auto;
  padding: 0 16px;
}

.hidden {
  display: none !important;
}

/* ============ LOGIN ============ */
#loginSection {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.login-header {
  padding: 60px 24px 40px;
  text-align: center;
  background: var(--bg);
}

.login-header h1 {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
  color: var(--blue);
}

.login-header p {
  color: var(--text-secondary);
  font-size: 17px;
  font-weight: 400;
}

.login-form {
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0;
  background: var(--card);
  border: 1px solid var(--separator);
  border-radius: 12px;
  overflow: hidden;
}

.form-group label {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-secondary);
  padding: 12px 16px 0;
}

.form-group input {
  background: var(--card);
  border: none;
  padding: 8px 16px 12px;
  font-size: 17px;
  font-weight: 400;
  color: var(--text);
}

.form-group input:focus {
  outline: none;
}

.form-group input::placeholder {
  color: var(--text-secondary);
}

.btn {
  background: var(--blue);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 16px 24px;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
  margin-top: 8px;
}

.btn:hover {
  opacity: 0.9;
}

.btn:active {
  opacity: 0.7;
}

.status {
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 500;
  text-align: center;
}

.status.error {
  background: rgba(255, 59, 48, 0.12);
  color: var(--red);
}

/* ============ TRIPS ============ */
#tripsSection {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.trips-header {
  padding: 60px 20px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg);
}

.trips-header h1 {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--blue);
}

.refresh-btn {
  background: transparent;
  border: none;
  color: var(--blue);
  width: 44px;
  height: 44px;
  border-radius: 22px;
  font-size: 24px;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.refresh-btn:hover {
  background: rgba(0, 122, 255, 0.1);
}

.refresh-btn:active {
  background: rgba(0, 122, 255, 0.2);
}

.refresh-btn:disabled {
  opacity: 0.4;
}

.refresh-btn.spinning {
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============ TRIP CARD ============ */
.trips-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 0 0 24px;
}

.trip-card {
  border-radius: 12px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: transform 0.2s, box-shadow 0.2s;
  background: var(--card);
  border: 1px solid var(--separator);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  cursor: pointer;
}

.trip-card:active {
  transform: scale(0.98);
}

.trip-card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.trip-card:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

/* Map + Time hero section */
.trip-hero {
  position: relative;
  height: 180px;
  overflow: hidden;
}

.trip-map-section {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--map-placeholder);
  z-index: 0;
}

.trip-map-section .trip-map {
  width: 100%;
  height: 100%;
}

/* Hide Google Maps controls and logo */
.trip-map .gm-style-cc,
.trip-map .gmnoprint,
.trip-map a[href^="https://maps.google.com"] {
  display: none !important;
}

/* Gradient overlay for readability */
.trip-hero::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.5) 0%,
    rgba(0, 0, 0, 0.2) 50%,
    rgba(0, 0, 0, 0) 100%
  );
  pointer-events: none;
  z-index: 1;
}

/* Trip card colors */
.trip-card.color-0 .trip-hero::after { background: linear-gradient(to bottom, rgba(0, 122, 255, 0.75) 0%, rgba(0, 122, 255, 0.4) 50%, rgba(0, 122, 255, 0) 100%); }
.trip-card.color-1 .trip-hero::after { background: linear-gradient(to bottom, rgba(52, 199, 89, 0.75) 0%, rgba(52, 199, 89, 0.4) 50%, rgba(52, 199, 89, 0) 100%); }
.trip-card.color-2 .trip-hero::after { background: linear-gradient(to bottom, rgba(255, 149, 0, 0.75) 0%, rgba(255, 149, 0, 0.4) 50%, rgba(255, 149, 0, 0) 100%); }
.trip-card.color-3 .trip-hero::after { background: linear-gradient(to bottom, rgba(175, 82, 222, 0.75) 0%, rgba(175, 82, 222, 0.4) 50%, rgba(175, 82, 222, 0) 100%); }
.trip-card.color-4 .trip-hero::after { background: linear-gradient(to bottom, rgba(255, 45, 85, 0.75) 0%, rgba(255, 45, 85, 0.4) 50%, rgba(255, 45, 85, 0) 100%); }
.trip-card.color-5 .trip-hero::after { background: linear-gradient(to bottom, rgba(88, 86, 214, 0.75) 0%, rgba(88, 86, 214, 0.4) 50%, rgba(88, 86, 214, 0) 100%); }

/* Time section - overlaid on map */
.trip-time-section {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 16px 16px 14px;
  color: white;
  z-index: 2;
}

.trip-day {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,0.95);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.trip-time {
  font-size: 52px;
  font-weight: 700;
  letter-spacing: -1px;
  line-height: 1;
  color: white;
  text-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* Route section */
.trip-route-section {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 0;
  background: var(--card);
}

.route-point {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
}

.route-point:first-child {
  border-bottom: 1px solid var(--separator);
}

.route-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.route-icon.from {
  background: rgba(52, 199, 89, 0.2);
}

.route-icon.to {
  background: rgba(255, 149, 0, 0.2);
}

.route-text {
  flex: 1;
  min-width: 0;
}

.route-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

.route-address {
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.3;
}

.route-connector {
  display: none;
}

/* Info section (countdown + duration) */
.trip-info-section {
  padding: 12px 16px;
  display: flex;
  gap: 16px;
  background: var(--card);
  border-top: 1px solid var(--separator);
}

.info-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.info-item:first-child {
  border-right: 1px solid var(--separator);
  padding-right: 16px;
}

.info-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.info-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--blue);
}

.info-value.countdown {
  color: var(--green);
}

.info-value.countdown.urgent {
  color: var(--orange);
}

.info-value.countdown.imminent {
  color: var(--red);
}

/* Contact info section */
.trip-contact-section {
  padding: 12px 16px;
  display: flex;
  gap: 16px;
  background: var(--card);
  border-top: 1px solid var(--separator);
}

.contact-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.contact-item:first-child {
  border-right: 1px solid var(--separator);
  padding-right: 16px;
}

.contact-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.contact-value {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

/* ============ EMPTY STATE ============ */
.empty-state {
  padding: 60px 24px;
  text-align: center;
  background: var(--card);
  border-radius: 16px;
  margin: 0 16px;
}

.empty-state .icon {
  font-size: 56px;
  margin-bottom: 16px;
}

.empty-state h3 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

.empty-state p {
  color: var(--text-secondary);
  font-size: 15px;
}

/* ============ LOADING ============ */
.loading {
  padding: 60px;
  text-align: center;
  background: var(--card);
  border-radius: 16px;
  margin: 0 16px;
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--separator);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

.loading p {
  font-size: 15px;
  color: var(--text-secondary);
}

.last-updated {
  text-align: center;
  font-size: 13px;
  color: var(--text-secondary);
  padding: 12px 16px 24px;
}

/* ============ PULL TO REFRESH ============ */
.pull-indicator {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%) translateY(-100%);
  background: var(--blue);
  color: white;
  padding: 12px 24px;
  border-radius: 0 0 16px 16px;
  font-size: 14px;
  font-weight: 600;
  z-index: 1000;
  transition: transform 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.pull-indicator.visible {
  transform: translateX(-50%) translateY(0);
}

.pull-indicator.releasing {
  background: var(--green);
}

.pull-indicator .spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ============ SKELETON LOADING ============ */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton {
  background: linear-gradient(
    90deg,
    var(--separator) 25%,
    var(--map-placeholder) 50%,
    var(--separator) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 8px;
}

.skeleton-card {
  border-radius: 12px;
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--separator);
}

.skeleton-hero {
  height: 180px;
  background: var(--map-placeholder);
  position: relative;
}

.skeleton-hero::after {
  content: '';
  position: absolute;
  top: 16px;
  left: 16px;
  width: 120px;
  height: 52px;
  background: rgba(255,255,255,0.2);
  border-radius: 8px;
}

.skeleton-content {
  padding: 16px;
}

.skeleton-line {
  height: 16px;
  margin-bottom: 12px;
}

.skeleton-line.short {
  width: 60%;
}

.skeleton-line.medium {
  width: 80%;
}

.skeleton-info {
  display: flex;
  gap: 16px;
  padding: 12px 16px;
  border-top: 1px solid var(--separator);
}

.skeleton-info-item {
  flex: 1;
}

.skeleton-label {
  height: 12px;
  width: 60px;
  margin-bottom: 6px;
}

.skeleton-value {
  height: 18px;
  width: 80px;
}

/* ============ FULLSCREEN MAP OVERLAY ============ */
.fullscreen-map-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: white;
  z-index: 2000;
  display: none;
  flex-direction: column;
}

.fullscreen-map-overlay.visible {
  display: flex;
}

.fullscreen-map-header {
  display: flex;
  align-items: center;
  padding: 16px;
  padding-top: env(safe-area-inset-top, 16px);
  background: white;
  border-bottom: 1px solid var(--separator);
  gap: 12px;
}

.fullscreen-map-close {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--map-placeholder);
  border: none;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.fullscreen-map-info {
  flex: 1;
  min-width: 0;
}

.fullscreen-map-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fullscreen-map-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fullscreen-map-container {
  flex: 1;
  position: relative;
}

.fullscreen-map-container #fullscreenMap {
  width: 100%;
  height: 100%;
}

/* ============ TABS ============ */
.tabs {
  display: flex;
  background: var(--map-placeholder);
  border-radius: 8px;
  padding: 2px;
  margin-bottom: 16px;
}

.tab {
  flex: 1;
  padding: 10px 16px;
  border: none;
  background: transparent;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.tab.active {
  background: white;
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* ============ HISTORY CARDS ============ */
.trip-card.history {
  opacity: 0.7;
}

.trip-card.history .trip-hero {
  filter: grayscale(50%);
}

.trip-card.history .trip-time-section {
  background: rgba(142, 142, 147, 0.9);
}
