/* ==========================================================================
   VintageTrail - Core Design System & Layout
   Aesthetic: Neo-Modern Vintage Editorial (Film grain, Warm Cream, Bold Sans)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Playfair+Display:ital,wght@0,600;0,800;1,600&family=JetBrains+Mono:wght@500;700&display=swap');

:root {
  /* Color Palette */
  --bg-primary: #FAF8F5; /* Warm vintage cream parchment */
  --bg-card: #FFFFFF;
  --bg-card-hover: #FCFBF9;
  --bg-dark: #181716; /* Deep charcoal ink */
  --bg-dark-card: #232220;
  
  --text-main: #1C1B1A;
  --text-muted: #6B6864;
  --text-light: #9E9A93;
  --text-inverse: #FAF8F5;

  /* Tier Accent Colors */
  --tier3-color: #E26D5C; /* Curated Vintage: Terracotta / Sunset */
  --tier3-bg: #FDF1EE;
  --tier2-color: #2F855A; /* Consignment: Sage Vintage Green */
  --tier2-bg: #EBF8F2;
  --tier1-color: #3182CE; /* Charity / Bins: Denim Steel Blue */
  --tier1-bg: #EBF8FF;

  --accent-gold: #D69E2E; /* Retro Star / Gold */
  --accent-purple: #805AD5; /* Y2K vibe */
  --border-color: #E6E2DB;
  --border-dark: #383633;

  /* Shadows & Elevation */
  --shadow-sm: 0 2px 8px rgba(28, 27, 26, 0.05);
  --shadow-md: 0 8px 24px rgba(28, 27, 26, 0.08);
  --shadow-lg: 0 16px 40px rgba(28, 27, 26, 0.12);
  --shadow-retro: 3px 3px 0px #181716;

  /* Typography */
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-serif: 'Playfair Display', Georgia, serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Dimensions */
  --header-height: 68px;
  --sidebar-width: 440px;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 9999px;

  --transition-fast: 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-smooth: 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Reset & Box Sizing */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

/* Base Utility Classes */
button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  transition: all var(--transition-fast);
}

a {
  color: inherit;
  text-decoration: none;
}

/* App Container */
#app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  position: relative;
}

/* Header & Navigation */
.app-header {
  height: var(--header-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.brand-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-serif);
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.5px;
}

.brand-badge {
  background: var(--tier3-color);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.city-selector-wrapper {
  display: flex;
  align-items: center;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color var(--transition-fast);
}

.city-selector-wrapper:hover {
  border-color: var(--text-main);
}

.city-selector-wrapper select {
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-main);
  cursor: pointer;
  outline: none;
  padding-left: 6px;
}

/* Header Weather Badge (Open-Meteo Powered) */
.weather-capsule {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
  flex-shrink: 0;
  min-width: max-content;
  transition: all var(--transition-fast);
}

.weather-capsule:hover {
  border-color: var(--accent-gold);
}

.weather-temp {
  font-family: var(--font-mono);
  color: var(--tier3-color);
}

.weather-tip {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* Header Action Buttons */
.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  white-space: nowrap;
}

.btn-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.btn-pill-primary {
  background: var(--bg-dark);
  color: var(--text-inverse);
  box-shadow: 0 4px 12px rgba(24, 23, 22, 0.15);
}

.btn-pill-primary:hover {
  transform: translateY(-1px);
  background: #2b2a28;
}

.btn-pill-outline {
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-main);
}

.btn-pill-outline:hover {
  border-color: var(--text-main);
  background: var(--bg-primary);
}

.btn-pill-accent {
  background: var(--tier3-bg);
  color: var(--tier3-color);
  border: 1px solid rgba(226, 109, 92, 0.25);
}

.btn-pill-accent:hover {
  background: var(--tier3-color);
  color: #fff;
}

/* Main Body Layout (Sidebar + Map) */
.main-viewport {
  flex: 1;
  display: flex;
  position: relative;
  overflow: hidden;
}

/* Left Sidebar - Stores & Feeds */
.app-sidebar {
  width: var(--sidebar-width);
  height: calc(100vh - var(--header-height));
  background: var(--bg-primary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 40;
  box-shadow: var(--shadow-md);
  position: relative;
  transition: transform var(--transition-smooth);
}

/* Top Filters Section */
.sidebar-filters-panel {
  padding: 16px 20px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Search Bar */
.search-input-box {
  position: relative;
  width: 100%;
}

.search-input-box input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  font-family: inherit;
  font-size: 0.88rem;
  color: var(--text-main);
  outline: none;
  transition: border-color var(--transition-fast);
}

.search-input-box input:focus {
  border-color: var(--text-main);
  background: #fff;
}

.search-input-box .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  pointer-events: none;
}

