/**
 * Cookie Consent Styles
 *
 * Stili personalizzati per il banner e il modal delle preferenze
 * Compatibile con la libreria orestbida/cookieconsent
 */

/* ============================================================
   CSS Variables - Tema Base
   ============================================================ */
:root {
  /* Colori primari */
  --cc-primary: #1a73e8;
  --cc-primary-hover: #1557b0;
  --cc-secondary: #5f6368;
  --cc-secondary-hover: #3c4043;

  /* Colori sfondo */
  --cc-bg: #ffffff;
  --cc-bg-overlay: rgba(0, 0, 0, 0.65);

  /* Colori testo */
  --cc-text: #333333;
  --cc-text-light: #666666;
  --cc-text-muted: #888888;

  /* Bordi */
  --cc-border: #e0e0e0;
  --cc-border-radius: 8px;

  /* Ombre */
  --cc-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
  --cc-shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.2);

  /* Transizioni */
  --cc-transition: 0.25s ease;

  /* Z-index */
  --cc-z-index: 999999;
}

/* Tema scuro */
[data-cc-theme="dark"] {
  --cc-bg: #1a1a2e;
  --cc-text: #f5f5f5;
  --cc-text-light: #cccccc;
  --cc-text-muted: #999999;
  --cc-border: #333355;
  --cc-primary: #4d9fff;
  --cc-primary-hover: #3d8df0;
}

/* ============================================================
   Banner Principale
   ============================================================ */
#cc-main {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--cc-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Overlay */
.cc--overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--cc-bg-overlay);
  z-index: var(--cc-z-index);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--cc-transition), visibility var(--cc-transition);
}

.cc--overlay.cc--visible {
  opacity: 1;
  visibility: visible;
}

/* Container Banner */
.cc-banner {
  position: fixed;
  z-index: calc(var(--cc-z-index) + 1);
  background: var(--cc-bg);
  box-shadow: var(--cc-shadow-lg);
  transform: translateY(100%);
  transition: transform var(--cc-transition);
}

.cc-banner.cc--visible {
  transform: translateY(0);
}

/* Posizioni */
.cc-banner--bottom {
  bottom: 0;
  left: 0;
  right: 0;
}

.cc-banner--top {
  top: 0;
  left: 0;
  right: 0;
  transform: translateY(-100%);
}

.cc-banner--top.cc--visible {
  transform: translateY(0);
}

.cc-banner--middle {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  max-width: 600px;
  border-radius: var(--cc-border-radius);
}

.cc-banner--middle.cc--visible {
  transform: translate(-50%, -50%) scale(1);
}

/* Layout Bar */
.cc-banner--bar {
  padding: 20px;
}

.cc-banner--bar .cc-banner__content {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 20px;
  max-width: 1400px;
  margin: 0 auto;
}

.cc-banner--bar .cc-banner__text {
  flex: 1;
  min-width: 300px;
}

.cc-banner--bar .cc-banner__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* Layout Box */
.cc-banner--box {
  max-width: 400px;
  padding: 24px;
  border-radius: var(--cc-border-radius);
}

.cc-banner--box.cc-banner--bottom {
  bottom: 20px;
  left: 20px;
  right: auto;
}

.cc-banner--box .cc-banner__actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}

/* ============================================================
   Contenuto Banner
   ============================================================ */
.cc-banner__title {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 10px;
  color: var(--cc-text);
}

.cc-banner__description {
  margin: 0;
  color: var(--cc-text-light);
  font-size: 13px;
  line-height: 1.6;
}

.cc-banner__link {
  color: var(--cc-primary);
  text-decoration: none;
}

.cc-banner__link:hover {
  text-decoration: underline;
}

/* ============================================================
   Pulsanti
   ============================================================ */
.cc-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--cc-transition), transform var(--cc-transition);
  white-space: nowrap;
}

.cc-btn:hover {
  transform: translateY(-1px);
}

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

