/* ==========================================================================
   Bildirishnomalar

   A separate file on purpose: app.css is 2200 lines and was being edited by
   another pass at the same time as this. It loads after app.css and uses the
   same tokens (--surface, --line, --muted, --accent ...), so it inherits the
   theme, including dark, without redefining anything.

   The old panel was a Bootstrap dropdown of text rows: title in bold, message
   in grey, nothing else. Three rows reading "Yangi ta'minot so'rovi" told the
   director nothing about which was new, what kind of thing it was, or how long
   it had been waiting -- which is the entire job of the surface. And at 320px
   pinned to the corner of a 360px phone it was unreadable, with rows well under
   the 44px touch floor the rest of the app now meets.
   ========================================================================== */

.notif { position: relative; }

/* ---------------------------------------------------------------- trigger */

.notif-trigger { position: relative; }

.notif-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  /* Not the lime accent: a count is something waiting, and lime reads as
     "fine". #c8431f rather than a brighter orange because white on it measures
     4.91:1 and passes outright -- #d94f2b was 4.11 and would have needed the
     bold-text exemption to qualify, for a difference nobody can see. */
  background: #c8431f;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  border: 2px solid var(--surface);
  /* ease-out, not a spring: this is a work tool for a site office, and a
     badge that boings reads as a toy. Decelerate and stop. */
  transition: transform .18s cubic-bezier(.22, 1, .36, 1);
}

.notif-badge.is-empty { display: none; }

/* A new arrival nudges the badge once: enough to catch the eye of someone not
   looking at it, without overshooting. A 1.32 peak on a spring curve was a
   bounce; 1.14 on an ease-out is a nudge. */
.notif-badge.just-arrived { animation: notif-nudge .32s cubic-bezier(.22, 1, .36, 1); }

@keyframes notif-nudge {
  0%   { transform: scale(1); }
  45%  { transform: scale(1.14); }
  100% { transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .notif-badge, .notif-badge.just-arrived { transition: none; animation: none; }
  .notif-panel { transition: none !important; }
}

/* ------------------------------------------------------------------ panel */

.notif-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 1080;
  width: 384px;
  max-height: min(560px, calc(100vh - 120px));
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(16, 24, 40, .16), 0 2px 6px rgba(16, 24, 40, .08);
  overflow: hidden;
}

.notif-panel[hidden] { display: none; }

/* ------------------------------------------------------------------- head */

.notif-head {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.notif-title {
  margin: 0;
  font-size: 14px;
  font-weight: 650;
  flex: 1 1 auto;
}

.notif-clear {
  background: none;
  border: 0;
  padding: 6px 8px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}

.notif-clear:hover { background: var(--hover); color: var(--ink); }
.notif-clear.is-hidden { display: none; }

/* Desktop closes by clicking away; the explicit button is for the phone sheet,
   where there is no "away" to click. */
.notif-close { display: none; }

/* ------------------------------------------------------------------- list */

.notif-list {
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.notif-item {
  display: grid;
  grid-template-columns: 34px 1fr 10px;
  align-items: start;
  gap: var(--sp-md);
  padding: 13px 14px;
  min-height: 44px;
  border-bottom: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
}

.notif-item:last-child { border-bottom: 0; }
.notif-item:hover { background: var(--hover); }

.notif-item:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}

/* The level, as a shape and a colour rather than colour alone -- a grey wall of
   identical rows is what made the old panel unreadable, and colour on its own
   excludes anyone who cannot separate these hues. */
.notif-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  font-size: 14px;
  flex: 0 0 auto;
}

