:root {
  --primary: #1e3a8a;
  --primary-light: #2563eb;
  --secondary: #0284c7;
  --bg-color: #f8fafc;
  --text-dark: #0f172a;
  --text-light: #ffffff;
  --glass-bg: rgba(255, 255, 255, 0.85);
  --glass-border: rgba(200, 200, 200, 0.5);
  --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.08);
  --font-heading: "Playfair Display", serif;
  --font-body: "Poppins", sans-serif;
  --transition: all 0.3s ease;
}

.dark-mode {
  --primary: #2d63be;
  --primary-light: #4f86d1;
  --secondary: #38bdf8;
  --bg-color: #0f172a;
  --text-dark: #f1f5f9;
  --text-light: #ffffff;
  --glass-bg: rgba(30, 30, 30, 0.9);
  --glass-border: rgba(255, 255, 255, 0.15);
  --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.6);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-color);
  color: var(--text-dark);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-heading);
  color: var(--primary);
  margin-bottom: 1rem;
}

/* Glassmorphism Util */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow);
  border-radius: 16px;
}

/* Layout */
.main {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.content-wrapper {
  flex: 1;
  padding: 2rem;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

/* Header */
header {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: var(--text-light);
  padding: 1rem 2rem;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.header-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
}

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

.brand h1 {
  color: var(--secondary);
  font-size: 2rem;
  margin: 0;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

header nav {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

header nav a {
  color: var(--text-light);
  text-decoration: none;
  font-weight: 500;
  transition: var(--transition);
  padding: 0.5rem 1rem;
  border-radius: 8px;
}

header nav a:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: var(--secondary);
}

header nav div.active a {
  color: var(--secondary);
  background-color: rgba(255, 255, 255, 0.15);
}

/* Footer */
footer {
  background: var(--primary);
  color: var(--text-light);
  text-align: center;
  padding: 2rem;
  margin-top: auto;
}

.footer-links {
  margin-top: 1rem;
}

.footer-links a {
  color: #93c5fd;
  /* Light blue link color for visibility */
  text-decoration: none;
  font-size: 0.9rem;
  transition: var(--transition);
}

.footer-links a:hover {
  color: #ffffff;
  text-decoration: underline;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  transition: var(--transition);
  cursor: pointer;
  border: none;
  text-align: center;
}

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

.btn-primary:hover {
  background-color: #e6c551;
  transform: translateY(-2px);
}

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

.btn-outline:hover {
  background-color: var(--secondary);
  color: var(--primary);
}

/* Auth Pages & Forms */
.form-container {
  max-width: 400px;
  margin: 4rem auto;
  padding: 2rem;
}

.form-group {
  margin-bottom: 1.5rem;
}

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

.form-group input,
.form-group select {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 1rem;
  background-color: rgba(255, 255, 255, 0.8);
  transition: var(--transition);
}

.form-group select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b1d2f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 1em;
  padding-right: 2.5rem;
  cursor: pointer;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(107, 29, 47, 0.15);
  background-color: #fff;
}

.form-group select:hover {
  border-color: var(--primary-light);
  background-color: #fff;
}

.content-box {
  padding: 2rem;
}

.text-center {
  text-align: center;
}

.btn-block {
  width: 100%;
}

.form-footer {
  margin-top: 1rem;
}

.form-footer a {
  color: #3b82f6;
  font-weight: 500;
  text-decoration: none;
  transition: var(--transition);
}

.dark-mode .form-footer a {
  color: #93c5fd;
}

.form-footer a:hover {
  color: var(--secondary);
  text-decoration: underline;
}

.flex-1 {
  flex: 1;
}

.align-end {
  align-self: flex-end;
}

.wines-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
}

.wine-card {
  display: block;
  text-decoration: none;
  color: inherit;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
  overflow: hidden;
  height: 280px;
  /* Ensure rounded corners clip content */
}

.wine-card:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
}

.dark-mode .wine-card:hover {
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.4);
}