/* Pulsante primario - Accetta tutti */
.cc-btn--primary {
  background: var(--cc-primary);
  color: #ffffff;
}

.cc-btn--primary:hover {
  background: var(--cc-primary-hover);
}

/* Pulsante secondario - Rifiuta/Solo necessari */
.cc-btn--secondary {
  background: var(--cc-secondary);
  color: #ffffff;
}

.cc-btn--secondary:hover {
  background: var(--cc-secondary-hover);
}

/* Pulsante outline - Personalizza */
.cc-btn--outline {
  background: transparent;
  border: 1px solid var(--cc-border);
  color: var(--cc-text);
}

.cc-btn--outline:hover {
  background: rgba(0, 0, 0, 0.05);
  border-color: var(--cc-text-muted);
}

/* ============================================================
   Modal Preferenze
   ============================================================ */
.cc-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: calc(var(--cc-z-index) + 2);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--cc-transition), visibility var(--cc-transition);
}

.cc-modal.cc--visible {
  opacity: 1;
  visibility: visible;
}

.cc-modal__overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--cc-bg-overlay);
}

.cc-modal__container {
  position: relative;
  background: var(--cc-bg);
  border-radius: var(--cc-border-radius);
  box-shadow: var(--cc-shadow-lg);
  max-width: 700px;
  max-height: 90vh;
  width: 100%;
  display: flex;
  flex-direction: column;
  transform: scale(0.95);
  transition: transform var(--cc-transition);
}

.cc-modal.cc--visible .cc-modal__container {
  transform: scale(1);
}

/* Header Modal */
.cc-modal__header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--cc-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cc-modal__title {
  font-size: 20px;
  font-weight: 600;
  margin: 0;
  color: var(--cc-text);
}

.cc-modal__close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--cc-text-muted);
  cursor: pointer;
  padding: 5px;
  line-height: 1;
  transition: color var(--cc-transition);
}

.cc-modal__close:hover {
  color: var(--cc-text);
}

/* Body Modal */
.cc-modal__body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.cc-modal__description {
  margin: 0 0 24px;
  color: var(--cc-text-light);
  font-size: 14px;
  line-height: 1.6;
}

/* Footer Modal */
.cc-modal__footer {
  padding: 16px 24px;
  border-top: 1px solid var(--cc-border);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

/* ============================================================
   Categorie Cookie
   ============================================================ */
.cc-category {
  border: 1px solid var(--cc-border);
  border-radius: var(--cc-border-radius);
  margin-bottom: 16px;
  overflow: hidden;
}

.cc-category__header {
  display: flex;
  align-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.02);
  cursor: pointer;
  transition: background var(--cc-transition);
}

.cc-category__header:hover {
  background: rgba(0, 0, 0, 0.04);
}

.cc-category__icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--cc-primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 16px;
  flex-shrink: 0;
}

.cc-category__icon svg {
  width: 20px;
  height: 20px;
}

.cc-category__info {
  flex: 1;
}

.cc-category__title {
  font-weight: 600;
  margin: 0 0 4px;
  color: var(--cc-text);
}

.cc-category__count {
  font-size: 12px;
  color: var(--cc-text-muted);
}

.cc-category__toggle {
  margin-left: 16px;
}

/* Toggle Switch */
.cc-toggle {
  position: relative;
  width: 50px;
  height: 26px;
}

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

.cc-toggle__slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #ccc;
  border-radius: 26px;
  transition: background var(--cc-transition);
}

.cc-toggle__slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: transform var(--cc-transition);
}

.cc-toggle input:checked + .cc-toggle__slider {
  background: var(--cc-primary);
}

.cc-toggle input:checked + .cc-toggle__slider:before {
  transform: translateX(24px);
}

