/**
 * ═══════════════════════════════════════════════════════════════════
 *  NhaBex App v3 — Notifications Page Styles
 *  app/assets/css/notifications.css
 * ═══════════════════════════════════════════════════════════════════
 */


/* ── Page layout ── */

.ntf-page {
  max-width: 640px;
  margin: 0 auto;
  padding: 8px 16px 24px;
  padding-bottom: calc(90px + env(safe-area-inset-bottom));
}


/* ═══════════════ Header ═══════════════ */

.ntf-header {
  position: sticky;
  top: var(--md-sys-layout-top-bar-h, 56px);
  z-index: 10;
  background: var(--md-sys-color-surface);
  padding: 8px 0 0;
  margin-bottom: 8px;
}

.ntf-header__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 6px;
}

.ntf-header__title {
  margin: 0;
  font-family: var(--md-sys-typescale-font);
  font-size: var(--md-sys-typescale-headline-small-size);
  font-weight: 400;
  line-height: var(--md-sys-typescale-headline-small-height);
  color: var(--md-sys-color-on-surface);
}

.ntf-header__subtitle {
  margin: 4px 0 0;
  font-size: var(--md-sys-typescale-body-small-size);
  color: var(--md-sys-color-on-surface-variant);
  display: flex;
  align-items: center;
  gap: 6px;
}

.ntf-header__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--md-sys-shape-full);
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  font-size: 11px;
  font-weight: 400;
}

.ntf-header__actions {
  display: flex;
  gap: 4px;
}

.ntf-header__clear {
  color: var(--md-sys-color-error) !important;
}


/* ═══════════════ Filters ═══════════════ */

.ntf-filters {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 0 2px 14px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.ntf-filters::-webkit-scrollbar {
  display: none;
}

.ntf-filter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--md-sys-shape-full);
  border: 1px solid var(--md-sys-color-outline-variant);
  background: transparent;
  color: var(--md-sys-color-on-surface-variant);
  font-family: var(--md-sys-typescale-font);
  font-size: var(--md-sys-typescale-label-medium-size);
  font-weight: 400;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition:
    background 0.2s var(--md-sys-motion-easing-standard),
    color 0.2s var(--md-sys-motion-easing-standard),
    border-color 0.2s var(--md-sys-motion-easing-standard);
}

.ntf-filter i {
  font-size: 11px;
}

.ntf-filter:hover {
  background: color-mix(in srgb, var(--md-sys-color-on-surface) 6%, transparent);
}

.ntf-filter--active {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  border-color: var(--md-sys-color-primary);
}

.ntf-filter--active:hover {
  background: color-mix(in srgb, var(--md-sys-color-primary) 90%, black);
}

.ntf-filter__count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--md-sys-shape-full);
  background: var(--md-sys-color-surface-container-highest);
  color: var(--md-sys-color-on-surface);
  font-size: 10px;
  font-weight: 400;
}

.ntf-filter--active .ntf-filter__count {
  background: rgba(255, 255, 255, 0.25);
  color: var(--md-sys-color-on-primary);
}


/* ═══════════════ Push Banner ═══════════════ */

.ntf-push-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  margin-bottom: 16px;
  border-radius: var(--md-sys-shape-medium);
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  cursor: pointer;
  transition: opacity 0.15s;
}

.ntf-push-banner:active {
  opacity: 0.85;
}

.ntf-push-banner__icon {
  width: 40px;
  height: 40px;
  border-radius: var(--md-sys-shape-full);
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.ntf-push-banner__content {
  flex: 1;
  min-width: 0;
}

.ntf-push-banner__title {
  margin: 0;
  font-size: var(--md-sys-typescale-label-large-size);
  font-weight: 400;
}

.ntf-push-banner__desc {
  margin: 2px 0 0;
  font-size: var(--md-sys-typescale-body-small-size);
  opacity: 0.85;
}

.ntf-push-banner__arrow {
  font-size: 12px;
  opacity: 0.6;
  flex-shrink: 0;
}


/* ═══════════════ Empty State ═══════════════ */

.ntf-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 24px 40px;
  gap: 12px;
}

