/*
File: components.css
Purpose: Reusable UI components, buttons, modals, forms, and utility components
Dependencies: style.css (custom properties), animations.css (utility animations)
Load Order: 8th (final file - contains reusable components)
*/

/* ===== BUTTON COMPONENT SYSTEM ===== */
/* Base button class */
.btn {
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: var(--font-weight-semibold);
  padding: 0.75rem 1.5rem;
  text-decoration: none;
  transition: all var(--transition-base);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  text-align: center;
  white-space: nowrap;
  min-width: 120px;
  box-shadow: var(--shadow-sm);
}

/* Primary button - Green outline → Amber fill pattern */
.btn-primary {
  background: #ffffff;
  border-color: var(--forest-green);
  color: var(--forest-green);
}

.btn-primary:hover {
  background: var(--highlight-color);
  border-color: var(--highlight-color);
  color: #ffffff;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* Secondary button - Shadow + scale + brightness pattern */
.btn-secondary {
  background: var(--rust-red);
  border-color: var(--rust-red);
  color: #ffffff;
}

.btn-secondary:hover {
  background: var(--rust-red);
  border-color: var(--rust-red);
  color: #ffffff;
  transform: scale(1.05);
  filter: brightness(1.1);
  box-shadow: var(--shadow-lg);
}

/* Accent button - Tab color theme */
.btn-accent {
  background: var(--tab-color);
  border-color: var(--tab-color);
  color: #ffffff;
}

.btn-accent:hover {
  background: var(--tab-color);
  border-color: var(--tab-color);
  color: #ffffff;
  transform: translateY(-2px);
  filter: brightness(1.1);
  box-shadow: var(--shadow-md);
}

/* Outline button - Transparent with border */
.btn-outline {
  background: transparent;
  border-color: var(--text-color);
  color: var(--text-color);
}

.btn-outline:hover {
  background: var(--text-color);
  border-color: var(--text-color);
  color: var(--forest-green);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

/* Ghost button - Minimal styling */
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--forest-green);
  box-shadow: none;
  min-width: auto;
}

.btn-ghost:hover {
  background: rgba(27, 81, 55, 0.1);
  border-color: transparent;
  color: var(--forest-green);
  transform: none;
  box-shadow: none;
}

/* ===== BUTTON SIZES ===== */
.btn-sm {
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
  min-width: 100px;
}

.btn-lg {
  font-size: 1.125rem;
  padding: 1rem 2rem;
  min-width: 160px;
}

.btn-xl {
  font-size: 1.25rem;
  padding: 1.25rem 2.5rem;
  min-width: 200px;
}

/* ===== BUTTON STATES ===== */
.btn:disabled,
.btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  filter: none !important;
  box-shadow: var(--shadow-sm) !important;
}

.btn.loading {
  pointer-events: none;
  opacity: 0.7;
}

.btn.loading::after {
  content: '';
  width: 16px;
  height: 16px;
  border: 2px solid transparent;
  border-top: 2px solid currentColor;
  border-radius: var(--radius-round);
  animation: spin 1s linear infinite;
  margin-left: 0.5rem;
}

/* ===== BUTTON GROUPS ===== */
.btn-group {
  display: inline-flex;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.btn-group .btn {
  border-radius: 0;
  border-right-width: 1px;
  margin: 0;
  box-shadow: none;
}

.btn-group .btn:first-child {
  border-top-left-radius: var(--radius-sm);
  border-bottom-left-radius: var(--radius-sm);
}

.btn-group .btn:last-child {
  border-top-right-radius: var(--radius-sm);
  border-bottom-right-radius: var(--radius-sm);
  border-right-width: 2px;
}

/* ===== COOKIE BANNER & MODAL SYSTEM ===== */
/* Cookie banner */
.cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-top: 1px solid #e0e0e0;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
  transform: translateY(100%);
  transition: transform 0.4s var(--transition-smooth);
  z-index: var(--z-modal);
  padding: 0;
  opacity: 0;
  visibility: hidden;
}

.cookie-banner.show {
  transform: translateY(0);
  opacity: 1;
  visibility: visible;
}

.cookie-banner.hide {
  transform: translateY(100%);
  opacity: 0;
  visibility: hidden;
}

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

.cookie-text {
  flex: 1;
}

