/* CSS Custom Properties for easy theming */
:root {
  --primary-color: #667eea;
  --secondary-color: #764ba2;
  --success-color: #28a745;
  --danger-color: #dc3545;
  --warning-color: #ffc107;
  --info-color: #17a2b8;
  --light-color: #f8f9fa;
  --dark-color: #343a40;
  --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  --border-radius: 6px;
  --box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
  --max-width: 1200px;
}

/* Global Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-family);
  line-height: 1.6;
  color: var(--dark-color);
  background-color: var(--light-color);
}

/* Global Header Styles */
.global-header {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
  box-shadow: var(--box-shadow);
  position: sticky;
  top: 0;
  z-index: 1000;
  backdrop-filter: blur(10px);
}

.header-container {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
}

.header-left {
  display: flex;
  align-items: center;
}

.logo-link {
  text-decoration: none;
  color: inherit;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.store-name {
  font-size: 1.5rem;
  font-weight: 700;
  color: white;
  letter-spacing: -0.5px;
}

.header-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 2rem;
  position: relative;
}

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

.mobile-menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: space-around;
  width: 30px;
  height: 30px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px;
  z-index: 1001;
  border-radius: 4px;
  transition: background-color 0.2s ease;
}

.mobile-menu-toggle:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.hamburger-line {
  width: 100%;
  height: 3px;
  background-color: white;
  border-radius: 2px;
  transition: all 0.3s ease;
  transform-origin: center;
}

.mobile-menu-open .hamburger-line:nth-child(1) {
  transform: rotate(45deg) translate(7px, 7px);
}

.mobile-menu-open .hamburger-line:nth-child(2) {
  opacity: 0;
}

.mobile-menu-open .hamburger-line:nth-child(3) {
  transform: rotate(-45deg) translate(7px, -7px);
}

.nav-link {
  color: white;
  text-decoration: none;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  transition: all 0.2s ease;
  position: relative;
}

.nav-link:hover {
  background-color: rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
}

.auth-section {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-greeting {
  color: white;
  font-weight: 500;
  opacity: 0.9;
}

/* Button Styles */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1.5rem;
  border-radius: 6px;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s ease;
  cursor: pointer;
  border: none;
  font-size: 0.9rem;
}

.btn-primary {
  background-color: #6495ED;
  color: white;
}

.btn-primary:hover {
  background-color: #004687;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(40, 74, 167, 0.3);
}

.btn-signin {
  background-color: #6495ED;
  color: white;
  margin-top: 1em;
  width: 100%;
}

.btn-signin:hover {
  background-color: #004687;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(40, 74, 167, 0.3);
}

.btn-signup {
  background-color: #662d91;
  color: white;
  margin-top: 1em;
  width: 100%;
}

.btn-signup:hover {
  background-color: #4B0082;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(40, 74, 167, 0.3);
}

.btn-secondary {
  background-color: #6F00FF;
  color: white;
}

.btn-secondary:hover {
  background-color: #4B0082;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(68, 40, 167, 0.3);
}

