/**
 * GeoFazendas Notification Bell & Dropdown
 *
 * Mobile-first notification system:
 * - Mobile: full-width bottom sheet panel
 * - Desktop: dropdown anchored to bell icon
 *
 * @version 1.0.0
 */

/* =========================================================
   Design tokens
   ========================================================= */
:root {
  --notif-z: 1060;
  --notif-radius: 0.875rem;
  --notif-shadow: 0 12px 48px -8px rgba(0,0,0,.22), 0 4px 16px rgba(0,0,0,.12);
  --notif-width: 360px;
  --notif-max-h: 480px;
  --notif-badge-size: 1.125rem;

  --notif-info-icon:    #2563eb;
  --notif-success-icon: #16a34a;
  --notif-warning-icon: #d97706;
  --notif-error-icon:   #dc2626;
}

/* =========================================================
   Bell wrapper & button
   ========================================================= */
.notif-bell-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.notif-bell-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 0.75rem;
  color: rgba(255,255,255,.85);
  transition: background 0.15s, color 0.15s;
  padding: 0;
}

.notif-bell-btn:hover,
.notif-bell-btn:focus-visible {
  background: rgba(255,255,255,.12);
  color: #fff;
  outline: none;
}

.notif-bell-btn[aria-expanded="true"] {
  background: rgba(255,255,255,.15);
  color: #fff;
}

.notif-bell-icon {
  font-size: 1.5rem;
}

/* =========================================================
   Badge (unread count)
   ========================================================= */
.notif-bell-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: var(--notif-badge-size);
  height: var(--notif-badge-size);
  padding: 0 0.25rem;
  background: #ef4444;
  color: #fff;
  border-radius: 999px;
  font-size: 0.625rem;
  font-weight: 700;
  line-height: var(--notif-badge-size);
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: transform 0.2s, opacity 0.2s;
  border: 2px solid transparent;
}

.notif-bell-badge--hidden {
  transform: scale(0);
  opacity: 0;
}

/* Pulse animation for new notifications */
@keyframes notif-pulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.2); }
}
.notif-bell-badge--pulse {
  animation: notif-pulse 0.4s ease;
}

/* =========================================================
   Dropdown panel (mobile-first: bottom sheet)
   ========================================================= */
.notif-dropdown {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: var(--notif-z);
  background: #fff;
  border-radius: var(--notif-radius) var(--notif-radius) 0 0;
  box-shadow: var(--notif-shadow);
  overflow: hidden;
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
  max-height: 80dvh;
  display: flex;
  flex-direction: column;
}

.notif-dropdown:not([hidden]) {
  transform: translateY(0);
}

/* Remove hidden display:none so CSS animation works */
.notif-dropdown[hidden] {
  display: flex !important;
  visibility: hidden;
  pointer-events: none;
}

/* Backdrop */
.notif-backdrop {
  position: fixed;
  inset: 0;
  z-index: calc(var(--notif-z) - 1);
  background: rgba(0,0,0,.45);
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
}
.notif-backdrop--visible {
  opacity: 1;
  pointer-events: auto;
}

/* =========================================================
   Dropdown: header
   ========================================================= */
.notif-dropdown__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem 0.75rem;
  border-bottom: 1px solid #f1f5f9;
  flex-shrink: 0;
}

.notif-dropdown__title {
  font-weight: 700;
  font-size: 1rem;
  color: #0f172a;
}

