/**
 * SGDA.es — Consent Banner and Cookie Settings Styles
 */

/* ==========================================================================
   Cookie Banner
   ========================================================================== */
.sgda-cookie-banner {
  position: fixed;
  bottom: 1.25rem;
  left: 1rem;
  right: 1rem;
  max-width: 980px;
  margin-inline: auto;
  z-index: 9999;
  background: #ffffff;
  color: #10233d;
  border: 1px solid #cbd5e1;
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(16, 35, 61, 0.16), 0 4px 12px rgba(16, 35, 61, 0.08);
  padding: 1.35rem 1.6rem;
  animation: sgdaSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes sgdaSlideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.sgda-cookie-banner-inner {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

@media (min-width: 860px) {
  .sgda-cookie-banner-inner {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 1.75rem;
  }
  .sgda-cookie-banner-content {
    flex: 1 1 auto;
  }
  .sgda-cookie-banner-actions {
    flex: 0 0 auto;
  }
}

.sgda-cookie-banner-title {
  margin: 0 0 0.35rem;
  font-size: 1.12rem;
  font-weight: 700;
  color: #10233d;
  line-height: 1.3;
}

.sgda-cookie-banner-text {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.55;
  color: #475569;
}

.sgda-cookie-banner-text a {
  color: #087b70;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.sgda-cookie-banner-text a:hover {
  color: #056358;
}

.sgda-cookie-banner-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
}

/* ==========================================================================
   Buttons (Aceptar and Rechazar have equal visual prominence)
   ========================================================================== */
.sgda-cookie-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.25;
  padding: 0.625rem 1.15rem;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid transparent;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}

.sgda-cookie-btn:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

/* Equal prominence buttons */
.sgda-cookie-btn-accept {
  background: #087b70;
  color: #ffffff;
  border-color: #087b70;
}
.sgda-cookie-btn-accept:hover {
  background: #056358;
  border-color: #056358;
}

.sgda-cookie-btn-reject {
  background: #10233d;
  color: #ffffff;
  border-color: #10233d;
}
.sgda-cookie-btn-reject:hover {
  background: #1a365d;
  border-color: #1a365d;
}

.sgda-cookie-btn-config {
  background: transparent;
  color: #10233d;
  border-color: #cbd5e1;
}
.sgda-cookie-btn-config:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

.sgda-cookie-btn-cancel {
  background: transparent;
  color: #475569;
  border-color: #cbd5e1;
}
.sgda-cookie-btn-cancel:hover {
  background: #f1f5f9;
  color: #10233d;
}

.sgda-cookie-btn-save {
  background: #087b70;
  color: #ffffff;
  border-color: #087b70;
}
.sgda-cookie-btn-save:hover {
  background: #056358;
  border-color: #056358;
}

@media (max-width: 540px) {
  .sgda-cookie-banner-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }
  .sgda-cookie-btn-config {
    grid-column: 1 / -1;
  }
}

/* ==========================================================================
   Cookie Settings Modal & Backdrop
   ========================================================================== */
.sgda-cookie-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16, 35, 61, 0.65);
  backdrop-filter: blur(2px);
  z-index: 10000;
  animation: sgdaFadeIn 0.2s ease forwards;
}

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

.sgda-cookie-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(580px, calc(100% - 2rem));
  max-height: 88vh;
  overflow-y: auto;
  background: #ffffff;
  color: #10233d;
  border: 1px solid #cbd5e1;
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(16, 35, 61, 0.28);
  z-index: 10001;
  animation: sgdaModalZoom 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes sgdaModalZoom {
  from {
    transform: translate(-50%, -46%) scale(0.97);
    opacity: 0;
  }
  to {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
}

.sgda-cookie-modal-dialog {
  padding: 1.75rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

@media (max-width: 540px) {
  .sgda-cookie-modal-dialog {
    padding: 1.25rem 1.25rem;
  }
}

.sgda-cookie-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 1rem;
}

.sgda-cookie-modal-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: #10233d;
}

.sgda-cookie-modal-close {
  background: transparent;
  border: none;
  font-size: 1.75rem;
  line-height: 1;
  color: #64748b;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
}

.sgda-cookie-modal-close:hover {
  color: #10233d;
  background: #f1f5f9;
}

.sgda-cookie-modal-close:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

.sgda-cookie-modal-body {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.sgda-cookie-modal-intro {
  margin: 0;
  font-size: 0.92rem;
  color: #475569;
  line-height: 1.5;
}

.sgda-cookie-category {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 1.1rem 1.25rem;
}

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

.sgda-cookie-category-title-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.sgda-cookie-category-name {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: #10233d;
}

.sgda-cookie-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.55rem;
  border-radius: 9999px;
  background: #e2e8f0;
  color: #334155;
}

.sgda-cookie-category-desc {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.5;
  color: #475569;
}

/* Switch styling */
.sgda-cookie-switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
  flex-shrink: 0;
}

.sgda-cookie-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.sgda-cookie-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #cbd5e1;
  transition: background-color 0.2s ease;
  border-radius: 26px;
}

.sgda-cookie-slider::before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: transform 0.2s ease;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.sgda-cookie-switch input:checked + .sgda-cookie-slider {
  background-color: #087b70;
}

.sgda-cookie-switch input:checked + .sgda-cookie-slider::before {
  transform: translateX(20px);
}

.sgda-cookie-switch input:focus-visible + .sgda-cookie-slider {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

.sgda-cookie-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  border-top: 1px solid #e2e8f0;
  padding-top: 1rem;
}

/* ==========================================================================
   Footer link button (seamless integration with site footer links)
   ========================================================================== */
.footer-link-button {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  font-size: 0.92rem;
  color: #d5dee7;
  text-decoration: none;
  cursor: pointer;
  display: inline;
  text-align: left;
}

.footer-link-button:hover {
  color: #ffffff;
  text-decoration: underline;
  text-decoration-color: rgba(255, 255, 255, 0.75);
}

.footer-link-button:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

/* ==========================================================================
   Reduced Motion
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  .sgda-cookie-banner,
  .sgda-cookie-backdrop,
  .sgda-cookie-modal {
    animation: none !important;
    transition: none !important;
  }
  .sgda-cookie-slider,
  .sgda-cookie-slider::before,
  .sgda-cookie-btn {
    transition: none !important;
  }
}

/* Screen reader utility if not globally defined */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
