/**
 * ============================================================================
 * COOKIES CSS - CORRIGIDO PARA MOBILE
 * ============================================================================
 * 
 * Ficheiro: themes/tratamentes/static/css/cookies.css
 * FIX: Modal height no mobile + toggles funcionais
 * ============================================================================
 */

/* ============================================================================
   BACKDROP COM DEGRADÊ DE OFUSCAÇÃO
   ============================================================================ */

.cookies-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9998;
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.2) 0%,
    rgba(0, 0, 0, 0.4) 30%,
    rgba(0, 0, 0, 0.7) 70%,
    rgba(0, 0, 0, 0.9) 100%
  );
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  opacity: 0;
  transition: all 0.4s ease;
  pointer-events: none;
}

.cookies-backdrop.is-active {
  opacity: 1;
  pointer-events: all;
}

/* ============================================================================
   BANNER PRINCIPAL
   ============================================================================ */

.cookies-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.cookies-banner.is-active {
  transform: translateY(0);
}

.cookies-banner-content {
  background: linear-gradient(
    135deg,
    var(--tratamentes-primary) 0%,
    var(--tratamentes-primary-dark) 100%
  );
  border-top: 3px solid var(--tratamentes-accent);
  padding: 1.5rem 2rem;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.3);
}

.cookies-banner-header {
  display: flex;
  align-items: center;
  margin-bottom: 1rem;
}

.cookies-banner-icon {
  font-size: 2rem;
  color: var(--tratamentes-accent);
  margin-right: 1rem;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.cookies-banner-title {
  color: var(--tratamentes-white);
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.cookies-banner-text {
  color: rgba(255, 255, 255, 0.9);
  line-height: 1.5;
  margin-bottom: 1.5rem;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.cookies-banner-actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

/* Botões usando cores do site */
.cookies-btn-primary {
  background-color: var(--tratamentes-accent) !important;
  border-color: var(--tratamentes-accent) !important;
  color: var(--tratamentes-dark) !important;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(232, 197, 71, 0.3);
}

.cookies-btn-primary:hover {
  background-color: var(--tratamentes-accent-dark) !important;
  border-color: var(--tratamentes-accent-dark) !important;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(232, 197, 71, 0.4);
}

.cookies-btn-secondary {
  background-color: rgba(255, 255, 255, 0.1) !important;
  border-color: rgba(255, 255, 255, 0.3) !important;
  color: var(--tratamentes-white) !important;
  backdrop-filter: blur(10px);
}

.cookies-btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.2) !important;
  transform: translateY(-1px);
}

.cookies-btn-ghost {
  background: transparent !important;
  border: none !important;
  color: rgba(255, 255, 255, 0.8) !important;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--tratamentes-accent);
}

.cookies-btn-ghost:hover {
  color: var(--tratamentes-white) !important;
  text-decoration-color: var(--tratamentes-white);
}

/* ============================================================================
   MODAL DE CONFIGURAÇÕES - MOBILE FRIENDLY
   ============================================================================ */

.cookies-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.cookies-modal.is-active {
  display: flex;
}

.cookies-modal-content {
  background: var(--tratamentes-white);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-width: 600px;
  width: 100%;
  max-height: 85vh; /* IMPORTANTE: Limitar altura no mobile */
  overflow: hidden;
  transform: scale(0.9);
  opacity: 0;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
}

.cookies-modal.is-active .cookies-modal-content {
  transform: scale(1);
  opacity: 1;
}

.cookies-modal-header {
  background: linear-gradient(
    135deg,
    var(--tratamentes-primary) 0%,
    var(--tratamentes-primary-light) 100%
  );
  color: var(--tratamentes-white);
  padding: 1.5rem 2rem;
  position: relative;
  flex-shrink: 0; /* Não encolher */
}

.cookies-modal-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 0.5rem 0;
}

.cookies-modal-subtitle {
  opacity: 0.9;
  margin: 0;
  font-size: 0.9rem;
}

.cookies-modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: var(--tratamentes-white);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cookies-modal-close:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
}

.cookies-modal-body {
  padding: 1.5rem 2rem;
  overflow-y: auto; /* IMPORTANTE: Scroll interno */
  flex: 1; /* Ocupar espaço disponível */
  max-height: calc(85vh - 120px - 80px); /* Altura - header - footer */
}

/* Categorias de cookies - COMPACTAS */
.cookie-category {
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  margin-bottom: 1rem;
  overflow: hidden;
}

.cookie-category-header {
  padding: 1rem 1.5rem;
  background: var(--tratamentes-white);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cookie-category-info {
  display: flex;
  align-items: center;
  flex: 1;
}

.cookie-category-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 1rem;
  color: var(--tratamentes-white);
  font-size: 1rem;
  flex-shrink: 0;
}

.cookie-category-icon.essential {
  background: #28a745;
}

.cookie-category-icon.analytics {
  background: var(--tratamentes-primary);
}

.cookie-category-icon.maps {
  background: var(--tratamentes-accent);
  color: var(--tratamentes-dark);
}

.cookie-category-icon.social {
  background: #6f42c1;
}

.cookie-category-details h3 {
  font-weight: 600;
  color: var(--tratamentes-dark);
  margin: 0 0 0.25rem 0;
  font-size: 1rem;
}

.cookie-category-details p {
  color: #6c757d;
  font-size: 0.85rem;
  margin: 0;
  line-height: 1.3;
}

