/**
 * Perfecty Push Notifications — DigitalNeurone Theme Overrides
 *
 * Reskins the default plugin UI (dialog popup, bell button, settings panel)
 * to match the NeuroneUX design system: glassmorphism, brand gradients,
 * dark/light-mode CSS variables, and IBM Plex Sans typography.
 *
 * @package DigitalNeurone
 * @since   1.0.2
 */

/* ============================================
   Slide-Down Entry Animation
   ============================================ */
@keyframes perfecty-slide-down {
  from {
    opacity: 0;
    transform: translateY(-18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes perfecty-bell-ring {
  0%, 100% { transform: rotate(0deg); }
  15%      { transform: rotate(14deg); }
  30%      { transform: rotate(-12deg); }
  45%      { transform: rotate(8deg); }
  60%      { transform: rotate(-6deg); }
  75%      { transform: rotate(2deg); }
}

@keyframes perfecty-fade-up {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================
   Dialog Container — Top-Bar Prompt
   ============================================ */
.perfecty-push-dialog-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100000;
  display: none;
  padding: 0.75rem 1rem;
  background: color-mix(in srgb, var(--neurone-bg-primary) 80%, transparent);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border-bottom: 1px solid color-mix(in srgb, var(--neurone-border) 40%, transparent);
  box-shadow:
    0 4px 24px -4px var(--neurone-shadow-color),
    inset 0 -1px 0 0 color-mix(in srgb, var(--neurone-border) 20%, transparent);
  animation: perfecty-slide-down 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* ============================================
   Dialog Box — The Inner Card
   ============================================ */
.perfecty-push-dialog-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  max-width: 640px;
  margin: 0 auto;
  padding: 0;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
  text-align: left;
  width: auto;
  flex-wrap: nowrap;
}

/* Hide the default icon — the plugin injects a .perfecty-push-dialog-icon img */
.perfecty-push-dialog-box .perfecty-push-dialog-icon {
  display: none;
}

/* ============================================
   Dialog Title
   ============================================ */
.perfecty-push-dialog-box .perfecty-push-dialog-title {
  font-family: var(--font-heading, 'IBM Plex Sans', sans-serif);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--neurone-text-primary);
  margin: 0;
  line-height: 1.5;
  flex: 1 1 auto;
  min-width: 0;
}

/* ============================================
   Dialog Buttons Wrapper
   ============================================ */
.perfecty-push-dialog-box .perfecty-push-dialog-buttons {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* ============================================
   Dialog Buttons — Shared Reset
   ============================================ */
.perfecty-push-dialog-container .perfecty-push-dialog-form button,
.perfecty-push-dialog-box .perfecty-push-dialog-buttons button {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-heading, 'IBM Plex Sans', sans-serif);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  line-height: 1;
  padding: 0.625rem 1.25rem;
  border-radius: 0.5rem;
  transition:
    transform 0.2s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.25s ease,
    background-color 0.2s ease,
    color 0.2s ease,
    opacity 0.2s ease;
  white-space: nowrap;
}

/* — Subscribe (Primary CTA) — */
#perfecty-push-dialog-subscribe {
  color: #fff !important;
  background: linear-gradient(135deg,
      var(--color-brand-primary, #6366f1),
      var(--color-brand-accent, #06b6d4),
      var(--color-brand-secondary, #8b5cf6)) !important;
  background-size: 200% 200% !important;
  animation: gradient-shift 4s ease infinite;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--neurone-accent, #6366f1) 25%, transparent);
}

#perfecty-push-dialog-subscribe:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 18px color-mix(in srgb, var(--neurone-accent, #6366f1) 40%, transparent);
}

#perfecty-push-dialog-subscribe:active {
  transform: translateY(0);
  box-shadow: 0 1px 4px color-mix(in srgb, var(--neurone-accent, #6366f1) 20%, transparent);
}

/* — Cancel (Ghost / Secondary) — */
#perfecty-push-dialog-cancel {
  color: var(--neurone-text-secondary, #64748b) !important;
  background: transparent !important;
  border: 1px solid color-mix(in srgb, var(--neurone-border, #e2e8f0) 60%, transparent) !important;
}

#perfecty-push-dialog-cancel:hover {
  color: var(--neurone-text-primary) !important;
  background: var(--neurone-surface-overlay, rgba(0, 0, 0, 0.05)) !important;
  border-color: var(--neurone-border-strong, #cbd5e1) !important;
}

/* ============================================
   Settings Container — Bottom-Left FAB
   ============================================ */
.perfecty-push-settings-container {
  position: fixed;
  bottom: 1.25rem;
  left: 1.25rem;
  z-index: 100000;
  display: none;
}

/* ============================================
   Bell Button (Settings Open Trigger)
   ============================================ */
.perfecty-push-settings-container #perfecty-push-settings-open {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3.25rem;
  height: 3.25rem;
  padding: 0;
  margin: 0;
  border: none;
  outline: none;
  background: linear-gradient(135deg,
      var(--color-brand-primary, #6366f1),
      var(--color-brand-accent, #06b6d4),
      var(--color-brand-secondary, #8b5cf6));
  background-size: 200% 200%;
  animation: gradient-shift 4s ease infinite;
  border-radius: 50%;
  cursor: pointer;
  box-shadow:
    0 4px 20px -4px color-mix(in srgb, var(--neurone-accent, #6366f1) 40%, transparent),
    0 1px 3px rgba(0, 0, 0, 0.1);
  transition:
    transform 0.25s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.3s ease;
}

.perfecty-push-settings-container #perfecty-push-settings-open:hover {
  transform: scale(1.08);
  box-shadow:
    0 8px 30px -4px color-mix(in srgb, var(--neurone-accent, #6366f1) 50%, transparent),
    0 2px 6px rgba(0, 0, 0, 0.12);
}

.perfecty-push-settings-container #perfecty-push-settings-open:active {
  transform: scale(0.96);
}

/* Bell icon/SVG inside the button */
.perfecty-push-settings-container #perfecty-push-settings-open svg,
.perfecty-push-settings-container #perfecty-push-settings-open img {
  width: 1.375rem;
  height: 1.375rem;
  padding: 0;
  border-radius: 0;
  background: none !important;
  background-color: transparent !important;
  fill: #fff;
  color: #fff;
  filter: brightness(0) invert(1);
  transition: transform 0.3s ease;
  box-shadow: none;
  box-sizing: content-box;
}

.perfecty-push-settings-container #perfecty-push-settings-open:hover svg,
.perfecty-push-settings-container #perfecty-push-settings-open:hover img {
  animation: perfecty-bell-ring 0.6s ease;
}

/* ============================================
   Settings Form — Opt-in Panel
   ============================================ */
.perfecty-push-settings-container #perfecty-push-settings-form {
  display: none;
  position: absolute;
  bottom: calc(100% + 0.75rem);
  left: 0;
  min-width: 260px;
  max-width: 320px;
  padding: 1.25rem 1.5rem;
  background: color-mix(in srgb, var(--neurone-bg-secondary, #fff) 85%, transparent);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border: 1px solid color-mix(in srgb, var(--neurone-border, #e2e8f0) 50%, transparent);
  border-radius: 1rem;
  box-shadow:
    0 20px 50px -12px var(--neurone-shadow-color, rgba(0, 0, 0, 0.1)),
    0 4px 12px -2px var(--neurone-shadow-color, rgba(0, 0, 0, 0.06)),
    inset 0 1px 1px 0 color-mix(in srgb, var(--neurone-bg-secondary, #fff) 15%, transparent);
  animation: perfecty-fade-up 0.3s cubic-bezier(0.22, 1, 0.36, 1) both;
  margin-bottom: 0;
}

/* Settings panel title */
.perfecty-push-settings-container #perfecty-push-settings-form > div:first-child {
  font-family: var(--font-heading, 'IBM Plex Sans', sans-serif);
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--neurone-text-primary);
  margin-bottom: 0.75rem;
  padding-bottom: 0.625rem;
  border-bottom: 1px solid var(--neurone-border, #e2e8f0);
}

/* Checkbox + label row */
.perfecty-push-settings-container #perfecty-push-settings-form label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-sans, 'IBM Plex Sans', sans-serif);
  font-size: 0.8125rem;
  color: var(--neurone-text-secondary);
  cursor: pointer;
  user-select: none;
  transition: color 0.2s;
}

.perfecty-push-settings-container #perfecty-push-settings-form label:hover {
  color: var(--neurone-text-primary);
}

/* Styled checkbox */
.perfecty-push-settings-container #perfecty-push-settings-subscribed {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: 1.125rem;
  height: 1.125rem;
  border: 2px solid var(--neurone-border-strong, #cbd5e1);
  border-radius: 0.25rem;
  background: var(--neurone-bg-secondary, #fff);
  cursor: pointer;
  transition:
    background-color 0.2s,
    border-color 0.2s,
    box-shadow 0.2s;
  position: relative;
  flex-shrink: 0;
}

.perfecty-push-settings-container #perfecty-push-settings-subscribed:checked {
  background: var(--neurone-accent, #6366f1);
  border-color: var(--neurone-accent, #6366f1);
}

.perfecty-push-settings-container #perfecty-push-settings-subscribed:checked::after {
  content: '';
  position: absolute;
  top: 1px;
  left: 4px;
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.perfecty-push-settings-container #perfecty-push-settings-subscribed:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--neurone-accent, #6366f1) 30%, transparent);
}

/* Settings notification message */
#perfecty-push-settings-notification {
  font-family: var(--font-sans, 'IBM Plex Sans', sans-serif);
  font-size: 0.75rem;
  color: var(--neurone-text-muted, #94a3b8);
  margin-top: 0.5rem;
  line-height: 1.45;
}

#perfecty-push-settings-notification:not(:empty) {
  padding: 0.5rem 0.75rem;
  background: color-mix(in srgb, var(--neurone-accent, #6366f1) 8%, transparent);
  border-radius: 0.5rem;
  color: var(--neurone-accent, #6366f1);
  font-weight: 500;
}

/* ============================================
   Responsive Adjustments
   ============================================ */
@media only screen and (max-width: 480px) {
  .perfecty-push-dialog-container {
    padding: 0.875rem 1rem;
  }

  .perfecty-push-dialog-box {
    flex-wrap: wrap;
    gap: 0.625rem;
    text-align: center;
    justify-content: center;
    max-width: 100%;
  }

  .perfecty-push-dialog-box .perfecty-push-dialog-title {
    flex: 1 1 100%;
    text-align: center;
    font-size: 0.8125rem;
  }

  .perfecty-push-dialog-box .perfecty-push-dialog-buttons {
    width: 100%;
    justify-content: center;
  }

  .perfecty-push-dialog-box .perfecty-push-dialog-buttons button {
    flex: 1;
  }

  /* Settings panel */
  .perfecty-push-settings-container {
    bottom: 1rem;
    left: 1rem;
  }

  .perfecty-push-settings-container #perfecty-push-settings-open {
    width: 2.75rem;
    height: 2.75rem;
  }

  .perfecty-push-settings-container #perfecty-push-settings-open svg,
  .perfecty-push-settings-container #perfecty-push-settings-open img {
    width: 1.125rem;
    height: 1.125rem;
  }

  .perfecty-push-settings-container #perfecty-push-settings-form {
    min-width: 240px;
    max-width: calc(100vw - 2rem);
    padding: 1rem 1.25rem;
  }
}

@media only screen and (max-width: 370px) {
  .perfecty-push-dialog-box {
    width: auto;
    max-width: 100%;
  }

  .perfecty-push-dialog-box .perfecty-push-dialog-buttons button {
    padding: 0.5rem 0.75rem;
    font-size: 0.6875rem;
  }
}