.btn-logout {
  background-color: #9e1b32;
  color: white;
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.btn-logout:hover {
  background-color: rgba(78, 5, 5, 0.959);
  border-color: rgba(255, 255, 255, 0.5);
  transform: translateY(-1px);
}

.btn-edit {
  background-color: #662d91;
  color: white;
}

.btn-edit:hover {
  background-color: #452c63;
  transform: translateY(-2px);
}

.btn-delete {
  background-color: #9e1b32;
  color: white;
  margin-top: 1em;
}

.btn-delete:hover {
  background-color: rgba(78, 5, 5, 0.959);
  border-color: rgba(255, 255, 255, 0.5);
  transform: translateY(-1px);
}

.btn-cancel {
  background-color: #662d91;
  color: white;
  height: 2.2em;
}

.btn-cancel:hover {
  background-color: #452c63;
  transform: translateY(-2px);
}

/* Notification Styles */
.notification {
  padding: 1rem 2rem;
  margin: 0;
  position: relative;
  animation: slideDown 0.3s ease;
}

.notification.notice {
  background: linear-gradient(90deg, #d4edda, #c3e6cb);
  border-left: 4px solid #28a745;
  color: #155724;
}

.notification.alert {
  background: linear-gradient(90deg, #f8d7da, #f1aeb5);
  border-left: 4px solid #dc3545;
  color: #721c24;
}

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

.notification-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.2s ease;
}

.notification-close:hover {
  opacity: 1;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Main Content */
.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
  min-height: calc(100vh - 80px);
  text-align: center;
}

/* Back button positioning - override main-content centering */
.main-content > p:first-child {
  text-align: left;
  margin-bottom: 1.5rem;
}

/* Headings */
.main-content h1 {
  margin-bottom: 2rem;
  color: var(--primary-color);
  font-size: 2.5rem;
  font-weight: 700;
}

.main-content h2 {
  margin-bottom: 1.5rem;
  color: var(--secondary-color);
  font-size: 2rem;
  font-weight: 600;
}

/* Legacy nav styles - keeping for compatibility */
nav {
  justify-content: flex-end;
  display: flex;
  font-size: 0.875em;
  gap: 0.5rem;
  max-width: 1024px;
  margin: 0 auto;
  padding: 1rem;
}

nav a {
  display: inline-block;
}

main {
  max-width: 1024px;
  margin: 0 auto;
}

.notice {
  color: green;
}

section.product {
  display: flex;
  gap: 1rem;
  flex-direction: row;
  max-width: 800px;
  margin: 0 auto;
  background: white;
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
}

section.product img {
  border-radius: 8px;
  flex-basis: 50%;
  max-width: 50%;
}

/* Out of stock product styling - modern centered design */
section.product.product-out-of-stock {
  flex-direction: column;
  text-align: center;
  max-width: 500px;
  align-items: center;
}

section.product.product-out-of-stock img {
  max-width: 300px;
  width: 100%;
  height: 300px;
  object-fit: cover;
  flex-basis: auto;
  margin-bottom: 2rem;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

section.product.product-out-of-stock .product-info {
  width: 100%;
  text-align: center;
}

section.product.product-out-of-stock h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 1rem;
  letter-spacing: -0.5px;
}

/* Style the product description when out of stock */
section.product.product-out-of-stock .product-info > p,
section.product.product-out-of-stock .product-info > div:not(.subscriber-form) {
  color: var(--dark-color);
  line-height: 1.6;
  margin-bottom: 1.5rem;
  font-size: 1rem;
  opacity: 0.8;
}

/* Modern subscriber form styling */
.subscriber-form {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  padding: 2rem;
  border-radius: 12px;
  border: 1px solid #e9ecef;
  margin-top: 1.5rem;
  width: 100%;
  max-width: 400px;
}

.subscriber-form p:first-child {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--danger-color);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.subscriber-form p:first-child::before {
  content: "⚠️";
  font-size: 1.1rem;
}

.subscriber-form p:last-of-type {
  font-size: 1rem;
  color: var(--dark-color);
  margin-bottom: 1.5rem;
  font-weight: 500;
}

.subscriber-form form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
  background: transparent;
  padding: 0;
  box-shadow: none;
  margin: 0;
  text-align: left;
}

.subscriber-form form input[type="email"] {
  margin-top: 0;
  padding: 0.875rem 1rem;
  border: 2px solid #e9ecef;
  border-radius: 8px;
  font-size: 1rem;
  background: white;
  transition: all 0.2s ease;
}

.subscriber-form form input[type="email"]:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
  transform: translateY(-1px);
}

.subscriber-form form input[type="submit"] {
  margin-top: 0;
  padding: 0.875rem 1.5rem;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.subscriber-form form input[type="submit"]:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.3);
}

/* Products list styling */
#products {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1.5rem;
  margin-top: 2rem;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}

#products > div {
  background: white;
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  text-align: center;
}

#products > div:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

#products a {
  text-decoration: none;
  color: var(--primary-color);
  font-weight: 500;
  font-size: 1.1rem;
}

#products a:hover {
  color: var(--secondary-color);
}

/* Action links and buttons in main content */
.main-content > a {
  display: inline-block;
  margin: 1rem 0;
}

/* Auth forms styling */
.signup-link {
  display: inline-block;
  padding: 8px 16px;
  background-color: #662d91;
  color: white !important;
  text-decoration: none;
  border-radius: 4px;
  margin-top: 10px;
}

