/* ==============================================================
   DARK MODE – CSS VARIABLES
   ============================================================== */
:root {
  --bg: #ffffff;
  --text: #333333;
  --header-bg: #ffffff;
  --border: #e5e7eb;
  --link: #4b5563;
  --link-hover: #16a34a;
  --input-bg: #ffffff;
  --input-border: #cccccc;
  --input-focus: #16a34a;
  --alert-success-bg: #d1fae5;
  --alert-success-border: #34d399;
  --alert-success-text: #065f46;
  --alert-error-bg: #fee2e2;
  --alert-error-border: #f87171;
  --alert-error-text: #991b1b;
  --alert-info-bg: #dbeafe;
  --alert-info-border: #93c5fd;
  --alert-info-text: #1e40af;
  --alert-warning-bg: #fef3c7;
  --alert-warning-border: #fbbf24;
  --alert-warning-text: #92400e;
  --footer-bg: #1f2937;
  --footer-text: #f3f4f6;
  --footer-link: #d1d5db;
  --footer-link-hover: #34d399;
}

html.dark {
  --bg: #0f172a;
  --text: #f1f5f9;
  --header-bg: #1e293b;
  --border: #334155;
  --link: #cbd5e1;
  --link-hover: #34d399;
  --input-bg: #1e293b;
  --input-border: #475569;
  --input-focus: #34d399;
  --alert-success-bg: #065f46;
  --alert-success-border: #0f9d58;
  --alert-success-text: #d1fae5;
  --alert-error-bg: #991b1b;
  --alert-error-border: #dc2626;
  --alert-error-text: #fee2e2;
  --alert-info-bg: #1e40af;
  --alert-info-border: #3b82f6;
  --alert-info-text: #dbeafe;
  --alert-warning-bg: #92400e;
  --alert-warning-border: #f59e0b;
  --alert-warning-text: #fef3c7;
  --footer-bg: #111827;
  --footer-text: #e2e8f0;
  --footer-link: #94a3b8;
  --footer-link-hover: #6ee7b7;
}

/* ==============================================================
   APPLY VARIABLES TO ELEMENTS
   ============================================================== */
body {
  background: var(--bg);
  color: var(--text);
  transition: background 0.3s ease, color 0.3s ease;
}

.header {
  background: var(--header-bg);
  box-shadow: 0 2px 4px rgba(0,0,0,.1);
}

.logo a { color: #16a34a; }

.search-input {
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--text);
}
.search-input:focus {
  border-color: var(--input-focus);
  box-shadow: 0 0 0 2px rgba(52, 211, 153, 0.2);
}

.nav-link, .mobile-nav-link {
  color: var(--link);
}
.nav-link:hover, .mobile-nav-link:hover {
  color: var(--link-hover);
}

.signup-btn, .mobile-signup-btn {
  background: #16a34a;
  color: #fff;
}
.signup-btn:hover, .mobile-signup-btn:hover {
  background: #15803d;
}

.alert-success { background: var(--alert-success-bg); border-color: var(--alert-success-border); color: var(--alert-success-text); }
.alert-error   { background: var(--alert-error-bg);   border-color: var(--alert-error-border);   color: var(--alert-error-text); }
.alert-info    { background: var(--alert-info-bg);    border-color: var(--alert-info-border);    color: var(--alert-info-text); }
.alert-warning { background: var(--alert-warning-bg); border-color: var(--alert-warning-border); color: var(--alert-warning-text); }

.footer {
  background: var(--footer-bg);
  color: var(--footer-text);
}
.footer-list a {
  color: var(--footer-link);
}
.footer-list a:hover {
  color: var(--footer-link-hover);
}

/* Theme toggle button */
.theme-toggle-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  display: flex;
  align-items: center;
}
.theme-toggle-btn .icon-sun,
.theme-toggle-btn .icon-moon {
  width: 1.5rem;
  height: 1.5rem;
  stroke: currentColor;
}
.mobile-theme-btn {
  margin-top: 1rem;
  justify-content: center;
}

/* ==============================================================
   BASIC RESET & PAGE LAYOUT (footer always at bottom)
   ============================================================== */
*,
*::before,
*::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: #333;
  line-height: 1.5;
}

/* Flex column that fills the viewport */
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;          /* <-- crucial for sticky footer */
}