.notif-item.is-info    .notif-icon { background: rgba(43, 108, 176, .12); color: #2b6cb0; }
.notif-item.is-success .notif-icon { background: rgba(28, 107, 60, .12);  color: #1c6b3c; }
.notif-item.is-warning .notif-icon { background: rgba(138, 97, 0, .14);   color: #8a6100; }
.notif-item.is-danger  .notif-icon { background: rgba(179, 38, 30, .12);  color: #b3261e; }

:root[data-theme="dark"] .notif-item.is-info    .notif-icon { background: rgba(99, 160, 227, .16); color: #7fb3ea; }
:root[data-theme="dark"] .notif-item.is-success .notif-icon { background: rgba(126, 199, 155, .16); color: #7ec79b; }
:root[data-theme="dark"] .notif-item.is-warning .notif-icon { background: rgba(224, 179, 85, .18); color: #e0b355; }
:root[data-theme="dark"] .notif-item.is-danger  .notif-icon { background: rgba(239, 139, 132, .16); color: #ef8b84; }

.notif-body { min-width: 0; display: flex; flex-direction: column; gap: 2px; }

.notif-item-title {
  font-size: 14px;
  font-weight: 620;
  line-height: 1.35;
}

/* Two lines, then ellipsis: the full text is on the page the item links to, and
   a five-line message pushed every other notification out of view. */
.notif-item-text {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* --muted, not --faint: --faint is 3.39:1 on the dark panel and 2.81:1 on the
   light one, and the time is what tells the director how long a request has
   been waiting -- meaningful text, so it gets the secondary-text floor. */
.notif-time {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.notif-dot {
  width: 8px;
  height: 8px;
  margin-top: 6px;
  border-radius: 999px;
  background: #c8431f;
  flex: 0 0 auto;
}

/* ------------------------------------------------------------------ empty */

.notif-empty {
  padding: 36px 20px 40px;
  text-align: center;
  color: var(--muted);
}

.notif-empty i { font-size: 26px; opacity: .45; }
.notif-empty-title { margin: 12px 0 2px; font-size: 14px; font-weight: 620; color: var(--ink); }
.notif-empty-text { margin: 0; font-size: 13px; }

/* ------------------------------------------------- the feed went quiet */

/* The poller backs off to two minutes and used to fail without saying so, so a
   director on dropped wifi was shown "Hammasi joyida" over a cache nobody had
   refreshed for twenty minutes. Two markers now, because one is not enough:
   this dot says something is off, and the row inside the panel says what.

   Bottom-right, not top-right: .notif-badge already owns the top corner
   (top: 2px, 18px tall => y 2..20 of the 40px button), and this box is
   9px + 2x1.5px border = 12px at bottom/right 4 => y 24..36, x 24..36. No
   overlap, on the 40px desktop button or the 44px phone one.
   Grey, not the lime accent: lime means "fine" everywhere else in the app. */
.notif-trigger.is-stale::after {
  content: "";
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
  border: 1.5px solid var(--surface);
}

/* Sticky, and opaque so it stays legible over rows scrolling under it: the
   warning has to survive a scroll, otherwise it is only true at the top. */
.notif-stale {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  background: #FBF3DF;
  border-bottom: 1px solid #EADFBE;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.35;
}

/* #8a6100 on #FBF3DF measures 5.03:1, so it passes as text and not only as an
   icon -- the same warning ink the .notif-item warning icon already uses. */
.notif-stale-icon { color: #8a6100; font-size: 15px; flex: 0 0 auto; }

/* Shrinkable, and the only shrinkable item in the row: at 320px the sheet is
   full width, so the content box is 320 - 2x16 = 288px and the unshrinkable
   widths are icon 16 + gap 10 + gap 10 + button 90 = 126, leaving 162px for the
   text -- and 155 = 288 - 133 in the worst case, while the button is widened by
   its "Yangilanmoqda..." label. Both leave more than the 77px min-content of the
   longest Uzbek word here ("yangilanmadi"), so the row cannot overflow a 320px
   phone and nothing has to wrap onto a second line. */
.notif-stale-text { flex: 1 1 140px; min-width: 0; overflow-wrap: anywhere; }

.notif-stale-retry {
  flex: 0 0 auto;
  margin-left: auto;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid #8a6100;
  border-radius: 8px;
  background: var(--surface);
  color: #7A5600;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.notif-stale-retry:hover { background: #F6ECD3; }
.notif-stale-retry:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.notif-stale-retry:disabled { opacity: .55; cursor: default; }

:root[data-theme="dark"] .notif-stale {
  background: #302711;
  border-bottom-color: #46381A;
}
:root[data-theme="dark"] .notif-stale-icon { color: #E0B355; }
:root[data-theme="dark"] .notif-stale-retry { border-color: #8A6F2E; color: #E8C877; }
:root[data-theme="dark"] .notif-stale-retry:hover { background: #3A2F15; }

/* ------------------------------------------------------- phone: a sheet */

.notif-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1070;
  background: rgba(10, 10, 8, .42);
  display: none;
}

@media (max-width: 575.98px) {
  /* A 384px panel pinned to the corner of a 360px screen is unusable. Below
     576px it becomes a bottom sheet: full width, thumb-reachable, and it scrolls
     without taking the page with it. */
  .notif-panel {
    position: fixed;
    top: auto;
    right: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    max-height: 82vh;
    border-radius: 18px 18px 0 0;
    border-bottom: 0;
    box-shadow: 0 -8px 32px rgba(16, 24, 40, .22);
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  .notif-backdrop:not([hidden]) { display: block; }
  .notif-close { display: grid; place-items: center; width: 44px; height: 44px;
                 background: none; border: 0; color: var(--muted);
                 border-radius: 8px; cursor: pointer; }
  .notif-close:hover { background: var(--hover); }

  .notif-head { padding: 15px 16px; }
  /* The sheet's two head controls were the last ones under the 44px floor:
     close 36x36, and "mark all read" a 32px strip of grey text. */
  .notif-clear { min-height: 44px; padding: 0 12px; }
  .notif-title { font-size: 16px; }

  /* Comfortably above the touch floor, and the text sized for a phone rather
     than inherited from a desktop panel. */
  .notif-item { padding: 15px 16px; min-height: 60px; gap: 14px; }
  .notif-item-title { font-size: 15px; }
  .notif-item-text { font-size: 14px; }
  .notif-time { font-size: 12.5px; }

  /* 44px, the same touch floor app.css gives .btn and .btn-sm below 576px --
     this button is hand-rolled like .notif-clear, so it does not inherit it.
     Width is unchanged by the taller box: padding stays 0 12px, so "Yangilash"
     is still ~90px and the 288px row still holds it (see the arithmetic above). */
  .notif-stale { padding: 12px 16px; }
  .notif-stale-retry { min-height: 44px; }
}