.cc-toggle input:disabled + .cc-toggle__slider {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Expand Arrow */
.cc-category__expand {
  margin-left: 12px;
  color: var(--cc-text-muted);
  transition: transform var(--cc-transition);
}

.cc-category.cc--expanded .cc-category__expand {
  transform: rotate(180deg);
}

/* Category Body */
.cc-category__body {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--cc-transition);
}

.cc-category.cc--expanded .cc-category__body {
  max-height: 500px;
}

.cc-category__content {
  padding: 16px;
  border-top: 1px solid var(--cc-border);
}

.cc-category__description {
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--cc-text-light);
  line-height: 1.6;
}

/* Cookie Table in Modal */
.cc-cookie-table {
  width: 100%;
  font-size: 12px;
  border-collapse: collapse;
}

.cc-cookie-table th,
.cc-cookie-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--cc-border);
}

.cc-cookie-table th {
  font-weight: 600;
  background: rgba(0, 0, 0, 0.02);
}

.cc-cookie-table code {
  background: rgba(0, 0, 0, 0.06);
  padding: 2px 6px;
  border-radius: 3px;
  font-family: monospace;
}

/* ============================================================
   Pulsante Gestisci Cookie (fisso)
   ============================================================ */
.cc-manage-btn {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: calc(var(--cc-z-index) - 1);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--cc-primary);
  color: #ffffff;
  border: none;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--cc-transition), box-shadow var(--cc-transition);
}

.cc-manage-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.cc-manage-btn svg {
  width: 22px;
  height: 22px;
}

/* Nascondi quando il banner è visibile */
.cc-banner.cc--visible ~ .cc-manage-btn,
.cc-modal.cc--visible ~ .cc-manage-btn {
  opacity: 0;
  pointer-events: none;
}

/* ============================================================
   Badge "Sempre attivo"
   ============================================================ */
.cc-badge {
  display: inline-block;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  border-radius: 4px;
  background: #e8f5e9;
  color: #2e7d32;
}

/* ============================================================
   Animazioni
   ============================================================ */
@keyframes cc-fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes cc-slideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

@keyframes cc-scaleIn {
  from {
    transform: scale(0.9);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
  .cc-banner--bar .cc-banner__content {
    flex-direction: column;
    align-items: stretch;
  }

  .cc-banner--bar .cc-banner__text {
    min-width: 100%;
  }

  .cc-banner--bar .cc-banner__actions {
    flex-direction: column;
  }

  .cc-banner--bar .cc-btn {
    width: 100%;
  }

  .cc-banner--box {
    left: 10px;
    right: 10px;
    bottom: 10px;
    max-width: none;
  }

  .cc-modal__container {
    max-height: 95vh;
  }

  .cc-modal__footer {
    flex-direction: column;
  }

  .cc-modal__footer .cc-btn {
    width: 100%;
  }

  .cc-manage-btn {
    bottom: 15px;
    left: 15px;
    width: 40px;
    height: 40px;
  }

  .cc-category__header {
    padding: 12px;
  }

  .cc-category__icon {
    width: 32px;
    height: 32px;
    margin-right: 12px;
  }
}

/* ============================================================
   Print Styles
   ============================================================ */
@media print {
  #cc-main,
  .cc-banner,
  .cc-modal,
  .cc-manage-btn {
    display: none !important;
  }
}

/* ============================================================
   Accessibility
   ============================================================ */
.cc-btn:focus,
.cc-toggle input:focus + .cc-toggle__slider,
.cc-modal__close:focus,
.cc-category__header:focus {
  outline: 2px solid var(--cc-primary);
  outline-offset: 2px;
}

/* Riduce motion per utenti che lo preferiscono - TODO necessario? */
@media (prefers-reduced-motion: reduce) {
  #cc-main,
  #cc-main *,
  #cc-main *::before,
  #cc-main *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* High contrast mode */
@media (prefers-contrast: high) {
  .cc-btn--primary {
    border: 2px solid #000;
  }

  .cc-btn--outline {
    border-width: 2px;
  }
}