/* Main grows to push footer down */
.main-content { flex: 1; }

/* Container (centered, max-width) */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 0;
}

/* ==============================================================
   HEADER
   ============================================================== */
.header {
  background: #fff;
  box-shadow: 0 2px 4px rgba(0,0,0,.1);
  position: sticky;
  top: 0;
  z-index: 1000;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
}
.logo a {
  font-size: 1.5rem;
  font-weight: bold;
  color: #16a34a;
  text-decoration: none;
}

/* ---- Search ---- */
.search-form { flex: 1; max-width: 500px; margin: 0 1rem; }
.search-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid #ccc;
  border-radius: 0.5rem;
  font-size: 1rem;
}
.search-input:focus {
  outline: none;
  border-color: #16a34a;
  box-shadow: 0 0 0 2px rgba(22,163,74,.2);
}

/* ---- Desktop Nav ---- */
.nav { display: flex; align-items: center; gap: 1rem; }
.nav-link {
  color: #4b5563;
  text-decoration: none;
  font-weight: 500;
}
.nav-link:hover { color: #16a34a; }
.signup-btn {
  background: #16a34a;
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  text-decoration: none;
  font-weight: 500;
}
.signup-btn:hover { background: #15803d; }

/* Cart icon */
.cart-link { position: relative; }
.icon { width: 1.5rem; height: 1.5rem; }
.cart-badge {
  position: absolute;
  top: -0.5rem;
  right: -0.5rem;
  background: #dc2626;
  color: #fff;
  font-size: 0.75rem;
  font-weight: bold;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---- Mobile menu button ---- */
.mobile-menu-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
}
.mobile-menu-btn .icon { width: 1.5rem; height: 1.5rem; }

/* ==============================================================
   MOBILE MENU
   ============================================================== */
.mobile-menu {
  background: #fff;
  border-top: 1px solid #e5e7eb;
  padding: 1rem;
}
.mobile-search-form { margin-bottom: 1rem; }
.mobile-nav { display: flex; flex-direction: column; gap: 0.75rem; }
.mobile-nav-link {
  color: #4b5563;
  text-decoration: none;
  display: flex;
  align-items: center;
  font-weight: 500;
}
.mobile-nav-link:hover { color: #16a34a; }
.icon-sm { width: 1.25rem; height: 1.25rem; margin-right: 0.5rem; }
.mobile-signup-btn {
  background: #16a34a;
  color: #fff;
  text-align: center;
  padding: 0.75rem;
  border-radius: 0.5rem;
  text-decoration: none;
  font-weight: 500;
}
.mobile-signup-btn:hover { background: #15803d; }

.hidden { display: none; }

/* ==============================================================
   MESSAGES
   ============================================================== */
.messages { padding: 1rem 0; }
.alert {
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
  border-radius: 0.375rem;
  border: 1px solid transparent;
}
.alert-success { background:#d1fae5; border-color:#34d399; color:#065f46; }
.alert-error   { background:#fee2e2; border-color:#f87171; color:#991b1b; }
.alert-info    { background:#dbeafe; border-color:#93c5fd; color:#1e40af; }
.alert-warning { background:#fef3c7; border-color:#fbbf24; color:#92400e; }

/* ==============================================================
   MAIN CONTENT (pages will fill this)
   ============================================================== */
.main-content {
  padding: 2rem 0;
}

/* ==============================================================
   FOOTER
   ============================================================== */
.footer {
  background: #1f2937;
  color: #f3f4f6;
  padding: 2rem 0 1rem;
}
.footer-inner {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 2rem;
}
.footer-col h3 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}
.footer-list { list-style: none; }
.footer-list li { margin-bottom: 0.5rem; }
.footer-list a { color: #d1d5db; text-decoration: none; }
.footer-list a:hover { color: #34d399; }

.footer-bottom {
  text-align: center;
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid #374151;
  font-size: 0.875rem;
}

/* ==============================================================
   RESPONSIVE BREAKPOINTS
   ============================================================== */
/* Hide desktop-only elements on small screens */
@media (max-width: 767px) {
  .desktop-only { display: none !important; }
}

/* Show mobile-only elements on small screens */
@media (min-width: 768px) {
  .mobile-menu-btn,
  .mobile-menu { display: none !important; }
}