.cookie-text h4 {
  font-family: var(--font-heading);
  color: var(--forest-green);
  margin: 0 0 0.5rem 0;
  font-size: 1.2rem;
  font-weight: var(--font-weight-bold);
}

.cookie-text p {
  font-family: var(--font-primary);
  color: #333;
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.4;
}

.cookie-link {
  color: var(--tab-color);
  text-decoration: underline;
  transition: color var(--transition-base);
}

.cookie-link:hover {
  color: var(--forest-green);
}

.cookie-actions {
  display: flex;
  gap: 1rem;
  flex-shrink: 0;
}

.cookie-btn {
  font-family: var(--font-heading);
  font-weight: var(--font-weight-semibold);
  font-size: 0.95rem;
  padding: 0.75rem 1.5rem;
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-smooth);
  text-decoration: none;
  display: inline-block;
  text-align: center;
  white-space: nowrap;
}

.cookie-btn-accept {
  background: var(--highlight-color);
  color: var(--text-color);
  border-color: var(--highlight-color);
}

.cookie-btn-accept:hover {
  background: #cc9030;
  border-color: #cc9030;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.cookie-btn-settings {
  background: transparent;
  color: var(--forest-green);
  border-color: var(--forest-green);
}

.cookie-btn-settings:hover {
  background: var(--forest-green);
  color: var(--text-color);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* ===== COOKIE SETTINGS MODAL ===== */
.cookie-settings-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: var(--z-tooltip);
  padding: 1.5rem; /* Reduced from 2rem */
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-base);
}

.cookie-settings-modal.show {
  display: flex;
  opacity: 1;
  visibility: visible;
}

.cookie-settings-content {
  background: white;
  border-radius: var(--radius-md);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
  max-width: 600px;
  width: 100%;
  max-height: 90vh; /* Increased from 80vh */
  overflow-y: auto;
  position: relative;
  padding: 1.5rem; /* Reduced from 2rem */
  font-family: var(--font-primary); /* Explicit sans-serif */
  font-size: 0.9rem; /* Reduced base font size */
}

.cookie-settings-close {
  position: absolute;
  top: 0.75rem; /* Reduced positioning */
  right: 0.75rem;
  background: none;
  border: none;
  font-size: 1.25rem; /* Reduced from 1.5rem */
  cursor: pointer;
  color: #666;
  width: 32px; /* Reduced size */
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-round);
  transition: all var(--transition-base);
}

.cookie-settings-close:hover {
  background: #f0f0f0;
  color: #333;
}

.cookie-settings-content h3 {
  font-family: var(--font-heading);
  color: var(--forest-green);
  margin: 0 0 0.75rem 0; /* Reduced from 1rem */
  font-size: 1.4rem; /* Reduced from 1.6rem */
  font-weight: var(--font-weight-bold);
}

.cookie-settings-content p {
  font-family: var(--font-primary);
  color: #333;
  line-height: 1.4; /* Reduced from 1.5 */
  margin: 0 0 1rem 0; /* Reduced from 1.5rem */
  font-size: 0.9rem; /* Reduced from 1rem */
}

.cookie-category {
  margin: 1rem 0; /* Reduced from 1.5rem */
  padding: 0.75rem 0; /* Reduced from 1rem */
  border-bottom: 1px solid #e0e0e0;
}

.cookie-category:last-of-type {
  border-bottom: none;
}

.cookie-category h4 {
  font-family: var(--font-heading);
  color: var(--forest-green);
  margin: 0 0 0.4rem 0; /* Reduced from 0.5rem */
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 1rem; /* Reduced from 1.1rem */
  font-weight: var(--font-weight-semibold);
}

.cookie-category p {
  font-size: 0.9rem; /* Reduced from 1rem */
  color: #666;
  margin: 0.4rem 0 0 0; /* Reduced from 0.5rem */
  line-height: 1.3; /* Reduced from 1.4 */
}

.cookie-settings-actions {
  display: flex;
  gap: 0.75rem; /* Reduced from 1rem */
  justify-content: flex-end;
  margin-top: 1.25rem; /* Reduced from 2rem */
  padding-top: 0.75rem; /* Reduced from 1rem */
  border-top: 1px solid #e0e0e0;
}

