/* ═══════════════════════════════════════════════════════════════════════════════
   ProjectsHub — Cookie Consent & Privacy Preference Center
   GDPR & CCPA Compliant, Glassmorphism, Theme-Aware, Fully Accessible
   ═══════════════════════════════════════════════════════════════════════════════ */

.ph-cookie-banner {
  position: fixed;
  bottom: 1.5rem;
  left: 1.5rem;
  z-index: 9998;
  max-width: 460px;
  width: calc(100vw - 3rem);
  opacity: 0;
  transform: translateY(24px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1), transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform, opacity;
  box-sizing: border-box;
}

.ph-cookie-banner.ph-cookie-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Glassmorphism Card Container */
.ph-cookie-card {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 1.25rem;
  padding: 1.35rem 1.5rem;
  box-shadow: 0 20px 45px -10px rgba(15, 23, 42, 0.15), 0 8px 16px -6px rgba(15, 23, 42, 0.08);
  color: #0f172a;
  font-family: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  body:not(.light) .ph-cookie-card {
    background: rgba(15, 23, 42, 0.92);
    border-color: rgba(51, 65, 85, 0.8);
    box-shadow: 0 20px 45px -10px rgba(0, 0, 0, 0.5), 0 8px 16px -6px rgba(0, 0, 0, 0.3);
    color: #f8fafc;
  }
}
body.dark .ph-cookie-card {
  background: rgba(15, 23, 42, 0.92);
  border-color: rgba(51, 65, 85, 0.8);
  box-shadow: 0 20px 45px -10px rgba(0, 0, 0, 0.5), 0 8px 16px -6px rgba(0, 0, 0, 0.3);
  color: #f8fafc;
}

/* Header Area */
.ph-cookie-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  gap: 0.75rem;
}

.ph-cookie-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.ph-cookie-icon-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(6, 182, 212, 0.12));
  color: #6366f1;
  flex-shrink: 0;
}

.ph-cookie-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: inherit;
}

.ph-cookie-close-btn {
  background: transparent;
  border: none;
  color: #64748b;
  cursor: pointer;
  padding: 0.35rem;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.ph-cookie-close-btn:hover {
  background: rgba(0, 0, 0, 0.05);
  color: #0f172a;
}
body.dark .ph-cookie-close-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

/* Description Text */
.ph-cookie-desc {
  margin: 0 0 1.15rem 0;
  font-size: 0.865rem;
  line-height: 1.55;
  color: #475569;
}
body.dark .ph-cookie-desc,
body:not(.light) .ph-cookie-desc {
  color: #94a3b8;
}

.ph-cookie-link {
  color: #6366f1;
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 600;
  transition: color 0.15s ease;
}

.ph-cookie-link:hover {
  color: #4f46e5;
}

/* Collapsible Preferences Panel */
.ph-cookie-preferences-panel {
  background: rgba(241, 245, 249, 0.65);
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 12px;
  padding: 0.85rem;
  margin-bottom: 1.15rem;
  max-height: 260px;
  overflow-y: auto;
  scrollbar-width: thin;
}
body.dark .ph-cookie-preferences-panel,
body:not(.light) .ph-cookie-preferences-panel {
  background: rgba(30, 41, 59, 0.7);
  border-color: rgba(51, 65, 85, 0.8);
}

.ph-cookie-category-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.ph-cookie-category-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(226, 232, 240, 0.6);
}

.ph-cookie-category-item:last-child {
  padding-bottom: 0;
  border-bottom: none;
}
body.dark .ph-cookie-category-item {
  border-bottom-color: rgba(51, 65, 85, 0.5);
}

.ph-cookie-cat-info {
  flex: 1;
}

.ph-cookie-cat-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.2rem;
}

.ph-cookie-cat-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: #1e293b;
}
body.dark .ph-cookie-cat-title,
body:not(.light) .ph-cookie-cat-title {
  color: #f1f5f9;
}

.ph-cookie-badge-locked,
.ph-cookie-badge-optional {
  font-size: 0.68rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.ph-cookie-badge-locked {
  background: rgba(16, 185, 129, 0.12);
  color: #059669;
}

.ph-cookie-badge-optional {
  background: rgba(99, 102, 241, 0.1);
  color: #6366f1;
}

.ph-cookie-cat-desc {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.4;
  color: #64748b;
}
body.dark .ph-cookie-cat-desc,
body:not(.light) .ph-cookie-cat-desc {
  color: #94a3b8;
}

/* Custom iOS-style Switch Toggles */
.ph-cookie-cat-toggle {
  position: relative;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
  margin-top: 2px;
}

.ph-cookie-cat-toggle input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.ph-toggle-label {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #cbd5e1;
  border-radius: 22px;
  transition: background-color 0.25s ease;
}

.ph-toggle-label::after {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 2px;
  bottom: 2px;
  background-color: #ffffff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.ph-cookie-cat-toggle input:checked + .ph-toggle-label {
  background-color: #6366f1;
}

.ph-cookie-cat-toggle input:checked + .ph-toggle-label::after {
  transform: translateX(18px);
}

.ph-toggle-label.disabled {
  cursor: not-allowed;
  opacity: 0.85;
  background-color: #10b981 !important;
}

/* Actions Bar & Buttons */
.ph-cookie-actions {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.ph-cookie-btn-group-primary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.ph-cookie-btn-group-secondary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.ph-cookie-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.6rem 0.9rem;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: inherit;
  white-space: nowrap;
}

.ph-cookie-btn-primary {
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.28);
}

.ph-cookie-btn-primary:hover {
  background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
  transform: translateY(-1px);
}

.ph-cookie-btn-secondary {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #e2e8f0;
}

.ph-cookie-btn-secondary:hover {
  background: #e2e8f0;
  color: #0f172a;
}
body.dark .ph-cookie-btn-secondary,
body:not(.light) .ph-cookie-btn-secondary {
  background: #1e293b;
  color: #cbd5e1;
  border-color: #334155;
}
body.dark .ph-cookie-btn-secondary:hover {
  background: #334155;
  color: #ffffff;
}

.ph-cookie-btn-link {
  background: transparent;
  border: none;
  color: #64748b;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.35rem 0.25rem;
  border-radius: 6px;
  transition: color 0.15s ease;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.ph-cookie-btn-link:hover {
  color: #4f46e5;
}
body.dark .ph-cookie-btn-link:hover {
  color: #818cf8;
}

.ph-cookie-btn-save {
  background: #0f172a;
  color: #ffffff;
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}
.ph-cookie-btn-save:hover {
  background: #334155;
}
body.dark .ph-cookie-btn-save {
  background: #6366f1;
}
body.dark .ph-cookie-btn-save:hover {
  background: #4f46e5;
}

/* Focus state for accessibility */
.ph-cookie-btn:focus-visible,
.ph-cookie-btn-link:focus-visible,
.ph-cookie-close-btn:focus-visible,
.ph-cookie-cat-toggle input:focus-visible + .ph-toggle-label {
  outline: 2px solid #6366f1;
  outline-offset: 2px;
}

/* Mobile & Small Screens (< 540px) */
@media (max-width: 540px) {
  .ph-cookie-banner {
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    border-radius: 0;
  }

  .ph-cookie-card {
    border-radius: 1.25rem 1.25rem 0 0;
    padding: 1.25rem 1.15rem calc(1.15rem + env(safe-area-inset-bottom, 0px));
    border-bottom: none;
    border-left: none;
    border-right: none;
  }

  .ph-cookie-btn-group-primary {
    grid-template-columns: 1fr;
  }

  .ph-cookie-btn {
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
  }
}