/* Tier Filters (The 3 distinct categories) */
.tier-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.tier-tab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.2;
}

.tier-tab-btn span.emoji {
  font-size: 1.1rem;
  margin-bottom: 3px;
}

.tier-tab-btn.active[data-tier="all"] {
  border-color: var(--text-main);
  background: var(--text-main);
  color: #fff;
}

.tier-tab-btn.active[data-tier="tier3"] {
  border-color: var(--tier3-color);
  background: var(--tier3-bg);
  color: var(--tier3-color);
}

.tier-tab-btn.active[data-tier="tier2"] {
  border-color: var(--tier2-color);
  background: var(--tier2-bg);
  color: var(--tier2-color);
}

.tier-tab-btn.active[data-tier="tier1"] {
  border-color: var(--tier1-color);
  background: var(--tier1-bg);
  color: var(--tier1-color);
}

/* Horizontal Style Scrollbar & Tag Chips */
.style-scroll-track {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 80px;
  overflow-y: auto;
  padding: 2px 0;
  scrollbar-width: thin;
}

.style-scroll-track::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

.style-scroll-track::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

.chip-filter {
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.chip-filter:hover {
  border-color: var(--text-main);
  color: var(--text-main);
}

.chip-filter.active {
  background: var(--bg-dark);
  color: var(--text-inverse);
  border-color: var(--bg-dark);
}

/* Feature Quick Toggles */
.feature-quick-toggles {
  display: flex;
  gap: 8px;
}

.toggle-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  border: 1px dashed var(--border-color);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
}

.toggle-chip.active {
  border-style: solid;
  border-color: var(--tier2-color);
  background: var(--tier2-bg);
  color: var(--tier2-color);
}

/* Stores List & Cards */
.store-list-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.results-meta-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0 2px;
}

.store-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: pointer;
  transition: all var(--transition-smooth);
  position: relative;
}

.store-card:hover {
  transform: translateY(-2px);
  border-color: var(--text-main);
  box-shadow: var(--shadow-md);
}

.store-card.selected {
  border: 2px solid var(--tier3-color) !important;
  background: #FFFDF8 !important;
  box-shadow: 0 0 0 3px rgba(226, 114, 91, 0.25), 4px 4px 0px #181716 !important;
  transform: translateX(3px) scale(1.01);
}

.store-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.store-card-title {
  font-family: var(--font-sans);
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.25;
}

.store-badge-tier {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.tier-badge-tier3 {
  background: var(--tier3-bg);
  color: var(--tier3-color);
  border: 1px solid rgba(226, 109, 92, 0.3);
}

.tier-badge-tier2 {
  background: var(--tier2-bg);
  color: var(--tier2-color);
  border: 1px solid rgba(47, 133, 90, 0.3);
}

.tier-badge-tier1 {
  background: var(--tier1-bg);
  color: var(--tier1-color);
  border: 1px solid rgba(49, 130, 206, 0.3);
}

.store-card-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.meta-rating {
  display: flex;
  align-items: center;
  gap: 3px;
  font-weight: 700;
  color: var(--text-main);
}

.meta-price {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--tier3-color);
}

.store-card-vibe {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.store-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.tag-pill {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  background: var(--bg-primary);
  color: var(--text-muted);
}

/* Right Map View */
.map-viewport {
  flex: 1;
  height: calc(100vh - var(--header-height));
  position: relative;
  background: #EDEAE5;
}

#map {
  width: 100%;
  height: 100%;
}

/* Mobile Toggle Bar */
.mobile-view-switch {
  display: none;
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  background: var(--bg-dark);
  color: var(--text-inverse);
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-lg);
  font-weight: 700;
  font-size: 0.88rem;
}

/* Responsive Breakpoints */
@media (max-width: 900px) {
  :root {
    --sidebar-width: 100vw;
  }

  .app-sidebar {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100%;
    transform: translateY(100%);
    box-shadow: none;
  }

  .app-sidebar.mobile-open {
    transform: translateY(0);
  }

  .mobile-view-switch {
    display: flex;
    align-items: center;
    gap: 8px;
  }
}
