:root {
  --amex-blue: #006fcf;
  --amex-dark-blue: #00175a;
  --amex-light-grey: #f4f4f4;
  --text-color: #333;
  --white: #ffffff;
  --border-color: #e6e6e6;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  color: var(--text-color);
  background-color: var(--amex-light-grey);
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
header {
  background-color: var(--amex-blue);
  color: var(--white);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  z-index: 10;
}

.logo-area h1 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.5px;
}

.controls {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.amex-select {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: var(--white);
  padding: 0.3rem 0.8rem;
  border-radius: 6px;
  font-family: var(--font-family);
  font-size: 0.875rem;
  cursor: pointer;
  outline: none;
  min-width: 140px;
}

.amex-select option {
  background: var(--white);
  color: var(--text-color);
}

.amex-select:focus {
  background: rgba(255, 255, 255, 0.25);
  border-color: var(--white);
}

/* Toggle Switch */
.language-toggle {
  display: flex;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 20px;
  padding: 2px;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.lang-btn {
  background: transparent;
  border: none;
  color: var(--white);
  padding: 0.25rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 18px;
  transition: all 0.2s ease;
}

.lang-btn.active {
  background: var(--white);
  color: var(--amex-blue);
  font-weight: 700;
}

/* Main Layout */
main {
  flex: 1;
  display: flex;
  position: relative;
  overflow: hidden;
}

#map {
  flex: 1;
  height: 100%;
  width: 100%;
}

/* Sidebar / List View */
.sidebar {
  width: 350px;
  background: var(--white);
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  z-index: 5;
}

.sidebar-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-header h2 {
  font-size: 1.25rem;
  color: var(--amex-dark-blue);
  margin-bottom: 0.5rem;
}

.sidebar-stats {
  font-size: 0.875rem;
  color: #666;
}

.restaurant-list {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

.restaurant-card {
  padding: 1.25rem;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: background-color 0.2s;
  position: relative;
}

.restaurant-card:hover {
  background-color: #f9f9f9;
}

.restaurant-card.active {
  border-left: 4px solid var(--amex-blue);
  background-color: #f0f7ff;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.5rem;
}

.restaurant-name {
  font-weight: 600;
  font-size: 1rem;
  color: var(--amex-dark-blue);
}

.new-badge {
  background-color: #007ac2;
  color: white;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.restaurant-type {
  font-size: 0.8rem;
  color: #666;
  margin-bottom: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.restaurant-address {
  font-size: 0.875rem;
  color: #444;
}

/* Info Window Styling */
.gm-style-iw {
  padding: 0 !important;
  border-radius: 8px !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
}

.info-window-content {
  padding: 12px 16px;
  min-width: 200px;
}

.info-window-content h3 {
  font-size: 1rem;
  margin-bottom: 4px;
  color: var(--amex-dark-blue);
}

.info-window-content p {
  font-size: 0.875rem;
  color: #555;
  margin-bottom: 4px;
}

/* Responsive */
@media (max-width: 768px) {
  body {
    flex-direction: column;
  }

  header {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  main {
    flex-direction: column-reverse;
    /* Map on top in logic, but visually maybe we want map then list or list overlay */
  }

  .sidebar {
    width: 100%;
    height: 40%;
    border-top: 2px solid var(--amex-blue);
    position: absolute;
    bottom: 0;
    left: 0;
    border-radius: 16px 16px 0 0;
    transition: transform 0.3s ease;
  }
}

/* Sidebar Toggle */
.sidebar-toggle {
  position: absolute;
  top: 50%;
  right: -32px;
  /* Increased width means we need to push it further out */
  transform: translateY(-50%);
  width: 32px;
  height: 64px;
  background-color: var(--amex-blue);
  /* Make it blue to pop */
  color: var(--white);
  border: 1px solid var(--amex-dark-blue);
  border-left: none;
  border-radius: 0 8px 8px 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 4px 0 8px rgba(0, 0, 0, 0.2);
  transition: background-color 0.2s;
  z-index: 20;
  font-size: 1.2rem;
}

.sidebar-toggle:hover {
  background-color: var(--amex-dark-blue);
}

.sidebar {
  width: 350px;
  background: var(--white);
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  z-index: 5;
  transition: width 0.3s ease, transform 0.3s ease;
  position: relative;
  overflow: visible;
  /* CRITICAL: Allow button to stick out */
}

.sidebar.collapsed {
  width: 0;
  transform: translateX(0);
}

/* Hide content when collapsed */
.sidebar.collapsed .sidebar-header,
.sidebar.collapsed .restaurant-list {
  display: none;
}

.sidebar.collapsed .sidebar-toggle {
  right: -24px;
  /* Keep it attached to the sliver */
}

/* Disclaimer Footer */
.disclaimer {
  background: rgba(0, 23, 90, 0.95);
  color: rgba(255, 255, 255, 0.85);
  padding: 0.75rem 1.5rem;
  text-align: center;
  font-size: 0.75rem;
  line-height: 1.5;
  z-index: 10;
  border-top: 1px solid var(--amex-blue);
}

.disclaimer-text {
  margin: 0;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
}

@media (max-width: 768px) {
  .disclaimer {
    padding: 0.5rem 1rem;
    font-size: 0.65rem;
  }
}

/* Loading State */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-color);
  border-top-color: var(--amex-blue);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1rem;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-state p {
  margin: 0;
  font-size: 0.9rem;
}

/* Error State */
.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  text-align: center;
}

.error-state p {
  margin: 0 0 0.5rem 0;
  color: var(--text-muted);
}

.error-state p:first-child {
  font-size: 1rem;
  color: var(--text-primary);
}

.error-detail {
  font-size: 0.8rem;
  color: #ff6b6b !important;
  max-width: 100%;
  word-break: break-word;
}

.retry-btn {
  margin-top: 1rem;
  padding: 0.5rem 1.5rem;
  background: var(--amex-blue);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background-color 0.2s ease;
}

.retry-btn:hover {
  background: var(--amex-accent);
}

/* Collapsible disclaimer */
.disclaimer {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.disclaimer-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  padding: 0.55rem 0.8rem;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.disclaimer-toggle-icon {
  font-size: 1rem;
  line-height: 1;
}

.disclaimer-body {
  width: 100%;
}

.disclaimer.collapsed .disclaimer-body {
  display: none;
}

/* Mobile UX improvements */
@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    height: min(58vh, 460px);
    max-height: 70vh;
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    border-top: 2px solid var(--amex-blue);
    border-radius: 16px 16px 0 0;
    transition: transform 0.28s ease;
    transform: translateY(0);
  }

  .sidebar-header {
    padding: 1rem 1rem 0.8rem;
  }

  .sidebar-toggle {
    position: absolute;
    top: 10px;
    right: 12px;
    left: auto;
    transform: none;
    width: auto;
    min-width: 132px;
    height: 34px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid rgba(0, 23, 90, 0.4);
    font-size: 0.78rem;
    box-shadow: none;
  }

  .sidebar.collapsed {
    width: 100%;
    transform: translateY(calc(100% - 50px));
  }

  .sidebar.collapsed .sidebar-toggle {
    right: 12px;
  }

  .sidebar.collapsed .sidebar-header,
  .sidebar.collapsed .restaurant-list {
    display: none;
  }

  .disclaimer {
    padding: 0.5rem 0.75rem;
    font-size: 0.7rem;
  }

  .disclaimer-toggle {
    font-size: 0.75rem;
    padding: 0.5rem 0.7rem;
  }
}