.wine-card-content {
  display: flex;
  flex-direction: row;
  height: 100%;
}

.wine-thumbnail {
  width: 130px;
  height: 100%;
  object-fit: cover;
  border-radius: 8px 0 0 8px;
  /* Round left corners only */
}

.wine-info {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.wine-title {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
  line-height: 1.2;
}

.wine-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.badge {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  background-color: var(--primary);
  color: var(--text-light);
  border-radius: 12px;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.dark-mode .badge {
  background-color: var(--secondary);
  color: var(--bg-color);
}

.wine-summary {
  font-size: 0.85rem;
  color: inherit;
  opacity: 0.8;
  margin-bottom: 1rem;
  flex-grow: 1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  /* Limit to 2 lines */
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.wine-price {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--secondary);
  margin-bottom: 0px !important;
  align-self: flex-end;
}

.filter-form {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 1rem;
  margin-bottom: 2rem;
}

.wine-images {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  padding-bottom: 1rem;
}

.detail-img {
  height: 250px;
  border-radius: 8px;
  object-fit: cover;
}

/* Image Popup Overlay */
.image-popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  cursor: pointer;
}

.image-popup-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
}

.full-size-img {
  max-width: 100%;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.close-popup-btn {
  position: absolute;
  top: -40px;
  right: 0;
  background-color: transparent;
  color: white;
  border: 1px solid white;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font-body);
  transition: var(--transition);
}

.close-popup-btn:hover {
  background-color: white;
  color: black;
}

.pointer {
  cursor: pointer;
}

.mt-1 {
  margin-top: 1rem;
}

.mb-1 {
  margin-bottom: 1rem;
  color: gray;
}

.price-text {
  color: #d4af37;
}

.italic-text {
  font-style: italic;
}

/* Alerts */
.error-msg {
  color: #d32f2f;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.success-msg {
  color: #388e3c;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

/* Hero Section */
.hero {
  text-align: center;
  padding: 5rem 1rem;
  background:
    linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)),
    url("https://images.unsplash.com/photo-1506377247377-2a5b3b417ebb?ixlib=rb-1.2.1&auto=format&fit=crop&w=1920&q=80") center/cover;
  color: white;
  border-radius: 0 0 16px 16px;
  margin-bottom: 3rem;
  box-shadow: var(--shadow);
}

.hero h1 {
  color: white;
  font-size: 3.5rem;
  margin-bottom: 1rem;
}

.hero p {
  font-size: 1.25rem;
  margin-bottom: 2rem;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

/* Theme Switch */
.theme-switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 24px;
  margin-left: 1rem;
}

.theme-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  -webkit-transition: 0.4s;
  transition: 0.4s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  -webkit-transition: 0.4s;
  transition: 0.4s;
}

input:checked+.slider {
  background-color: var(--secondary);
}

input:focus+.slider {
  box-shadow: 0 0 1px var(--secondary);
}

input:checked+.slider:before {
  -webkit-transform: translateX(26px);
  -ms-transform: translateX(26px);
  transform: translateX(26px);
}

.slider.round {
  border-radius: 24px;
}

.slider.round:before {
  border-radius: 50%;
}

/* Wine Card */
.wine-info {
  padding: 8px 8px 8px 14px;
}

.back-to-catalog {
  color: #3b82f6;
  /* Lighter blue in light mode */
  text-decoration: none;
  font-weight: 500;
  transition: var(--transition);
  display: inline-block;
}

.dark-mode .back-to-catalog {
  color: #93c5fd;
  /* Light sky blue in dark mode */
}

.back-to-catalog:hover {
  color: var(--secondary);
  text-decoration: underline;
}

/* Responsive */
@media (max-width: 768px) {
  header nav {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
  }

  .header-container {
    flex-direction: column;
    gap: 1rem;
  }

  .hero h1 {
    font-size: 2.5rem;
  }

  .filter-form {
    flex-direction: column;
  }

  .filter-form .align-end {
    width: 100%;
    align-self: stretch;
  }
}