/* Cliff Weather - Custom Styles */
/* Built on top of Simple.css */

/* ============================================
   CSS Variables - Color Palette
   ============================================ */
:root {
  /* State colors */
  --color-sec: #22c55e;        /* Green - DRY */
  --color-humide: #eab308;     /* Yellow - HUMID */
  --color-mouille: #ef4444;    /* Red - WET */

  /* UI colors */
  --color-primary: #3b82f6;    /* Blue - primary actions */
  --color-primary-hover: #2563eb;
  --color-bg: #f8fafc;         /* Light background */
  --color-bg-alt: #ffffff;     /* Card background */
  --color-text: #1e293b;       /* Dark text */
  --color-text-muted: #64748b; /* Muted text */
  --color-border: #e2e8f0;     /* Borders */

  /* Layout */
  --header-height: 60px;
  --sidebar-width: 280px;
}

/* ============================================
   Base Styles
   ============================================ */
*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
  background-color: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
  font-size: 16px;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0 0 1rem 0;
  line-height: 1.2;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }

p {
  margin: 0 0 1rem 0;
}

a {
  color: var(--color-primary);
  text-decoration: none;
}

a:hover {
  color: var(--color-primary-hover);
  text-decoration: underline;
}

input, button, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

/* ============================================
   Header / Navigation
   ============================================ */
.site-header {
  background: var(--color-bg-alt);
  border-bottom: 1px solid var(--color-border);
  height: var(--header-height);
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: relative;
  z-index: 100;
}

.site-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--color-text);
}

.site-logo:hover {
  text-decoration: none;
  color: var(--color-primary);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  font-weight: 500;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.15s ease;
  border: none;
}

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

.btn-primary:hover {
  background: var(--color-primary-hover);
  text-decoration: none;
  color: white;
}

.btn-secondary {
  background: transparent;
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover {
  background: var(--color-bg);
  text-decoration: none;
}

.btn-danger {
  background: var(--color-mouille);
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
}

/* ============================================
   Main Content
   ============================================ */
.main-content {
  width: 100%;
  min-height: calc(100vh - var(--header-height));
  overflow-x: hidden;
}

/* Ensure body doesn't have horizontal scroll */
html, body {
  overflow-x: hidden;
  max-width: 100vw;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ============================================
   Cards
   ============================================ */
.card {
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  padding: 1.5rem;
}

/* ============================================
   Forms
   ============================================ */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.375rem;
  font-weight: 500;
  font-size: 0.875rem;
}

.form-group input {
  width: 100%;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 0.375rem;
  font-size: 1rem;
  transition: border-color 0.15s ease;
}

.form-group input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-error {
  color: var(--color-mouille);
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

/* ============================================
   Auth Pages
   ============================================ */
.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - var(--header-height));
  padding: 2rem;
}

.auth-card {
  width: 100%;
  max-width: 400px;
}

.auth-card h1 {
  margin-bottom: 1.5rem;
  text-align: center;
}

.auth-card .btn {
  width: 100%;
  margin-top: 0.5rem;
}