.signup-link:hover {
  background-color: #4B0082;
}

/* Form styling */
form {
  display: inline-block;
  max-width: 500px;
  width: 100%;
  background: white;
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
  text-align: left;
}

form div {
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

/* Form button group for submit and cancel buttons */
form .form-button-group {
  display: inline-block;
  gap: 1rem;
  align-items: center;
  justify-content: flex-start;
}

form label {
  margin-bottom: 8px;
  font-weight: 600;
  color: var(--dark-color);
  font-size: 0.9rem;
}

form input[type="email"],
form input[type="password"],
form input[type="text"],
form input[type="number"],
form input[type="file"],
form textarea,
form trix-editor {
  width: 100%;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  margin-top: 1em;
  font-family: var(--font-family);
  font-size: 0.9rem;
}

/* Special styling for file inputs */
form input[type="file"] {
  padding: 6px;
  background-color: white;
}

/* Focus styles for form inputs */
form input[type="email"]:focus,
form input[type="password"]:focus,
form input[type="text"]:focus,
form input[type="number"]:focus,
form input[type="file"]:focus,
form textarea:focus,
form trix-editor:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Rich text editor specific styling */
form trix-editor {
  min-height: 120px;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 12px;
}

/* Error styling for form validation */
form .field_with_errors input,
form .field_with_errors textarea,
form .field_with_errors trix-editor {
  border-color: var(--danger-color);
  box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
}

/* Form error messages */
form .error-messages {
  background: linear-gradient(90deg, #f8d7da, #f1aeb5);
  border: 1px solid var(--danger-color);
  border-radius: 6px;
  padding: 1rem;
  margin-bottom: 1.5rem;
  color: #721c24;
}

form .error-messages h3 {
  margin: 0 0 0.5rem 0;
  font-size: 1rem;
  font-weight: 600;
}

form .error-messages ul {
  margin: 0;
  padding-left: 1.5rem;
}

form .error-messages li {
  margin-bottom: 0.25rem;
}

/* Default form submit button styles (fallback) */
form input[type="submit"]:not(.btn) {
  background-color: #6495ED;
  color: white;
  padding: 10px 20px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  margin-top: 1em;
  width: 100%;
}

form input[type="submit"]:not(.btn):hover {
  background-color: #004687;
}

/* Ensure btn classes override form input styles */
input[type="submit"].btn {
  padding: 0.5rem 1.5rem;
  border-radius: 6px;
  font-weight: 500;
  transition: all 0.2s ease;
  cursor: pointer;
  border: none;
  font-size: 0.9rem;
}

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

  .mobile-menu-toggle {
    display: flex;
  }

  .nav-links {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 1.5rem;
    flex-direction: column;
    gap: 1rem;
    min-width: 220px;
    transform: translateY(-20px) scale(0.95);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    border: 1px solid rgba(255, 255, 255, 0.1);
  }

  .nav-links-open {
    transform: translateY(0) scale(1) !important;
    opacity: 1 !important;
    visibility: visible !important;
  }

  .nav-links .nav-link {
    width: 100%;
    text-align: center;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    white-space: nowrap;
  }

  .nav-links .btn {
    width: 100%;
    justify-content: center;
  }

  .user-greeting {
    text-align: center;
    padding: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
  }

  .main-content {
    padding: 1rem;
  }

  #products {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
  }

  .main-content h1 {
    font-size: 2rem;
  }

  .main-content h2 {
    font-size: 1.5rem;
  }

  /* Form responsive adjustments */
  form {
    max-width: 100%;
    padding: 1.5rem;
  }

  form input[type="email"],
  form input[type="password"],
  form input[type="text"],
  form input[type="number"],
  form input[type="file"],
  form textarea,
  form trix-editor {
    font-size: 1rem;
  }
}

@media (max-width: 480px) {
  .header-container {
    padding: 0.75rem;
  }

  .store-name {
    font-size: 1.1rem;
  }

  .nav-links {
    right: -0.75rem;
    left: -4rem;
    width: 90% !important;
  }

  .notification {
    padding: 0.75rem 1rem;
  }

  .notification-content {
    flex-direction: column;
    gap: 0.5rem;
    text-align: center;
  }
}
