/* notifications.css — dropdown de notificações (issue #343).
 *
 * IMPORTANTE: o projeto usa tokens Material Design 3 (--surface,
 * --on-surface, --outline-variant, etc., definidos em tokens.css).
 * NÃO usar --card/--text/--line/--muted — esses não existem e o
 * `var()` cai pro initial value (transparent / preto) — popover ficou
 * transparente em prod no primeiro deploy do #343 antes deste fix.
 *
 * Fallbacks (#hex) garantem que mesmo sem tokens.css carregado o
 * popover renderiza visível.
 */

:root {
  --notif-info: #3b82f6;
  --notif-warning: #f59e0b;
  --notif-critical: #ef4444;
  --notif-backdrop: rgba(15, 23, 42, .35);
}

[data-theme="dark"] {
  --notif-backdrop: rgba(0, 0, 0, .55);
}

.iconbtn .badge[hidden] { display: none; }

/* ─── Panel base ───────────────────────────────────────────────────── */
.notif-panel {
  position: fixed;
  z-index: 1200;
  background: var(--surface-container-lowest, #ffffff);
  color: var(--on-surface, #1a1c1e);
  border-radius: 14px;
  border: 1px solid var(--outline-variant, #c4c6d0);
  box-shadow: 0 18px 50px rgba(15, 23, 42, .18);
  display: none;
  overflow: hidden;
  transform-origin: top right;
  font: inherit;
}
.notif-panel.is-open { display: block; animation: notif-pop .14s ease-out; }

@keyframes notif-pop {
  from { opacity: 0; transform: translateY(-6px) scale(.985); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

.notif-panel__inner {
  display: flex;
  flex-direction: column;
  max-height: 480px;
  background: var(--surface-container-lowest, #ffffff);
}

/* ─── Popover (desktop) ────────────────────────────────────────────── */
.notif-panel--popover {
  width: 380px;
  max-width: calc(100vw - 16px);
}

/* ─── Bottom sheet (mobile) ────────────────────────────────────────── */
.notif-panel--sheet {
  inset: auto 0 0 0;
  border-radius: 18px 18px 0 0;
  width: 100%;
  max-width: 100%;
  transform-origin: bottom center;
  box-shadow: 0 -18px 50px rgba(15, 23, 42, .25);
}
.notif-panel--sheet.is-open { animation: notif-slide-up .18s ease-out; }
.notif-panel--sheet .notif-panel__inner { max-height: 75vh; }

@keyframes notif-slide-up {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── Header ───────────────────────────────────────────────────────── */
.notif-panel__header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--outline-variant, #c4c6d0);
  background: var(--surface-container-lowest, #ffffff);
}
.notif-panel__title {
  font-weight: 600;
  font-size: 15px;
  flex: 1;
  color: var(--on-surface, #1a1c1e);
}
.notif-panel__readall {
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--primary, #2563eb);
  background: transparent;
  border: none;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
}
.notif-panel__readall:hover { background: rgba(37, 99, 235, .08); }
.notif-panel__close {
  background: transparent;
  border: none;
  color: var(--on-surface-variant, #43474e);
  cursor: pointer;
  border-radius: 8px;
  padding: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.notif-panel__close:hover { background: rgba(0,0,0,.05); color: var(--on-surface, #1a1c1e); }
.notif-panel__close .msym { font-size: 18px; }

.notif-panel--popover .notif-panel__close { display: none; }

/* ─── List ─────────────────────────────────────────────────────────── */
.notif-panel__list {
  list-style: none;
  padding: 4px 0;
  margin: 0;
  overflow-y: auto;
  flex: 1;
  background: var(--surface-container-lowest, #ffffff);
}

/* ─── Item ─────────────────────────────────────────────────────────── */
.notif-item {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--outline-variant, #c4c6d0);
  transition: background .12s;
  position: relative;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: rgba(37, 99, 235, .04); }
.notif-item:focus-visible {
  outline: 2px solid var(--primary, #2563eb);
  outline-offset: -2px;
}

.notif-item__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--on-surface-variant, #43474e);
  margin-top: 6px;
  align-self: start;
  justify-self: center;
  flex-shrink: 0;
}
.notif-item--info     .notif-item__dot { background: var(--notif-info); }
.notif-item--warning  .notif-item__dot { background: var(--notif-warning); }
.notif-item--critical .notif-item__dot { background: var(--notif-critical); }

.notif-item.is-unread .notif-item__title { font-weight: 600; }
.notif-item:not(.is-unread) { opacity: .82; }

.notif-item__body { min-width: 0; }
.notif-item__title {
  font-size: 13.5px;
  line-height: 1.35;
  color: var(--on-surface, #1a1c1e);
  word-wrap: break-word;
}
.notif-item__sub {
  font-size: 12.5px;
  color: var(--on-surface-variant, #43474e);
  margin-top: 2px;
  word-wrap: break-word;
}
.notif-item__time {
  font-size: 11.5px;
  color: var(--on-surface-variant, #43474e);
  margin-top: 4px;
}

.notif-item__archive {
  background: transparent;
  border: none;
  color: var(--on-surface-variant, #43474e);
  border-radius: 8px;
  padding: 6px;
  cursor: pointer;
  align-self: start;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity .12s, background .12s;
}
.notif-item:hover .notif-item__archive,
.notif-item:focus-within .notif-item__archive { opacity: 1; }
.notif-item__archive:hover { background: rgba(0,0,0,.06); color: var(--on-surface, #1a1c1e); }
.notif-item__archive .msym { font-size: 16px; }

@media (max-width: 640px) {
  .notif-item__archive { opacity: .6; }
  .notif-item__archive:active { opacity: 1; }
}

/* ─── Empty / Error states ─────────────────────────────────────────── */
.notif-panel__empty {
  padding: 36px 24px;
  text-align: center;
  color: var(--on-surface-variant, #43474e);
  background: var(--surface-container-lowest, #ffffff);
}
.notif-panel__empty .msym {
  font-size: 38px;
  opacity: .55;
  margin-bottom: 8px;
}
.notif-panel__empty p {
  margin: 0 0 4px;
  font-size: 14px;
  color: var(--on-surface, #1a1c1e);
}
.notif-panel__empty small {
  font-size: 12px;
  color: var(--on-surface-variant, #43474e);
}
.notif-panel__empty--error p { color: var(--notif-critical); }

/* ─── Backdrop pro sheet mobile ────────────────────────────────────── */
@media (max-width: 640px) {
  body.notif-open::before {
    content: "";
    position: fixed;
    inset: 0;
    background: var(--notif-backdrop);
    z-index: 1199;
    animation: notif-fade-in .14s ease-out;
  }
}

@keyframes notif-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ─── Dark mode ────────────────────────────────────────────────────── */
[data-theme="dark"] .notif-panel,
[data-theme="dark"] .notif-panel__inner,
[data-theme="dark"] .notif-panel__header,
[data-theme="dark"] .notif-panel__list,
[data-theme="dark"] .notif-panel__empty {
  background: #1f2937;
}
[data-theme="dark"] .notif-panel {
  border-color: #2d3748;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .4);
  color: #e2e8f0;
}
[data-theme="dark"] .notif-panel__title,
[data-theme="dark"] .notif-item__title,
[data-theme="dark"] .notif-panel__empty p { color: #e2e8f0; }
[data-theme="dark"] .notif-item__sub,
[data-theme="dark"] .notif-item__time,
[data-theme="dark"] .notif-panel__empty small { color: #94a3b8; }
[data-theme="dark"] .notif-panel__header { border-bottom-color: #2d3748; }
[data-theme="dark"] .notif-item { border-bottom-color: #2d3748; }
[data-theme="dark"] .notif-panel__readall:hover { background: rgba(96, 165, 250, .12); }
[data-theme="dark"] .notif-item:hover { background: rgba(96, 165, 250, .06); }
[data-theme="dark"] .notif-item__archive:hover { background: rgba(255,255,255,.08); }