/* ============================================================================
   TOGGLE SWITCH - CORRIGIDO PARA CLIQUES FUNCIONAREM
   ============================================================================ */

.cookie-toggle {
  position: relative;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
}

.cookie-toggle input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
  z-index: 2; /* IMPORTANTE: Input por cima do slider */
}

.cookie-toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #cdd4da;
  border-radius: 13px;
  transition: all 0.3s ease;
  z-index: 1; /* Slider por baixo do input */
  pointer-events: none; /* IMPORTANTE: Não capturar cliques */
}

.cookie-toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 4px;
  bottom: 4px;
  background: var(--tratamentes-white, #ffffff);
  border-radius: 50%;
  transition: all 0.3s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  pointer-events: none; /* IMPORTANTE: Não capturar cliques */
}

/* Estados do toggle */
.cookie-toggle input:checked + .cookie-toggle-slider {
  background: var(--tratamentes-primary, #3c6e71);
}

.cookie-toggle input:checked + .cookie-toggle-slider:before {
  transform: translateX(22px);
}

.cookie-toggle input:disabled + .cookie-toggle-slider {
  background: #28a745;
  cursor: not-allowed;
}

.cookie-toggle input:disabled {
  cursor: not-allowed;
}

/* Estados de foco para acessibilidade */
.cookie-toggle input:focus + .cookie-toggle-slider {
  outline: 3px solid var(--tratamentes-accent, #e8c547);
  outline-offset: 2px;
}

/* Hover effect */
.cookie-toggle:hover .cookie-toggle-slider:before {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* ============================================================================
   BOTÃO FLUTUANTE
   ============================================================================ */

.cookies-float {
  position: fixed;
  bottom: 2rem;
  left: 2rem;
  z-index: 9997;
  opacity: 0;
  transform: scale(0.8);
  transition: all 0.4s ease;
  display: none;
}

.cookies-float.is-active {
  display: block;
  opacity: 1;
  transform: scale(1);
}

.cookies-float-btn {
  width: 56px;
  height: 56px;
  background: var(--tratamentes-primary);
  color: var(--tratamentes-white);
  border: none;
  border-radius: 50%;
  font-size: 1.4rem;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(60, 110, 113, 0.4);
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cookies-float-btn:hover {
  background: var(--tratamentes-primary-dark);
  transform: translateY(-4px) scale(1.1);
  box-shadow: 0 8px 30px rgba(60, 110, 113, 0.5);
}

/* ============================================================================
   RESPONSIVIDADE MOBILE - MELHORADA
   ============================================================================ */

@media screen and (max-width: 768px) {
  .cookies-banner-content {
    padding: 1rem 1.5rem;
  }
  
  .cookies-banner-header {
    flex-direction: column;
    align-items: flex-start;
    margin-bottom: 0.75rem;
  }
  
  .cookies-banner-icon {
    margin-right: 0;
    margin-bottom: 0.5rem;
  }
  
  .cookies-banner-actions {
    flex-direction: column;
    width: 100%;
  }
  
  .cookies-banner-actions .button {
    width: 100%;
    justify-content: center;
  }
  
  /* Modal mobile - CORRIGIDO */
  .cookies-modal {
    padding: 0.5rem;
    align-items: flex-start; /* Alinhar ao topo */
    padding-top: 10vh; /* Espaço do topo */
  }
  
  .cookies-modal-content {
    margin: 0;
    max-height: 80vh; /* Menor no mobile */
    width: 100%;
  }
  
  .cookies-modal-header {
    padding: 1rem 1.5rem;
  }
  
  .cookies-modal-title {
    font-size: 1.1rem;
  }
  
  .cookies-modal-subtitle {
    font-size: 0.85rem;
  }
  
  .cookies-modal-body {
    padding: 1rem 1.5rem;
    max-height: calc(80vh - 100px - 70px); /* Ajustado */
  }
  
  .cookie-category-header {
    padding: 0.75rem 1rem;
  }
  
  .cookie-category-icon {
    width: 32px;
    height: 32px;
    margin-right: 0.75rem;
  }
  
  .cookie-category-details h3 {
    font-size: 0.9rem;
  }
  
  .cookie-category-details p {
    font-size: 0.8rem;
  }
  
  .cookies-modal-footer {
    padding: 0.75rem 1.5rem 1rem;
    flex-direction: column;
  }
  
  .cookies-modal-footer .button {
    width: 100%;
    justify-content: center;
  }
  
  .cookies-float {
    bottom: 1rem;
    left: 1rem;
  }
  
  .cookies-float-btn {
    width: 48px;
    height: 48px;
    font-size: 1.2rem;
  }
}

/* ============================================================================
   ACESSIBILIDADE
   ============================================================================ */

.cookies-banner .button:focus,
.cookie-toggle input:focus + .cookie-toggle-slider,
.cookies-float-btn:focus,
.cookies-modal-close:focus {
  outline: 3px solid var(--tratamentes-accent);
  outline-offset: 2px;
}

@media (prefers-contrast: high) {
  .cookies-backdrop {
    background: rgba(0, 0, 0, 0.8);
  }
  
  .cookie-category {
    border-width: 2px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

/* ============================================================================
   UTILITIES
   ============================================================================ */

.cookies-blocked {
  display: none;
}

.cookies-blocked.is-allowed {
  display: block;
}

.cookies-loading {
  pointer-events: none;
  opacity: 0.7;
}






