// ===== COOKIE BANNER - CLEAN & MOBILE FIRST =====

@import '../../utils/shared-styles.scss';

// ===== VARIABLES =====
$banner-bg: rgba(255, 255, 255, 0.98);
$banner-radius: 20px;
$banner-shadow: 0 -8px 40px rgba(0, 0, 0, 0.15);

// ===== OVERLAY =====
.cookie-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 9999;
  padding: 0;
  animation: fadeIn 0.3s ease;

  @media (min-width: 640px) {
    align-items: center;
    padding: 1rem;
  }
}

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

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

// ===== BANNER =====
.cookie-banner {
  background: $banner-bg;
  width: 100%;
  max-width: 100%;
  max-height: 85vh;
  max-height: 85dvh;
  overflow-y: auto;
  border-radius: $banner-radius $banner-radius 0 0;
  box-shadow: $banner-shadow;
  animation: slideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  flex-direction: column;

  @media (min-width: 640px) {
    max-width: 480px;
    border-radius: $banner-radius;
    animation: scaleIn 0.3s ease;
  }

  &.expanded {
    max-height: 90vh;
    max-height: 90dvh;
  }
}

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

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

@keyframes slideDown {
  from { 
    opacity: 1;
    transform: translateY(0); 
  }
  to { 
    opacity: 0;
    transform: translateY(100%); 
  }
}

@keyframes scaleOut {
  from { 
    opacity: 1;
    transform: scale(1); 
  }
  to { 
    opacity: 0;
    transform: scale(0.95); 
  }
}

// ===== OVERLAY CLOSING STATE =====
.cookie-overlay.closing {
  animation: fadeOut 0.3s ease forwards;
}

.cookie-banner.closing {
  animation: slideDown 0.3s cubic-bezier(0.4, 0, 1, 1) forwards;

  @media (min-width: 640px) {
    animation: scaleOut 0.3s ease forwards;
  }
}

// ===== HEADER =====
.banner-header {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 1.25rem 1.25rem 0;
}

.banner-icon {
  width: 48px;
  height: 48px;
  background: $gradient-primary;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;

  .material-symbols-outlined {
    font-size: 24px;
    color: white;
  }
}

.banner-title-area {
  h2 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 700;
    color: $color-text-primary;
    line-height: 1.3;
  }
}

.banner-subtitle {
  margin: 0.125rem 0 0;
  font-size: 0.8125rem;
  color: $color-text-tertiary;
}

// ===== CONTENT =====
.banner-content {
  padding: 1rem 1.25rem;
}

.banner-text {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.6;
  color: $color-text-secondary;
}

// ===== COOKIE DETAILS =====
.cookie-details {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.cookie-category {
  background: $color-gray-50;
  border: 2px solid transparent;
  border-radius: 12px;
  padding: 0.875rem;
  transition: all 0.2s;

  &.enabled {
    background: rgba($color-brand-primary, 0.04);
    border-color: rgba($color-brand-primary, 0.15);
  }

  &.required {
    background: $color-gray-50;
    border-color: $color-gray-200;
  }
}

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

.category-info {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.category-icon {
  font-size: 20px;
  color: $color-brand-primary;
}

.category-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: $color-text-primary;
}

.category-badge {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.125rem 0.5rem;
  background: $color-gray-200;
  border-radius: 4px;
  font-size: 0.625rem;
  font-weight: 600;
  color: $color-text-tertiary;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.category-description {
  margin: 0.5rem 0 0;
  font-size: 0.75rem;
  line-height: 1.5;
  color: $color-text-tertiary;
}

// ===== TOGGLE SWITCH =====
.toggle-switch {
  position: relative;
  width: 44px;
  height: 26px;
  background: $color-gray-300;
  border: none;
  border-radius: 13px;
  cursor: pointer;
  transition: all 0.25s;
  flex-shrink: 0;

  &:disabled {
    cursor: not-allowed;
    opacity: 0.6;
  }

  &.active {
    background: $color-brand-primary;

    .toggle-knob {
      transform: translateX(18px);
    }
  }

  &:not(:disabled):hover {
    background: $color-gray-400;

    &.active {
      background: $color-brand-dark;
    }
  }
}

.toggle-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

// ===== ACTIONS =====
.banner-actions {
  padding: 0.75rem 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.action-row {
  display: flex;
  gap: 0.5rem;

  &.primary-actions {
    .btn {
      flex: 1;
    }
  }
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  font-size: 0.875rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;

  .material-symbols-outlined {
    font-size: 18px;
  }
}

.btn-accept {
  background: $gradient-primary;
  color: white;
  box-shadow: 0 4px 12px rgba($color-brand-primary, 0.25);

  &:hover {
    box-shadow: 0 6px 16px rgba($color-brand-primary, 0.35);
    transform: translateY(-1px);
  }

  &:active {
    transform: translateY(0);
  }
}

.btn-reject {
  background: $color-gray-100;
  color: $color-text-secondary;
  border: 1px solid $color-gray-200;

  &:hover {
    background: $color-gray-200;
    color: $color-text-primary;
  }
}

.btn-save {
  background: $color-brand-primary;
  color: white;
  width: 100%;

  &:hover {
    background: $color-brand-dark;
  }
}

.btn-details {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.625rem;
  background: transparent;
  border: none;
  font-size: 0.8125rem;
  font-weight: 500;
  color: $color-text-tertiary;
  cursor: pointer;
  transition: color 0.2s;

  .material-symbols-outlined {
    font-size: 18px;
  }

  &:hover {
    color: $color-brand-primary;
  }
}

// ===== FOOTER =====
.banner-footer {
  padding: 0.75rem 1.25rem 1rem;
  border-top: 1px solid $color-gray-100;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;

  a {
    color: $color-text-tertiary;
    text-decoration: none;
    transition: color 0.2s;

    &:hover {
      color: $color-brand-primary;
      text-decoration: underline;
    }
  }

  .separator {
    color: $color-gray-300;
  }
}

// ===== MATERIAL ICONS =====
.material-symbols-outlined {
  font-variation-settings: "FILL" 0, "wght" 500, "GRAD" 0, "opsz" 24;
  line-height: 1;
}

// ===== SAFE AREA (iPhone Notch) =====
@supports (padding: max(0px)) {
  .cookie-banner {
    padding-bottom: max(0px, env(safe-area-inset-bottom));
  }
}

// ===== REDUCED MOTION =====
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

// ===== TABLET+ ADJUSTMENTS =====
@media (min-width: 640px) {
  .banner-header {
    padding: 1.5rem 1.5rem 0;
  }

  .banner-icon {
    width: 52px;
    height: 52px;

    .material-symbols-outlined {
      font-size: 26px;
    }
  }

  .banner-title-area h2 {
    font-size: 1.25rem;
  }

  .banner-content {
    padding: 1.25rem 1.5rem;
  }

  .banner-text {
    font-size: 0.9375rem;
  }

  .cookie-category {
    padding: 1rem;
  }

  .category-name {
    font-size: 0.9375rem;
  }

  .category-description {
    font-size: 0.8125rem;
  }

  .banner-actions {
    padding: 1rem 1.5rem 1.25rem;
  }

  .banner-footer {
    padding: 1rem 1.5rem 1.25rem;
  }
}