.ntf-empty__illustration {
  width: 80px;
  height: 80px;
  border-radius: var(--md-sys-shape-full);
  background: var(--md-sys-color-surface-container);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}

.ntf-empty__illustration i {
  font-size: 32px;
  color: var(--md-sys-color-on-surface-variant);
  opacity: 0.5;
}

.ntf-empty__title {
  margin: 0;
  font-family: var(--md-sys-typescale-font);
  font-size: var(--md-sys-typescale-title-medium-size);
  font-weight: 400;
  color: var(--md-sys-color-on-surface);
}

.ntf-empty__desc {
  margin: 0;
  font-size: var(--md-sys-typescale-body-medium-size);
  color: var(--md-sys-color-on-surface-variant);
  max-width: 260px;
}


/* ═══════════════ Notification List ═══════════════ */

.ntf-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}


/* ── Group ── */

.ntf-group {
  margin-bottom: 8px;
}

.ntf-group__label {
  font-family: var(--md-sys-typescale-font);
  font-size: var(--md-sys-typescale-label-small-size);
  font-weight: 400;
  color: var(--md-sys-color-on-surface-variant);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 12px 4px 6px;
}

.ntf-group__items {
  display: flex;
  flex-direction: column;
  gap: 6px;
}


/* ── Notification Item (swipe container) ── */

.ntf-item {
  position: relative;
  border-radius: var(--md-sys-shape-medium);
  overflow: hidden;
  animation: ntf-slide-in 0.3s var(--md-sys-motion-easing-emphasized-decel) both;
}

.ntf-group__items .ntf-item:nth-child(1)  { animation-delay: 0ms; }
.ntf-group__items .ntf-item:nth-child(2)  { animation-delay: 40ms; }
.ntf-group__items .ntf-item:nth-child(3)  { animation-delay: 80ms; }
.ntf-group__items .ntf-item:nth-child(4)  { animation-delay: 120ms; }
.ntf-group__items .ntf-item:nth-child(5)  { animation-delay: 160ms; }
.ntf-group__items .ntf-item:nth-child(6)  { animation-delay: 200ms; }
.ntf-group__items .ntf-item:nth-child(7)  { animation-delay: 240ms; }
.ntf-group__items .ntf-item:nth-child(8)  { animation-delay: 280ms; }
.ntf-group__items .ntf-item:nth-child(9)  { animation-delay: 320ms; }
.ntf-group__items .ntf-item:nth-child(10) { animation-delay: 360ms; }

@keyframes ntf-slide-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}


/* ── Swipe reveal backgrounds ── */

.ntf-item__swipe-bg {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 20px;
  font-family: var(--md-sys-typescale-font);
  font-size: var(--md-sys-typescale-label-medium-size);
  font-weight: 400;
  opacity: 0;
  transition: opacity 0.15s;
}

.ntf-item__swipe-bg--delete {
  right: 0;
  justify-content: flex-end;
  background: var(--md-sys-color-error);
  color: var(--md-sys-color-on-error, #fff);
}

.ntf-item__swipe-bg--read {
  left: 0;
  justify-content: flex-start;
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}

.ntf-item__swipe-bg i {
  font-size: 16px;
}

.ntf-item--swiping .ntf-item__swipe-bg {
  opacity: 1;
}


/* ── Inner content (moves on swipe) ── */

.ntf-item__inner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: var(--md-sys-color-surface-container-lowest);
  cursor: pointer;
  position: relative;
  z-index: 1;
  transition: background 0.15s var(--md-sys-motion-easing-standard);
  -webkit-user-select: none;
  user-select: none;
}

.ntf-item__inner--returning {
  transition: transform 0.3s var(--md-sys-motion-easing-emphasized-decel),
              background 0.15s var(--md-sys-motion-easing-standard);
}

