/**
 * GDPR-Compliant Cookie Consent Banner Styles
 * 
 * This CSS provides complete styling for the cookie consent management system
 * with responsive design, accessibility features, and modern UI components.
 * 
 * Features:
 * - Responsive cookie banner with main and options views
 * - Toggle switches for granular consent categories
 * - Persistent cookie settings icon
 * - Smooth animations and transitions
 * - Accessibility-friendly focus states
 * - Mobile-optimized layouts
 * 
 * CSS Variables Required:
 * --bg-primary, --bg-secondary, --bg-accent
 * --text-primary, --text-secondary
 * --border-color, --accent-color
 */

/* CSS Variables for Dark Banner Theme */
:root {
  --bg-primary: rgba(45, 45, 45, 0.95);
  --bg-secondary: rgba(55, 55, 55, 0.9);
  --bg-accent: rgba(65, 65, 65, 0.8);
  --text-primary: #ffffff;
  --text-secondary: #e0e0e0;
  --border-color: rgba(255, 255, 255, 0.2);
  --accent-color: #007acc;
}

/* Cookie Options Subtitle in White */
.cookie-options-view .cookie-header p {
  color: #ffffff !important;
  font-weight: 400;
}

/* Privacy Policy Links in Cookie Banner */
.cookie-banner a {
  color: #4da6ff !important;
  text-decoration: underline;
}

.cookie-banner a:hover {
  color: #66b3ff !important;
  opacity: 0.8;
}

/* Scrollable Cookie Categories for Mobile */
.cookie-categories {
  max-height: 300px;
  overflow-y: auto;
  padding-right: 8px;
  margin-bottom: 1rem;
}

.cookie-categories::-webkit-scrollbar {
  width: 6px;
}

.cookie-categories::-webkit-scrollbar-track {
  background: var(--bg-secondary);
  border-radius: 3px;
}

.cookie-categories::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

.cookie-categories::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.4);
}

@media (max-width: 768px) {
  .cookie-categories {
    max-height: 200px;
  }
}

