/*


 */

/* ===== CSS Variables / Theme ===== */
:root {
  --primary: #89CFF0;
  --primary-dark: #5fb3e6;
  --highlight: #77DD77;
  --highlight-dark: #55bb55;
  --accent: #FFB7C5;
  --accent-dark: #ff8fa5;
  --bg: #F0F8FF;
  --bg-white: #FFFFFF;
  --text: #2F4F4F;
  --text-light: #5a7a7a;
  --shadow: rgba(0,0,0,0.1);
  --radius: 12px;
}

/* ===== Reset & Base ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100%;
  overflow: hidden;
}

/* ===== Menu Overlay ===== */
.menu-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 9999;
  justify-content: center;
  align-items: center;
}

.menu-overlay.active {
  display: flex;
}

.menu-panel {
  background: var(--bg-white);
  border-radius: var(--radius);
  padding: 24px;
  width: 90%;
  max-width: 320px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.menu-panel h2 {
  font-size: 20px;
  margin-bottom: 16px;
  color: var(--text);
  text-align: center;
}

.menu-link {
  display: block;
  padding: 14px 16px;
  margin-bottom: 8px;
  background: var(--primary);
  color: white;
  text-decoration: none;
  border-radius: 8px;
  text-align: center;
  font-weight: 600;
  font-size: 16px;
  transition: background 0.2s;
}

.menu-link:hover { background: var(--primary-dark); }
.menu-link.green { background: var(--highlight); color: var(--text); }
.menu-link.green:hover { background: var(--highlight-dark); }
.menu-link.pink { background: var(--accent); color: var(--text); }
.menu-link.pink:hover { background: var(--accent-dark); }

.menu-close {
  display: block;
  margin-top: 12px;
  padding: 10px;
  text-align: center;
  color: var(--text-light);
  cursor: pointer;
  font-size: 14px;
}

/* ===== Sell Page ===== */
.sell-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  background: var(--bg);
}

.sell-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--primary);
  color: white;
  min-height: 56px;
  flex-shrink: 0;
}

.sell-daily-total {
  font-size: 20px;
  font-weight: 700;
}

.sell-history {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  flex: 1;
  margin: 0 12px;
  align-items: center;
}

.sell-history-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(255,255,255,0.2);
  border-radius: 8px;
  padding: 4px 8px;
  min-width: 48px;
  cursor: pointer;
  text-decoration: none;
  color: white;
}

.sell-history-item .amount {
  font-size: 11px;
  font-weight: 600;
}

.sell-menu-btn {
  background: none;
  border: 2px solid white;
  color: white;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.sell-product-grid {
  flex: 1;
  overflow: hidden;
  padding: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-content: stretch;
}

.product-tile {
  position: relative;
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: 0 2px 8px var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 8px;
  cursor: pointer;
  user-select: none;
  transition: transform 0.1s, box-shadow 0.1s;
  overflow: hidden;
  flex: 1 0 0;
  min-width: 0;
}

.product-tile:active {
  transform: scale(0.95);
  box-shadow: 0 1px 4px var(--shadow);
}

.product-tile.selected {
  border: 3px solid var(--highlight);
}

.product-tile .product-emoji {
  font-size: 36px;
  margin-bottom: 4px;
}

.product-tile .product-name {
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  color: var(--text);
  line-height: 1.2;
}

.product-tile .product-price {
  position: absolute;
  top: 6px;
  right: 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--highlight-dark);
}

.product-tile .qty-badge {
  position: absolute;
  top: -4px;
  left: -4px;
  background: var(--accent);
  color: var(--text);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  box-shadow: 0 2px 4px var(--shadow);
}

.sell-bottom {
  flex-shrink: 0;
  background: var(--bg-white);
  border-top: 2px solid var(--primary);
  padding: 8px 12px;
}

.sell-running-total {
  text-align: center;
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  padding: 4px 0;
}

.sell-denominations {
  display: flex;
  gap: 6px;
  margin: 8px 0;
  flex-wrap: wrap;
  justify-content: center;
}

.denom-btn {
  padding: 10px 14px;
  border: 2px solid var(--primary);
  background: var(--bg);
  color: var(--text);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.denom-btn:active, .denom-btn.active {
  background: var(--primary);
  color: white;
}

.card-btn {
  padding: 10px 14px;
  border: 2px solid var(--primary-dark);
  background: var(--primary-dark);
  color: white;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.card-btn.active {
  background: var(--highlight);
  border-color: var(--highlight);
  color: var(--text);
}

.sell-change {
  text-align: center;
  font-size: 18px;
  font-weight: 600;
  color: var(--highlight-dark);
  min-height: 24px;
  padding: 2px 0;
}

.card-input-row {
  display: none;
  justify-content: center;
  gap: 8px;
  margin: 4px 0;
  align-items: center;
}

.card-input-row.active {
  display: flex;
}

.card-input-row input {
  width: 80px;
  padding: 8px;
  border: 2px solid var(--primary);
  border-radius: 8px;
  font-size: 16px;
  text-align: center;
}

.sell-complete-btn {
  display: block;
  width: 100%;
  padding: 14px;
  background: var(--highlight);
  color: var(--text);
  border: none;
  border-radius: var(--radius);
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 4px;
}

.sell-complete-btn:active {
  background: var(--highlight-dark);
}

.sell-complete-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
}

/* ===== Map Page ===== */
.map-page {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

.map-alert-banner {
  display: none;
  padding: 10px 16px;
  background: var(--accent);
  color: var(--text);
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  flex-shrink: 0;
  animation: pulse-bg 2s infinite;
}

.map-alert-banner.active {
  display: block;
}

@keyframes pulse-bg {
  0%, 100% { background: var(--accent); }
  50% { background: var(--accent-dark); }
}

.map-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--primary);
  color: white;
  flex-shrink: 0;
}

