/* ==========================================
   NOTIFICATIONS -- Panel, Badge, Banner, Match Indicator
   ========================================== */

@layer pages {

  /* ==========================================
     BADGE (on bell icon)
     ========================================== */

  #notifications-btn { position: relative; }

  .notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--brand-500);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    font-family: var(--font-body);
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    pointer-events: none;
  }

  /* ==========================================
     NOTIFICATION PANEL -- Desktop (right side slide-out)
     ========================================== */

  .notif-desktop-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.4);
  }

  .notif-side-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 400px;
    max-width: 90vw;
    height: 100vh;
    z-index: 1001;
    background: var(--surface-primary, #faf9f6);
    overflow-y: auto;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
  }

  /* ==========================================
     NOTIFICATION PANEL -- Mobile (bottom sheet)
     ========================================== */

  .notif-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: flex-end;
  }

  .notif-bottom-sheet {
    width: 100%;
    max-height: 70vh;
    background: var(--surface-primary, #faf9f6);
    border-radius: 16px 16px 0 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
  }

  /* ==========================================
     PANEL HEADER
     ========================================== */

  .notif-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    padding-right: 0.75rem; /* Align with dismiss X buttons below */
    border-bottom: 1px solid var(--border, rgba(0, 0, 0, 0.08));
    position: sticky;
    top: 0;
    background: inherit;
    z-index: 1;
  }

  .notif-panel-title {
    font-family: var(--font-body);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text, #1a1a1a);
  }

  .notif-panel-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }

  .notif-panel-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px 8px;
    border-radius: 6px;
  }
  .notif-panel-close:hover { background: var(--surface-secondary, rgba(0, 0, 0, 0.05)); }

  .notif-mark-all {
    background: none;
    border: none;
    font-size: 0.8rem;
    cursor: pointer;
    color: var(--brand-500);
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 6px;
  }
  .notif-mark-all:hover { text-decoration: underline; }

  /* ==========================================
     NOTIFICATION CARDS
     ========================================== */

  .notif-card {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border, rgba(0, 0, 0, 0.06));
    cursor: pointer;
    transition: background 0.15s, transform 0.2s ease, opacity 0.2s ease;
    position: relative;
    will-change: transform;
  }
  .notif-card:hover { background: var(--surface-secondary, rgba(0, 0, 0, 0.03)); }

  /* X dismiss button on notification cards */
  .notif-card-dismiss {
    position: absolute;
    top: 0.85rem;
    right: 0.75rem;
    display: none; /* Hidden by default (mobile uses swipe) */
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--color-text-tertiary);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    z-index: 2;
  }
  .notif-card-dismiss:hover {
    background: var(--surface-200);
    color: var(--color-text);
  }
  /* Show dismiss button only on desktop (non-touch) */
  @media (hover: hover) and (pointer: fine) {
    .notif-card-dismiss { display: flex; }
    .notif-card { padding-right: 3rem; } /* Make room for dismiss button */
  }

  /* Swipe-to-dismiss wrapper & trash reveal */
  .notif-card-wrapper {
    position: relative;
    overflow: hidden;
  }
  /* Move margin to wrapper so swipe-action-bg (inset:0) doesn't bleed into gap below */
  .notif-card-wrapper:has(.activation-banner) {
    margin-bottom: 1rem;
  }

  .swipe-action-bg {
    position: absolute;
    inset: 0;
    background: var(--color-danger, #ef4444);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 0 1.5rem;
    color: white;
    opacity: 0;
    pointer-events: none;
    border-radius: 4px;
  }

  .swipe-action-bg svg {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
  }

  /* Swipe-to-dismiss animation support */
  .notif-card.swiping,
  .activation-banner.swiping {
    transition: none; /* JS controls movement during swipe */
  }

  .notif-card-action {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text);
    line-height: 1.4;
    margin-bottom: 0.35rem;
    padding-right: 0;
  }
  .notif-card-action strong { color: var(--brand-600, var(--brand-500)); }

  .notif-card-context {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }

  .notif-expiry {
    color: var(--color-danger, #ef4444);
    font-weight: 500;
  }


  .notif-card--reminder { border-left: 3px solid var(--brand-500); }

  .notif-activate-cta {
    display: inline-block;
    margin-top: 0.5rem;
    padding: 0.35rem 0.75rem;
    background: var(--brand-500);
    color: white;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.15s;
  }
  .notif-activate-cta:hover { background: var(--brand-600, #d03b1f); }

  .notif-empty {
    padding: 3rem 1.5rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
  }

  /* ==========================================
     ACTIVATION BANNER (contextual on Benefits/Offers pages)
     ========================================== */

  .activation-banner {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--surface-secondary, rgba(0, 0, 0, 0.03));
    border-left: 3px solid var(--brand-500);
    border-radius: 0 8px 8px 0;
    font-size: 0.85rem;
    color: var(--text);
  }

  .activation-banner-text {
    flex: 1;
    line-height: 1.4;
  }

  .activation-banner-cta {
    padding: 0.35rem 0.75rem;
    background: var(--brand-500);
    color: white;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
  }
  .activation-banner-cta:hover { background: var(--brand-600, #d03b1f); }

  .activation-banner-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
  }

  .activation-banner-dismiss {
    display: none; /* Hidden by default (mobile) */
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--color-text-tertiary);
    cursor: pointer;
    transition: background var(--transition-base), color var(--transition-base);
  }

  .activation-banner-dismiss:hover {
    background: var(--surface-200);
    color: var(--color-text);
  }

  /* Show dismiss button only on desktop (non-touch) */
  @media (hover: hover) and (pointer: fine) {
    .activation-banner-dismiss {
      display: flex;
    }
  }


  /* ==========================================
     DEAL CARD MATCH INDICATOR (burst icon on offer tiles)
     ========================================== */

  /* Deal match indicator — rendered inline in offer-tile-header-top */
  .deal-match-indicator {
    margin-right: auto;
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 3px 10px;
    background: var(--brand-500);
    color: white;
    border-radius: var(--radius-full);
    font-size: 0.6875rem;
    font-weight: var(--weight-bold);
    line-height: 1.4;
    white-space: nowrap;
  }
  .deal-match-indicator svg {
    width: 10px;
    height: 10px;
  }

  /* ==========================================
     BOTTOM SHEET SCROLL CONTAINMENT
     ========================================== */
  .notif-bottom-sheet {
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  @media (max-width: 480px) {
    .notif-card {
      padding: var(--space-3);
    }
    .notif-card-title {
      font-size: var(--text-base);
    }
    .notif-card-body {
      font-size: var(--text-sm);
    }
    .notif-empty {
      padding: var(--space-6) var(--space-4);
    }
    .activation-banner {
      flex-wrap: wrap;
    }
  }

  /* Touch target compliance (44px minimum) */
  @media (pointer: coarse) {
    .notif-panel-close {
      min-width: 44px;
      min-height: 44px;
    }
    .notif-activate-cta {
      min-height: 44px;
      display: inline-flex;
      align-items: center;
    }
  }
}
