/**
 * SmartAgenda Cookie Consent Styles
 * GDPR/ePrivacy Compliant Implementation
 *
 * Matches Silicon Bootstrap 5 theme with --si-* CSS variables
 * Supports light/dark mode via data-bs-theme attribute
 */

/* ============================================
   COOKIE CONSENT OVERLAY
   Dims the background until user makes a choice
   ============================================ */

.cookie-consent-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1054; /* Below banner (1055) but above everything else */
  opacity: 1;
  transition: opacity 0.3s ease-in-out;
}

.cookie-consent-overlay[hidden] {
  display: block !important;
  opacity: 0;
  pointer-events: none;
}

/* ============================================
   COOKIE CONSENT BANNER
   Fixed bottom position, slide-up animation
   ============================================ */

.cookie-consent-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1055; /* Same as Bootstrap modal backdrop */
  background-color: var(--si-body-bg, #fff);
  border-top: 1px solid var(--si-border-color, #e2e5f1);
  box-shadow: 0 -0.5rem 1.5rem rgba(11, 15, 25, 0.1);
  padding: 1.25rem 0;
  transform: translateY(0);
  transition: transform 0.3s ease-in-out, opacity 0.3s ease-in-out;
}

/* Hidden state with animation */
.cookie-consent-banner[hidden] {
  display: block !important; /* Override default hidden for animation */
  transform: translateY(100%);
  opacity: 0;
  pointer-events: none;
}

/* Dark mode support */
[data-bs-theme="dark"] .cookie-consent-banner {
  background-color: var(--si-dark-mode-body-bg, #0b0f19);
  border-top-color: var(--si-dark-mode-border-color, #252a3a);
  box-shadow: 0 -0.5rem 1.5rem rgba(0, 0, 0, 0.3);
}

/* Content layout */
.cookie-consent-content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

@media (min-width: 992px) {
  .cookie-consent-content {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
  }
}

/* Text section */
.cookie-consent-text {
  flex: 1;
}

.cookie-consent-text h6 {
  color: var(--si-heading-color, #121519);
  display: flex;
  align-items: center;
}

[data-bs-theme="dark"] .cookie-consent-text h6 {
  color: var(--si-dark-mode-heading-color, #fff);
}

.cookie-consent-text p {
  color: var(--si-body-color, #565973);
  margin-bottom: 0;
}

[data-bs-theme="dark"] .cookie-consent-text p {
  color: var(--si-dark-mode-body-color, #b4b7c9);
}

/* Actions section - buttons */
.cookie-consent-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

@media (min-width: 576px) {
  .cookie-consent-actions {
    flex-wrap: nowrap;
  }
}

/*
 * GDPR Requirement: Equal visual weight for Accept and Reject
 * Both use same button style (outline-secondary)
 * Only "Accept all" uses primary color for positive action
 */
.cookie-consent-actions .btn {
  flex: 1;
  min-width: 120px;
  white-space: nowrap;
}

@media (min-width: 992px) {
  .cookie-consent-actions .btn {
    flex: none;
  }
}

/* ============================================
   COOKIE PREFERENCES MODAL
   Extends Bootstrap modal styling
   ============================================ */

#cookie-preferences-modal .modal-header {
  border-bottom-color: var(--si-border-color, #e2e5f1);
}

#cookie-preferences-modal .modal-title {
  display: flex;
  align-items: center;
  color: var(--si-heading-color, #121519);
}

[data-bs-theme="dark"] #cookie-preferences-modal .modal-title {
  color: var(--si-dark-mode-heading-color, #fff);
}

#cookie-preferences-modal .modal-footer {
  border-top-color: var(--si-border-color, #e2e5f1);
}

/* Category sections with card-like styling */
.cookie-category {
  padding: 1rem;
  background-color: var(--si-secondary-bg, #f3f6ff);
  border-radius: var(--si-border-radius, 0.5rem);
  border: 1px solid var(--si-border-color, #e2e5f1);
}

[data-bs-theme="dark"] .cookie-category {
  background-color: var(--si-dark-mode-secondary-bg, #181d2c);
  border-color: var(--si-dark-mode-border-color, #252a3a);
}

.cookie-category h6 {
  color: var(--si-heading-color, #121519);
}

[data-bs-theme="dark"] .cookie-category h6 {
  color: var(--si-dark-mode-heading-color, #fff);
}

.cookie-category p {
  color: var(--si-body-color, #565973);
}

[data-bs-theme="dark"] .cookie-category p {
  color: var(--si-dark-mode-body-color, #b4b7c9);
}

/* Toggle switch styling */
.cookie-category .form-switch {
  padding-left: 3rem;
  min-height: 1.5rem;
}

.cookie-category .form-check-input {
  width: 2.5rem;
  height: 1.25rem;
  margin-left: -3rem;
  cursor: pointer;
  background-color: var(--si-gray-400, #c5c7d3);
}

.cookie-category .form-check-input:checked {
  background-color: var(--si-primary, #6366f1);
  border-color: var(--si-primary, #6366f1);
}

/* Disabled state for "Strictly Necessary" toggle */
.cookie-category .form-check-input:disabled {
  opacity: 0.8;
  cursor: not-allowed;
}

.cookie-category .form-check-input:disabled:checked {
  background-color: var(--si-success, #22c55e);
  border-color: var(--si-success, #22c55e);
}

/* ============================================
   ACCESSIBILITY
   Focus styles, screen reader support
   ============================================ */

/* Enhanced focus styles for keyboard navigation */
.cookie-consent-banner .btn:focus-visible,
#cookie-preferences-modal .btn:focus-visible,
#cookie-preferences-modal .form-check-input:focus-visible,
#cookie-preferences-modal .btn-close:focus-visible {
  outline: 2px solid var(--si-primary, #6366f1);
  outline-offset: 2px;
  box-shadow: none;
}

/* Screen reader only text (Bootstrap's visually-hidden) */
.cookie-consent-banner .visually-hidden,
#cookie-preferences-modal .visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   Mobile-first approach
   ============================================ */

@media (max-width: 575.98px) {
  .cookie-consent-banner {
    padding: 1rem 0;
  }

  .cookie-consent-actions {
    flex-direction: column;
  }

  .cookie-consent-actions .btn {
    width: 100%;
  }

  /* Stack modal content better on mobile */
  #cookie-preferences-modal .modal-body {
    padding: 1rem;
  }

  .cookie-category {
    padding: 0.875rem;
  }
}

/* ============================================
   PRINT STYLES
   Hide consent UI when printing
   ============================================ */

@media print {
  .cookie-consent-banner,
  #cookie-preferences-modal {
    display: none !important;
  }
}