.ntf-item__inner:hover {
  background: var(--md-sys-color-surface-container-low);
}

.ntf-item__inner:active {
  transform: scale(0.99);
}

/* Unread indicator — left accent bar */
.ntf-item--unread .ntf-item__inner {
  background: var(--md-sys-color-surface-container-low);
}

.ntf-item--unread .ntf-item__inner::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 3px;
  background: var(--md-sys-color-primary);
}


/* ── Removing animation ── */

.ntf-item--removing {
  animation: ntf-slide-out 0.3s var(--md-sys-motion-easing-emphasized-accel) forwards;
}

@keyframes ntf-slide-out {
  0% {
    opacity: 1;
    max-height: 120px;
    margin-bottom: 6px;
  }
  50% {
    opacity: 0;
    transform: translateX(-100%);
  }
  100% {
    opacity: 0;
    transform: translateX(-100%);
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    margin-bottom: 0;
    overflow: hidden;
  }
}

/* ── Mark-read flash ── */

.ntf-item--read-flash .ntf-item__inner {
  animation: ntf-read-flash 0.5s ease;
}

@keyframes ntf-read-flash {
  0% { background: var(--md-sys-color-surface-container-low); }
  40% { background: color-mix(in srgb, var(--md-sys-color-primary) 15%, var(--md-sys-color-surface-container-lowest)); }
  100% { background: var(--md-sys-color-surface-container-lowest); }
}


/* ── Icon ── */

.ntf-item__icon {
  width: 42px;
  height: 42px;
  min-width: 42px;
  border-radius: var(--md-sys-shape-medium);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}


/* ── Content ── */

.ntf-item__content {
  flex: 1;
  min-width: 0;
}

.ntf-item__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.ntf-item__title {
  margin: 0;
  font-family: var(--md-sys-typescale-font);
  font-size: var(--md-sys-typescale-body-medium-size);
  font-weight: 400;
  color: var(--md-sys-color-on-surface);
  line-height: 1.3;
}

.ntf-item--unread .ntf-item__title {
  font-weight: 400;
}

.ntf-item__time {
  font-size: var(--md-sys-typescale-label-small-size);
  color: var(--md-sys-color-on-surface-variant);
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 2px;
}

.ntf-item__body {
  margin: 3px 0 0;
  font-size: var(--md-sys-typescale-body-small-size);
  color: var(--md-sys-color-on-surface-variant);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ntf-item__action {
  display: inline-block;
  margin-top: 6px;
  padding: 0;
  border: none;
  background: none;
  font-family: var(--md-sys-typescale-font);
  font-size: var(--md-sys-typescale-label-small-size);
  font-weight: 400;
  color: var(--md-sys-color-primary);
  cursor: pointer;
}

.ntf-item__action:hover {
  text-decoration: underline;
}


/* ── Delete button ── */

.ntf-item__delete {
  border: none;
  background: none;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--md-sys-shape-full);
  color: var(--md-sys-color-on-surface-variant);
  cursor: pointer;
  font-size: 12px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
  align-self: center;
}

.ntf-item__inner:hover .ntf-item__delete {
  opacity: 1;
}

.ntf-item__delete:hover {
  background: color-mix(in srgb, var(--md-sys-color-error) 12%, transparent);
  color: var(--md-sys-color-error);
}

/* On touch devices: hide X button (swipe replaces it) */
@media (hover: none) {
  .ntf-item__delete {
    display: none;
  }
}


/* ═══════════════ Reduced Motion ═══════════════ */

@media (prefers-reduced-motion: reduce) {
  .ntf-item {
    animation: none;
  }
  .ntf-item--removing {
    animation-duration: 0.01s;
  }
  .ntf-item--read-flash .ntf-item__inner {
    animation: none;
  }
  .ntf-item__inner--returning {
    transition-duration: 0.01s;
  }
}