.notif-dropdown__mark-all {
  font-size: 0.75rem;
  font-weight: 600;
  color: #2563eb;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem 0;
  transition: color 0.15s;
}
.notif-dropdown__mark-all:hover { color: #1d4ed8; }
.notif-dropdown__mark-all:disabled { color: #94a3b8; cursor: default; }

/* =========================================================
   Dropdown: list
   ========================================================= */
.notif-dropdown__list {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  min-height: 4rem;
}

/* =========================================================
   Dropdown: loading / empty states
   ========================================================= */
.notif-dropdown__loading,
.notif-dropdown__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 2.5rem 1rem;
  color: #94a3b8;
  font-size: 0.875rem;
  text-align: center;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
.notif-dropdown__spinner {
  animation: spin 1s linear infinite;
  font-size: 1.75rem;
}

.notif-dropdown__empty-icon {
  font-size: 2rem;
  opacity: 0.5;
}

/* =========================================================
   Dropdown: single item
   ========================================================= */
.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid #f8fafc;
  cursor: pointer;
  transition: background 0.12s;
  text-decoration: none;
  color: inherit;
  position: relative;
}

.notif-item:hover { background: #f8fafc; }
.notif-item--unread { background: #eff6ff; }
.notif-item--unread:hover { background: #dbeafe; }

/* Unread dot */
.notif-item--unread::after {
  content: '';
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: #3b82f6;
  flex-shrink: 0;
}

.notif-item__icon-wrap {
  flex-shrink: 0;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f1f5f9;
}

.notif-item__icon {
  font-size: 1.125rem;
}

/* Variant icon colors */
.notif-item--info    .notif-item__icon { color: var(--notif-info-icon); }
.notif-item--success .notif-item__icon { color: var(--notif-success-icon); }
.notif-item--warning .notif-item__icon { color: var(--notif-warning-icon); }
.notif-item--error   .notif-item__icon { color: var(--notif-error-icon); }

.notif-item--info    .notif-item__icon-wrap { background: #eff6ff; }
.notif-item--success .notif-item__icon-wrap { background: #f0fdf4; }
.notif-item--warning .notif-item__icon-wrap { background: #fffbeb; }
.notif-item--error   .notif-item__icon-wrap { background: #fef2f2; }

.notif-item__body {
  flex: 1;
  min-width: 0;
}

.notif-item__title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #0f172a;
  line-height: 1.3;
  margin-bottom: 0.1875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.notif-item__message {
  font-size: 0.75rem;
  color: #64748b;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.notif-item__time {
  font-size: 0.6875rem;
  color: #94a3b8;
  margin-top: 0.25rem;
  white-space: nowrap;
}

/* =========================================================
   Dropdown: footer
   ========================================================= */
.notif-dropdown__footer {
  padding: 0.75rem 1.25rem;
  border-top: 1px solid #f1f5f9;
  flex-shrink: 0;
}

.notif-dropdown__footer-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #2563eb;
  text-decoration: none;
  transition: color 0.15s;
}
.notif-dropdown__footer-link:hover { color: #1d4ed8; }

.notif-dropdown__footer-arrow {
  font-size: 1rem;
}

/* =========================================================
   Desktop: convert bottom-sheet to anchored dropdown
   ========================================================= */
@media (min-width: 1024px) {
  .notif-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    left: auto;
    bottom: auto;
    width: var(--notif-width);
    max-height: var(--notif-max-h);
    border-radius: var(--notif-radius);
    transform: translateY(-0.5rem) scale(0.97);
    opacity: 0;
    transition: transform 0.18s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.18s;
  }

  .notif-dropdown:not([hidden]) {
    transform: translateY(0) scale(1);
    opacity: 1;
  }

  .notif-dropdown[hidden] {
    transform: translateY(-0.5rem) scale(0.97);
    opacity: 0;
  }

  .notif-backdrop {
    display: none !important;
  }
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  .notif-dropdown {
    background: #1e293b;
    color: #f1f5f9;
  }
  .notif-dropdown__header { border-color: #334155; }
  .notif-dropdown__title  { color: #f1f5f9; }
  .notif-item { border-color: #1e293b; color: #f1f5f9; }
  .notif-item:hover { background: #334155; }
  .notif-item--unread { background: #1e3a5f; }
  .notif-item--unread:hover { background: #1e3a6e; }
  .notif-item__title { color: #f1f5f9; }
  .notif-item__message, .notif-item__time { color: #94a3b8; }
  .notif-dropdown__footer { border-color: #334155; }
  .notif-item__icon-wrap { background: #334155; }
  .notif-item--info    .notif-item__icon-wrap { background: #1e3a5f; }
  .notif-item--success .notif-item__icon-wrap { background: #14532d; }
  .notif-item--warning .notif-item__icon-wrap { background: #451a03; }
  .notif-item--error   .notif-item__icon-wrap { background: #450a0a; }
}