.auth-footer {
  text-align: center;
  margin-top: 1.5rem;
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

/* ============================================
   Status Badges
   ============================================ */
.status-badge {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-sec {
  background-color: var(--color-sec);
}

.status-humide {
  background-color: var(--color-humide);
}

.status-mouille {
  background-color: var(--color-mouille);
}

/* Text variants */
.text-sec {
  color: var(--color-sec);
}

.text-humide {
  color: var(--color-humide);
}

.text-mouille {
  color: var(--color-mouille);
}

/* ============================================
   Alerts / Messages
   ============================================ */
.alert {
  padding: 0.75rem 1rem;
  border-radius: 0.375rem;
  margin-bottom: 1rem;
  font-size: 0.875rem;
}

.alert-error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.alert-success {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.alert-info {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

/* ============================================
   Footer
   ============================================ */
.site-footer {
  background: var(--color-bg-alt);
  border-top: 1px solid var(--color-border);
  padding: 1rem 1.5rem;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

/* ============================================
   Search Component
   ============================================ */
.search-container {
  position: absolute;
  top: 1rem;
  left: 60px; /* Offset to avoid zoom buttons */
  z-index: 1000;
  width: 280px;
  max-width: calc(100% - 80px);
}

.search-container #search-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  font-size: 0.9375rem;
  background: var(--color-bg-alt);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-container #search-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 2px 12px rgba(59, 130, 246, 0.2);
}

.search-container #search-input::placeholder {
  color: var(--color-text-muted);
}

#search-results {
  display: none;
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  margin-top: 0.5rem;
  max-height: 300px;
  overflow-y: auto;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

#search-results.active {
  display: block;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: background-color 0.1s ease;
  border-bottom: 1px solid var(--color-border);
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:hover {
  background-color: var(--color-bg);
}

.search-result-item .result-name {
  flex: 1;
  font-weight: 500;
  color: var(--color-text);
}

.search-result-item .result-score {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  font-weight: 500;
}

.search-empty,
.search-error {
  padding: 1rem;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

.search-error {
  color: var(--color-mouille);
}

/* ============================================
   Spots Sidebar
   ============================================ */
.spots-sidebar {
  position: absolute;
  top: 0;
  right: 0;
  width: var(--sidebar-width);
  height: 100%;
  background: var(--color-bg-alt);
  border-left: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  z-index: 500;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: -2px 0 8px rgba(0, 0, 0, 0.05);
}

/* Collapsed state */
.spots-sidebar.collapsed {
  transform: translateX(100%);
}

.sidebar-header {
  padding: 1rem;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.sidebar-header h2 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  flex: 1;
}

.spot-count {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

/* Close button in sidebar header */
.sidebar-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: var(--color-bg);
  border-radius: 0.375rem;
  cursor: pointer;
  color: var(--color-text-muted);
  font-size: 1.25rem;
  transition: all 0.15s ease;
  margin-left: 0.5rem;
}

.sidebar-close-btn:hover {
  background: var(--color-border);
  color: var(--color-text);
}

.spots-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
}

.spot-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid var(--color-border);
  transition: background-color 0.1s ease;
}

.spot-item:hover {
  background-color: var(--color-bg);
}

.spot-item .spot-name {
  flex: 1;
  font-weight: 500;
  font-size: 0.9375rem;
  color: var(--color-text);
}

.spot-item .spot-score {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-text-muted);
}

.spots-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

/* Toggle Button - visible when sidebar is collapsed */
.sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: 50%;
  right: 1rem;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 0.5rem;
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  cursor: pointer;
  z-index: 600;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: all 0.2s ease;
  opacity: 0;
  pointer-events: none;
  color: var(--color-text);
}

/* Show toggle when sidebar is collapsed */
.spots-sidebar.collapsed ~ .sidebar-toggle {
  opacity: 1;
  pointer-events: auto;
}

.sidebar-toggle:hover {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: white;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.sidebar-toggle svg {
  transition: transform 0.2s ease;
}

.sidebar-toggle:hover svg {
  transform: translateX(-2px);
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
  .site-header {
    padding: 0 1rem;
  }

  .container {
    padding: 1rem;
  }

  .nav-links {
    gap: 0.5rem;
  }

  .nav-user span {
    display: none;
  }

  .search-container {
    width: calc(100% - 2rem);
  }

  /* Mobile sidebar */
  .spots-sidebar {
    position: fixed;
    top: var(--header-height);
    right: 0;
    width: 100%;
    max-width: 320px;
    height: calc(100vh - var(--header-height));
    box-shadow: -4px 0 12px rgba(0, 0, 0, 0.15);
  }

  .spots-sidebar.collapsed {
    transform: translateX(100%);
  }

  .sidebar-toggle {
    bottom: 1rem;
    top: auto;
    right: 1rem;
    transform: none;
    border-radius: 50%;
    width: 56px;
    height: 56px;
  }

  .spots-sidebar.collapsed ~ .sidebar-toggle {
    opacity: 1;
    pointer-events: auto;
  }
}