.cookie-settings-actions .cookie-btn {
  font-family: var(--font-heading);
  font-weight: var(--font-weight-semibold);
  font-size: 0.9rem; /* Reduced from 1rem */
  padding: 0.6rem 1.2rem; /* Reduced from 0.8rem 1.5rem */
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-smooth);
  text-decoration: none;
  display: inline-block;
  text-align: center;
  min-width: 120px; /* Reduced from 140px */
  box-shadow: var(--shadow-md);
  color: inherit;
  background-color: inherit;
}

#cookieRejectAll {
  background: transparent;
  color: var(--forest-green);
  border-color: var(--forest-green);
}

#cookieRejectAll:hover {
  background: var(--forest-green);
  color: var(--text-color);
  border-color: var(--forest-green);
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

#cookieSavePreferences {
  background: var(--highlight-color);
  color: var(--text-color);
  border-color: var(--highlight-color);
}

#cookieSavePreferences:hover {
  background: #cc9030;
  color: var(--text-color);
  border-color: #cc9030;
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

/* ===== TOGGLE SWITCHES ===== */
.cookie-toggle {
  position: relative;
  display: inline-block;
  width: 44px; /* Reduced from 50px */
  height: 22px; /* Reduced from 24px */
}

.cookie-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.cookie-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: var(--transition-base);
  border-radius: 22px;
}

.cookie-slider:before {
  position: absolute;
  content: "";
  height: 16px; /* Reduced from 18px */
  width: 16px; /* Reduced from 18px */
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: var(--transition-base);
  border-radius: var(--radius-round);
}

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

input:checked + .cookie-slider:before {
  transform: translateX(22px); /* Adjusted for smaller toggle */
}

/* ===== MODAL COMPONENT SYSTEM ===== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  padding: 2rem;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-base);
}

.modal-overlay.show {
  display: flex;
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  padding: 2rem;
  transform: scale(0.9);
  transition: transform var(--transition-base);
}

.modal-overlay.show .modal-content {
  transform: scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.modal-title {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: var(--font-weight-bold);
  color: var(--forest-green);
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #666;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-round);
  transition: all var(--transition-base);
}

.modal-close:hover {
  background: #f0f0f0;
  color: #333;
  transform: rotate(90deg);
}

.modal-body {
  margin-bottom: 1.5rem;
}

.modal-footer {
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
}

/* ===== FORM COMPONENTS ===== */
.form-group {
  margin-bottom: 1.5rem;
}

.form-label {
  display: block;
  font-family: var(--font-heading);
  font-weight: var(--font-weight-semibold);
  color: var(--forest-green);
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}

.form-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid #e0e0e0;
  border-radius: var(--radius-sm);
  font-family: var(--font-primary);
  font-size: 1rem;
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
  background: white;
}

.form-input:focus {
  outline: none;
  border-color: var(--tab-color);
  box-shadow: 0 0 0 3px rgba(79, 154, 168, 0.1);
}

.form-input.error {
  border-color: var(--rust-red);
}

.form-input.error:focus {
  border-color: var(--rust-red);
  box-shadow: 0 0 0 3px rgba(204, 64, 32, 0.1);
}

.form-textarea {
  resize: vertical;
  min-height: 100px;
}

.form-select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 0.5rem center;
  background-repeat: no-repeat;
  background-size: 1.5em 1.5em;
  padding-right: 2.5rem;
}

.form-help {
  font-size: 0.875rem;
  color: #666;
  margin-top: 0.25rem;
}

.form-error {
  font-size: 0.875rem;
  color: var(--rust-red);
  margin-top: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* ===== ALERT COMPONENTS ===== */
.alert {
  padding: 1rem 1.5rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  margin-bottom: 1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.alert-success {
  background: rgba(5, 150, 105, 0.1);
  border-color: rgba(5, 150, 105, 0.2);
  color: #065f46;
}

.alert-warning {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.2);
  color: #92400e;
}

.alert-error {
  background: rgba(204, 64, 32, 0.1);
  border-color: rgba(204, 64, 32, 0.2);
  color: #991b1b;
}

.alert-info {
  background: rgba(79, 154, 168, 0.1);
  border-color: rgba(79, 154, 168, 0.2);
  color: #0c4a6e;
}

.alert-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin-top: 1px;
}

.alert-content {
  flex: 1;
}

.alert-title {
  font-family: var(--font-heading);
  font-weight: var(--font-weight-semibold);
  margin: 0 0 0.25rem 0;
  font-size: 0.95rem;
}

