/**
 * Accessible Cookie Banner
 * Main stylesheet with WCAG 2.2 AA compliance focus
 */

/* CSS Variables for theming */
:root {
  /* Light theme (default) */
  --cookie-bg: #ffffff;
  --cookie-text: #111111;
  --cookie-border: #dddddd;
  --cookie-button-primary-bg: #0056b3;
  --cookie-button-primary-text: #ffffff;
  --cookie-button-secondary-bg: #f8f9fa;
  --cookie-button-secondary-text: #212529;
  --cookie-button-secondary-border: #dee2e6;
  --cookie-modal-overlay: rgba(0, 0, 0, 0.5);
  --cookie-focus-outline: 3px solid #4d90fe;
}

/* Dark theme */
.theme-dark {
  --cookie-bg: #333333;
  --cookie-text: #f8f9fa;
  --cookie-border: #555555;
  --cookie-button-primary-bg: #0d6efd;
  --cookie-button-primary-text: #ffffff;
  --cookie-button-secondary-bg: #444444;
  --cookie-button-secondary-text: #f8f9fa;
  --cookie-button-secondary-border: #666666;
  --cookie-focus-outline: 3px solid #4d90fe;
}

/* High contrast theme */
.theme-high-contrast {
  --cookie-bg: #000000;
  --cookie-text: #ffffff;
  --cookie-border: #ffffff;
  --cookie-button-primary-bg: #ffff00;
  --cookie-button-primary-text: #000000;
  --cookie-button-secondary-bg: #000000;
  --cookie-button-secondary-text: #ffffff;
  --cookie-button-secondary-border: #ffffff;
  --cookie-focus-outline: 3px solid #ffff00;
}

/* Base styles */
#cookie-banner {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  padding: 1rem;
  background-color: var(--cookie-bg);
  color: var(--cookie-text);
  border-top: 1px solid var(--cookie-border);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  box-sizing: border-box;
  line-height: 1.5;
}

@media (min-width: 768px) {
  #cookie-banner {
    flex-direction: row;
  }
}

#cookie-description {
  margin: 0 0 1rem 0;
  max-width: 60ch;
  font-size: 1rem;
}

@media (min-width: 768px) {
  #cookie-description {
    margin: 0 1rem 0 0;
  }
}

.cookie-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Button styles */
#cookie-banner button,
#cookie-modal button {
  padding: 0.5rem 1rem;
  border-radius: 4px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  min-width: 120px;
  transition: background-color 0.2s, transform 0.1s;
}

/* Primary buttons (Accept All) */
#accept-all {
  background-color: var(--cookie-button-primary-bg);
  color: var(--cookie-button-primary-text);
  border: none;
}

#accept-all:hover,
#accept-all:focus {
  background-color: color-mix(in srgb, var(--cookie-button-primary-bg) 90%, black);
}

/* Secondary buttons (Reject All, Customize) */
#reject-all,
#customize-preferences,
#close-modal {
  background-color: var(--cookie-button-secondary-bg);
  color: var(--cookie-button-secondary-text);
  border: 1px solid var(--cookie-button-secondary-border);
}

#reject-all:hover,
#customize-preferences:hover,
#close-modal:hover,
#reject-all:focus,
#customize-preferences:focus,
#close-modal:focus {
  background-color: color-mix(in srgb, var(--cookie-button-secondary-bg) 90%, black);
}

/* Focus styles for accessibility */
#cookie-banner button:focus,
#cookie-modal button:focus,
#cookie-modal input:focus {
  outline: var(--cookie-focus-outline);
  outline-offset: 2px;
}

/* Active button state */
#cookie-banner button:active,
#cookie-modal button:active {
  transform: scale(0.98);
}

/* Modal styles */
#cookie-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--cookie-modal-overlay);
  z-index: 9998;
}

#cookie-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 9999;
  background-color: var(--cookie-bg);
  color: var(--cookie-text);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  padding: 2rem;
  max-width: 500px;
  width: calc(100% - 2rem);
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  box-sizing: border-box;
}

#modal-title {
  margin-top: 0;
  margin-bottom: 1.5rem;
  font-size: 1.5rem;
}

/* Form elements */
#cookie-form fieldset {
  border: 1px solid var(--cookie-border);
  margin-bottom: 1rem;
  padding: 1rem;
  border-radius: 4px;
}

#cookie-form legend {
  font-weight: bold;
  padding: 0 0.5rem;
}

#cookie-form label {
  display: flex;
  align-items: center;
  margin-bottom: 0.5rem;
}

#cookie-form input[type="checkbox"] {
  margin-right: 0.5rem;
  width: 1.25rem;
  height: 1.25rem;
}

.cookie-description {
  margin-top: 0.5rem;
  margin-bottom: 0;
  font-size: 0.9rem;
}

.cookie-modal-actions {
  margin-top: 1.5rem;
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
}

/* RTL support */
[dir="rtl"] #cookie-form input[type="checkbox"] {
  margin-right: 0;
  margin-left: 0.5rem;
}

[dir="rtl"] #cookie-description {
  margin: 0 0 1rem 0;
}

@media (min-width: 768px) {
  [dir="rtl"] #cookie-description {
    margin: 0 0 0 1rem;
  }
}

/* Animations */
@keyframes cookieBannerSlideIn {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

@keyframes cookieModalFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

#cookie-banner {
  animation: cookieBannerSlideIn 0.5s ease-out;
}

#cookie-modal,
#cookie-modal-overlay {
  animation: cookieModalFadeIn 0.3s ease-out;
}