/* Cookie Banner Main Container */
.cookie-banner {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 2rem;
  max-width: 700px;
  width: calc(100% - 2rem);
  z-index: 9999;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* Cookie Banner Layout Views */
.cookie-main-view {
  display: block;
}

.cookie-options-view {
  display: none;
}

.cookie-banner.show-options .cookie-main-view {
  display: none !important;
}

.cookie-banner.show-options .cookie-options-view {
  display: block !important;
}

/* Cookie Options Scrollable Container */
.cookie-options-scrollable {
  max-height: 60vh;
  overflow-y: auto;
  margin: 1rem 0;
  padding-right: 0.5rem;
}

/* Scrollbar styling for cookie options */
.cookie-options-scrollable::-webkit-scrollbar {
  width: 6px;
}

.cookie-options-scrollable::-webkit-scrollbar-track {
  background: var(--bg-accent);
  border-radius: 3px;
}

.cookie-options-scrollable::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

.cookie-options-scrollable::-webkit-scrollbar-thumb:hover {
  background: var(--accent-color);
}

/* Cookie Banner Header */
.cookie-header h3 {
  margin-bottom: 1rem;
  font-size: 1.3rem;
  color: var(--text-primary);
  font-weight: 600;
  line-height: 1.3;
}

.cookie-text p {
  margin-bottom: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.5;
  font-size: 0.9rem;
}

.cookie-text p:last-child {
  margin-bottom: 0;
}

/* Cookie Categories */
.cookie-categories {
  margin: 1.5rem 0;
}

.cookie-category {
  margin-bottom: 1.25rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem;
  background: var(--bg-secondary);
  transition: all 0.3s ease;
}

.cookie-category:hover {
  border-color: var(--accent-color);
  background: var(--bg-accent);
}

.cookie-category-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.category-info {
  flex: 1;
}

.category-info strong {
  display: block;
  color: var(--text-primary);
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.category-info small {
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.4;
}

.category-control {
  flex-shrink: 0;
}

/* Required Badge */
.required-badge {
  background: var(--accent-color);
  color: white;
  padding: 0.4rem 0.8rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Toggle Switch Styles */
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 24px;
}

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

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--bg-accent);
  border: 1px solid var(--border-color);
  transition: 0.3s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.switch input:checked + .slider {
  background-color: var(--accent-color);
  border-color: var(--accent-color);
}

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

.switch input:focus + .slider {
  box-shadow: 0 0 0 2px rgba(123, 22, 255, 0.2);
}

/* Cookie Consent ID Section */
.cookie-consent-id-section {
  margin-top: 1.5rem;
  padding: 1rem;
  background: var(--bg-accent);
  border: 1px solid var(--border-color);
  border-radius: 8px;
}

.cookie-id-info h4 {
  margin-bottom: 0.5rem;
  color: var(--text-primary);
  font-size: 0.9rem;
  font-weight: 600;
}

.cookie-id-info code {
  display: block;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  padding: 0.5rem;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 0.8rem;
  color: var(--text-primary);
  word-break: break-all;
  margin-bottom: 0.5rem;
}

.cookie-id-info p {
  margin-bottom: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.btn-copy-id {
  font-size: 0.8rem !important;
  padding: 0.4rem 0.8rem !important;
}

/* Cookie Banner Actions */
.cb-actions-main {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 1.5rem;
}

.cb-actions-options {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  margin-top: 1.5rem;
}

/* Button Styles */
.btn {
  background: var(--bg-accent);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.7rem 1.2rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-width: 120px;
  user-select: none;
}

.btn:hover {
  background: var(--accent-color);
  color: white;
  border-color: var(--accent-color);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn:active {
  transform: translateY(0);
}

.btn:focus {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

/* Button Variants */
.btn-primary {
  background: var(--accent-color);
  color: white;
  border-color: var(--accent-color);
}

.btn-primary:hover {
  background: var(--accent-color);
  opacity: 0.9;
  transform: translateY(-1px);
}

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

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
}

/* Technical-only banner styling */
.cookie-banner.technical-only {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
}

.cookie-banner.technical-only .cookie-buttons {
  justify-content: center;
  margin-top: 1rem;
}

.cookie-banner.technical-only .btn-primary {
  min-width: 120px;
  padding: 12px 24px;
  font-weight: 500;
  cursor: pointer;
}

/* Cookie Settings Icon (persistent when consent given) */
.cookie-settings-icon {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.4) !important;
  border: 1px solid rgba(150, 150, 150, 0.3);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 9998;
  opacity: 0;
  transform: scale(0.8);
  pointer-events: none;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.cookie-settings-icon.visible {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

.cookie-settings-icon:hover {
  background: rgba(255, 255, 255, 0.95) !important;
  transform: scale(1.1);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
  border-color: rgba(222, 184, 135, 0.6);
}

.cookie-settings-icon svg {
  width: 24px;
  height: 24px;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.3));
}

/* Tooltip for cookie icon */
.cookie-settings-icon::before {
  content: 'Cookie Settings';
  position: absolute;
  bottom: 100%;
  right: 0;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.8rem;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(-5px);
  transition: all 0.3s ease;
  pointer-events: none;
  z-index: 10000;
}

.cookie-settings-icon:hover::before {
  opacity: 1;
  transform: translateY(-8px);
}

/* Animation for icon appearance */
@keyframes cookieIconSlideIn {
  from {
    opacity: 0;
    transform: translateX(100px) scale(0.5);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

.cookie-settings-icon.slide-in {
  animation: cookieIconSlideIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Banner slide-down animation */
@keyframes slideDown {
  to {
    opacity: 0;
    transform: translateX(-50%) translateY(100px);
  }
}

/* Focus Management */
button:focus:not(:focus-visible) {
  outline: none;
}

.btn:focus:not(:focus-visible) {
  outline: none;
}

/* Responsive Design */
@media (max-width: 768px) {
  .cookie-settings-icon {
    bottom: 1.5rem;
    right: 1.5rem;
    width: 42px;
    height: 42px;
  }
  
  .cookie-settings-icon svg {
    width: 22px;
    height: 22px;
  }
  
  .cookie-settings-icon::before {
    font-size: 0.7rem;
    padding: 0.4rem 0.6rem;
  }
  
  .cookie-banner {
    bottom: 1rem;
    width: calc(100% - 1rem);
    padding: 1.5rem;
    max-width: none;
    max-height: 85vh;
  }
  
  .cookie-options-scrollable {
    max-height: 50vh;
  }
  
  .cb-actions-main,
  .cb-actions-options {
    flex-direction: column;
  }
  
  .cb-actions-options {
    justify-content: center;
  }
  
  .btn {
    flex: none;
    min-width: auto;
    width: 100%;
  }
  
  .cookie-category {
    padding: 0.75rem;
  }
  
  .cookie-category-content {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
  
  .category-control {
    align-self: flex-end;
  }
  
  .cookie-text {
    max-height: 8rem;
    overflow-y: auto;
    padding-right: 0.5rem;
  }
  
  .cookie-text::-webkit-scrollbar {
    width: 4px;
  }
  
  .cookie-text::-webkit-scrollbar-track {
    background: var(--bg-accent);
    border-radius: 2px;
  }
  
  .cookie-text::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 2px;
  }
  
  .cookie-text::-webkit-scrollbar-thumb:hover {
    background: var(--accent-color);
  }
  
  .cookie-text p {
    font-size: 0.85rem;
  }
  
  .cookie-header h3 {
    font-size: 1.2rem;
  }
}

@media (max-width: 480px) {
  .cookie-banner {
    padding: 1rem;
    bottom: 0.5rem;
    width: calc(100% - 0.5rem);
    border-radius: 8px;
  }
  
  .cookie-settings-icon {
    bottom: 1rem;
    right: 1rem;
    width: 40px;
    height: 40px;
  }
  
  .cookie-settings-icon svg {
    width: 20px;
    height: 20px;
  }
  
  .btn {
    padding: 0.6rem 1rem;
    font-size: 0.85rem;
  }
  
  .switch {
    width: 45px;
    height: 22px;
  }
  
  .slider:before {
    height: 16px;
    width: 16px;
  }
  
  .switch input:checked + .slider:before {
    transform: translateX(23px);
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .cookie-banner {
    border: 2px solid var(--text-primary);
  }
  
  .btn {
    border: 2px solid var(--border-color);
  }
  
  .switch {
    border: 2px solid var(--text-primary);
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .cookie-banner,
  .cookie-settings-icon,
  .btn,
  .slider,
  .slider:before {
    transition: none;
  }
  
  .cookie-settings-icon.slide-in {
    animation: none;
  }
}

/* Print styles */
@media print {
  .cookie-banner,
  .cookie-settings-icon {
    display: none !important;
  }
}