.alert-message {
  font-family: var(--font-primary);
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.4;
}

/* ===== LOADING COMPONENTS ===== */
.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #e0e0e0;
  border-top: 4px solid var(--tab-color);
  border-radius: var(--radius-round);
  animation: spin 1s linear infinite;
  margin: 2rem auto;
}

.loading-dots {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  align-items: center;
  margin: 2rem auto;
}

.loading-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-round);
  background: var(--tab-color);
  animation: pulse 1.4s ease-in-out infinite both;
}

.loading-dot:nth-child(1) { animation-delay: -0.32s; }
.loading-dot:nth-child(2) { animation-delay: -0.16s; }
.loading-dot:nth-child(3) { animation-delay: 0; }

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
  .cookie-content {
    flex-direction: column;
    align-items: flex-start;
    gap: 1.5rem;
    padding: 1.5rem;
  }
  
  .cookie-actions {
    width: 100%;
    justify-content: space-between;
  }
  
  .cookie-btn {
    flex: 1;
    font-size: 0.9rem;
    padding: 0.7rem 1rem;
  }
  
  .cookie-settings-modal {
    padding: 1rem;
  }
  
  .cookie-settings-content {
    padding: 1.5rem;
    margin: 1rem 0;
  }
  
  .btn {
    min-width: 100px;
    padding: 0.7rem 1.2rem;
  }
  
  .btn-group {
    flex-direction: column;
  }
  
  .btn-group .btn {
    border-radius: 0;
    border-bottom-width: 1px;
    border-right-width: 2px;
  }
  
  .btn-group .btn:first-child {
    border-top-left-radius: var(--radius-sm);
    border-top-right-radius: var(--radius-sm);
    border-bottom-left-radius: 0;
  }
  
  .btn-group .btn:last-child {
    border-bottom-left-radius: var(--radius-sm);
    border-bottom-right-radius: var(--radius-sm);
    border-top-right-radius: 0;
    border-bottom-width: 2px;
  }
  
  .modal-content {
    padding: 1.5rem;
    margin: 1rem;
  }
  
  .modal-footer {
    flex-direction: column;
  }
  
  .modal-footer .btn {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .cookie-actions {
    flex-direction: column;
    gap: 0.75rem;
  }
  
  .cookie-btn {
    width: 100%;
  }
  
  .btn-sm {
    font-size: 0.8rem;
    padding: 0.4rem 0.8rem;
    min-width: 80px;
  }
  
  .cookie-settings-actions {
    flex-direction: column;
  }
  
  .cookie-settings-actions .cookie-btn {
    width: 100%;
  }
}

@media (min-width: 768px) {
  .cookie-settings-modal {
    padding: 1rem; /* Reduced for desktop */
  }

  .cookie-settings-content {
    max-height: 600px; /* Fixed height to fit desktop viewports */
    overflow-y: hidden; /* Disable scroll on desktop */
    padding: 1.25rem; /* Reduced for desktop */
  }
}

/* ===== ACCESSIBILITY FEATURES ===== */
@media (prefers-reduced-motion: reduce) {
  .btn:hover,
  .cookie-btn:hover,
  .modal-close:hover {
    transform: none !important;
  }
  
  .loading-spinner,
  .loading-dot {
    animation: none !important;
  }
  
  .modal-content {
    transform: none !important;
  }
}

/* High contrast mode */
@media (prefers-contrast: high) {
  .btn {
    border-width: 3px;
  }
  
  .form-input:focus {
    box-shadow: 0 0 0 4px rgba(79, 154, 168, 0.3);
  }
  
  .alert {
    border-width: 2px;
  }
}

/* Focus states */
.btn:focus-visible,
.cookie-btn:focus-visible,
.form-input:focus-visible,
.modal-close:focus-visible {
  outline: 3px solid var(--highlight-color);
  outline-offset: 2px;
}

/* ===== PRINT STYLES ===== */
@media print {
  .cookie-banner,
  .cookie-settings-modal,
  .modal-overlay,
  .loading-spinner,
  .loading-dots {
    display: none;
  }
  
  .btn {
    background: #f0f0f0 !important;
    color: #000 !important;
    border: 1px solid #ccc !important;
    box-shadow: none !important;
  }
}