.map-speed-indicator {
  padding: 6px 12px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 14px;
}

.map-speed-indicator.on-time { background: var(--highlight); color: var(--text); }
.map-speed-indicator.speed-up { background: var(--accent); color: var(--text); }
.map-speed-indicator.slow-down { background: #FFD700; color: var(--text); }

.map-toggle-btn {
  background: rgba(255,255,255,0.2);
  border: 2px solid white;
  color: white;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.map-nav-btn {
  background: none;
  border: 2px solid white;
  color: white;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

#map-container {
  flex: 1;
  z-index: 1;
}

.map-eta {
  font-size: 14px;
  font-weight: 600;
}

/* ===== Homepage (Public) ===== */
.homepage {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.homepage-header {
  padding: 16px;
  text-align: center;
  background: var(--primary);
  color: white;
  flex-shrink: 0;
}

.homepage-header h1 {
  font-size: 24px;
  margin-bottom: 4px;
}

.homepage-header p {
  font-size: 14px;
  opacity: 0.9;
}

#homepage-map {
  flex: 1;
}

.homepage-buttons {
  display: flex;
  gap: 8px;
  padding: 12px;
  flex-shrink: 0;
}

.homepage-btn {
  flex: 1;
  padding: 16px 12px;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
}

.homepage-btn.missed {
  background: var(--accent);
  color: var(--text);
}

.homepage-btn.want {
  background: var(--highlight);
  color: var(--text);
}

.homepage-btn:active {
  opacity: 0.8;
}

.homepage-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.homepage-status {
  text-align: center;
  padding: 8px;
  font-size: 13px;
  color: var(--text-light);
  flex-shrink: 0;
}

/* ===== Days Page ===== */
.days-page {
  min-height: 100vh;
  background: var(--bg);
  padding: 16px;
}

.days-page h1 {
  font-size: 24px;
  color: var(--text);
  margin-bottom: 20px;
  text-align: center;
}

.days-form {
  max-width: 500px;
  margin: 0 auto;
  background: var(--bg-white);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 2px 12px var(--shadow);
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.form-group select,
.form-group input {
  width: 100%;
  padding: 12px;
  border: 2px solid var(--primary);
  border-radius: 8px;
  font-size: 16px;
  color: var(--text);
  background: var(--bg);
}

.trip-tag {
  text-align: center;
  padding: 8px 16px;
  margin: 8px 0 16px;
  background: var(--primary);
  color: white;
  border-radius: 8px;
  font-weight: 700;
  font-size: 16px;
}

.start-day-btn {
  display: block;
  width: 100%;
  padding: 16px;
  background: var(--highlight);
  color: var(--text);
  border: none;
  border-radius: var(--radius);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
}

.start-day-btn:active {
  background: var(--highlight-dark);
}

/* ===== Flash messages ===== */
.flash {
  padding: 12px 16px;
  text-align: center;
  font-weight: 600;
}

.flash.notice {
  background: var(--highlight);
  color: var(--text);
}

.flash.alert {
  background: var(--accent);
  color: var(--text);
}

/* ===== No active session banner ===== */
.no-session-banner {
  padding: 20px;
  text-align: center;
  background: var(--bg-white);
  margin: 20px;
  border-radius: var(--radius);
  box-shadow: 0 2px 12px var(--shadow);
}

.no-session-banner h2 {
  color: var(--text);
  margin-bottom: 12px;
}

.no-session-banner a {
  display: inline-block;
  padding: 12px 24px;
  background: var(--highlight);
  color: var(--text);
  text-decoration: none;
  border-radius: 8px;
  font-weight: 600;
}

/* ===== Auth Pages ===== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 16px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-white);
  border-radius: var(--radius);
  padding: 32px 24px;
  box-shadow: 0 4px 24px var(--shadow);
  text-align: center;
}

.auth-card h1 {
  font-size: 28px;
  color: var(--primary-dark);
  margin-bottom: 4px;
}

.auth-subtitle {
  font-size: 14px;
  color: var(--text-light);
  margin-bottom: 24px;
}

.auth-card .flash {
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
}

.auth-field {
  margin-bottom: 16px;
  text-align: left;
}

.auth-field label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
  font-size: 14px;
}

.auth-field input {
  width: 100%;
  padding: 12px;
  border: 2px solid var(--primary);
  border-radius: 8px;
  font-size: 16px;
  color: var(--text);
  background: var(--bg);
  transition: border-color 0.2s;
}

.auth-field input:focus {
  outline: none;
  border-color: var(--primary-dark);
}

.auth-btn {
  display: block;
  width: 100%;
  padding: 14px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 8px;
}

.auth-btn:hover { background: var(--primary-dark); }
.auth-btn:active { background: var(--primary-dark); }
.auth-btn.green { background: var(--highlight); color: var(--text); }
.auth-btn.green:hover { background: var(--highlight-dark); }
.auth-btn.green:active { background: var(--highlight-dark); }

.auth-footer {
  margin-top: 20px;
  font-size: 14px;
  color: var(--text-light);
}

.auth-footer a {
  color: var(--primary-dark);
  font-weight: 600;
  text-decoration: none;
}

.auth-footer a:hover {
  text-decoration: underline;
}
