/* STT Workspace PWA Notification Foundation.
 *
 * Minimal, clean, professional styles for the onboarding card, the badge,
 * and the Notification Center panel. No external dependencies — uses
 * existing STT Workspace design language (warm borders, sage palette,
 * Georgia/serif headings, soft shadows).
 *
 * Bell badge: canonical notification unread count only. One numeric badge.
 * Legacy workspace notices live in the workspace-notices panel (separate),
 * accessible via bell click. They are NOT shown as a numeric badge on bell.
 */

/* Bell badge — canonical unread count, one per bell.
 * Top-right of the bell glyph, not inline below it.
 * Bell button is position:relative so the badge anchors to it.
 */
[data-notification-badge] {
    position: absolute;
    top: -4px;
    right: -4px;
    display: inline-flex;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    align-items: center;
    justify-content: center;
    background: #e53935;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    border-radius: 999px;
    pointer-events: none;
    box-sizing: border-box;
    z-index: 1;
}
[data-notification-badge][hidden] {
    display: none;
}

/* Bell button (used inside existing app.js nav).
 * The bell is position:relative so the badge (position:absolute)
 * anchors to the bell's top-right corner.
 */
[data-notification-bell] {
    background: transparent;
    border: 0;
    color: inherit;
    cursor: pointer;
    font-size: 18px;
    position: relative;
    padding: 4px 8px;
}

/* Onboarding card */
.stt-onb {
    position: fixed;
    inset: auto 0 18px 0;
    display: flex;
    justify-content: center;
    z-index: 9999;
    pointer-events: none;
    opacity: 1;
    transition: opacity 220ms ease;
}
.stt-onb--hide {
    opacity: 0;
}
.stt-onb__wrap {
    pointer-events: auto;
    background: #fff;
    border: 1px solid #e3ded5;
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(28, 35, 30, .15);
    padding: 20px 22px;
    max-width: 420px;
    width: calc(100% - 32px);
    text-align: left;
    position: relative;
    color: #1f2937;
    font-family: inherit;
}
.stt-onb__close {
    position: absolute;
    top: 8px;
    right: 10px;
    background: transparent;
    border: 0;
    color: #6b7280;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}
.stt-onb__icon {
    font-size: 24px;
    margin-bottom: 6px;
}
.stt-onb__title {
    margin: 0 0 6px 0;
    font-size: 17px;
    font-weight: 600;
    color: #1f2937;
}
.stt-onb__body {
    margin: 0 0 14px 0;
    font-size: 14px;
    line-height: 1.45;
    color: #374151;
}
.stt-onb__actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.stt-onb__btn {
    border: 0;
    border-radius: 8px;
    padding: 9px 14px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}
.stt-onb__btn--primary {
    background: #2563eb;
    color: #fff;
}
.stt-onb__btn--primary:disabled {
    opacity: 0.6;
    cursor: progress;
}
.stt-onb__btn--ghost {
    background: transparent;
    color: #4b5563;
}
.stt-onb__hint {
    margin: 10px 0 0 0;
    font-size: 12px;
    color: #6b7280;
    min-height: 1.2em;
}
.stt-onb__hint[data-type="ok"] {
    color: #059669;
}
.stt-onb__hint[data-type="warn"] {
    color: #b45309;
}

/* Notification Center — Workspace design language.
 *
 * Warm STT palette: borders #e3ded5, surface #fff, header #f8f6f2,
 * unread highlight #f5f0e8 (warm), destructive muted #b34a3a.
 * No browser-default link blue: anchor colors and decorations are
 * explicitly neutralized inside the panel. Deep-link behavior is
 * preserved (we just style the anchor as a Workspace button).
 */
.stt-nc {
    position: fixed;
    top: 56px;
    right: 12px;
    width: 380px;
    max-width: calc(100vw - 24px);
    max-height: calc(100vh - 80px);
    background: #fff;
    border: 1px solid #e3ded5;
    border-radius: 14px;
    box-shadow: 0 18px 50px rgba(28, 35, 30, .18), 0 4px 12px rgba(28, 35, 30, .08);
    z-index: 9998;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: inherit;
    color: #1f2937;
}
.stt-nc[hidden] {
    display: none;
}

/* Hard reset: no blue default links, no underlines, inside the panel. */
.stt-nc,
.stt-nc * {
    color: inherit;
    text-decoration: none;
}
.stt-nc a,
.stt-nc a:visited,
.stt-nc a:hover,
.stt-nc a:active,
.stt-nc a:focus {
    color: inherit;
    text-decoration: none;
    outline: none;
}

.stt-nc__hd {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px 10px;
    border-bottom: 1px solid #e3ded5;
    background: #f8f6f2;
    flex-shrink: 0;
}
.stt-nc__title {
    font-weight: 600;
    font-size: 14px;
    color: #1f2937;
    letter-spacing: 0.01em;
}
.stt-nc__close {
    background: transparent;
    border: 0;
    font-size: 20px;
    line-height: 1;
    color: #7a807a;
    cursor: pointer;
    width: 28px;
    height: 28px;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.stt-nc__close:hover {
    background: #ede9e1;
    color: #1f2937;
}
.stt-nc__bd {
    overflow-y: auto;
    flex: 1;
    min-height: 60px;
    /* safe-area on iOS */
    padding-bottom: env(safe-area-inset-bottom);
}
.stt-nc__empty {
    padding: 22px 14px;
    color: #7a807a;
    font-size: 13px;
    text-align: center;
    line-height: 1.5;
}

/* Notification row.
 *
 * The row contains:
 *   .stt-nc__item-content  — clickable anchor (deep-link) — fills width
 *   .stt-nc__delete        — compact × action — right edge
 *
 * Padding/line-height tuned for iPhone comfortable touch target
 * (44px+ row height) and for desktop compact lists.
 */
.stt-nc__item {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 6px;
    padding: 12px 14px;
    border-bottom: 1px solid #ede9e1;
    color: #1f2937;
    background: transparent;
    text-decoration: none;
    cursor: pointer;
    transition: background 150ms ease;
}
.stt-nc__item:last-child {
    border-bottom: 0;
}
.stt-nc__item:hover {
    background: #faf7f1;
}
.stt-nc__item--unread {
    background: #f5f0e8;
}
.stt-nc__item--unread:hover {
    background: #ede5d6;
}

/* Subtle warm accent dot for unread — replaces browser blue. */
.stt-nc__item--unread::before {
    content: "";
    position: absolute;
    left: 5px;
    top: 18px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #c98a3c;
}
.stt-nc__item--unread {
    padding-left: 18px;
}

.stt-nc__item-content {
    flex: 1;
    min-width: 0;
    display: block;
    color: inherit;
    text-decoration: none;
    line-height: 1.4;
}
.stt-nc__row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
}
.stt-nc__t {
    font-size: 13.5px;
    font-weight: 600;
    color: #1f2937;
    line-height: 1.3;
    /* allow multi-line wrap with natural breaking */
    word-break: break-word;
}
.stt-nc__ts {
    font-size: 11px;
    color: #9ca3a0;
    white-space: nowrap;
    flex-shrink: 0;
    line-height: 1.3;
}
.stt-nc__b {
    margin: 4px 0 0 0;
    font-size: 12.5px;
    color: #5c6a64;
    line-height: 1.45;
    word-break: break-word;
}

/* Compact but usable × delete — non-default styling, warm Workspace. */
.stt-nc__delete {
    background: transparent;
    border: 0;
    color: #b0b0a8;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    width: 30px;
    height: 30px;
    border-radius: 7px;
    flex-shrink: 0;
    align-self: flex-start;
    transition: background 150ms, color 150ms;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    /* touch target usable on iPhone */
    padding: 0;
    text-decoration: none;
}
.stt-nc__delete:hover {
    background: #fde8e8;
    color: #b34a3a;
}
.stt-nc__delete:active {
    background: #fcd4d4;
}
.stt-nc__delete:focus {
    outline: 2px solid #c98a3c;
    outline-offset: 1px;
    color: #b34a3a;
}

/* Footer — two clean Workspace actions.
 *
 * Primary ("Đánh dấu tất cả đã đọc") = subtle sage.
 * Secondary ("Xóa thông báo đã đọc") = destructive-muted.
 * On narrow iPhone they stack vertically and respect safe area.
 */
.stt-nc__ft {
    padding: 10px 12px;
    border-top: 1px solid #ede9e1;
    background: #f8f6f2;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: stretch;
    /* iOS safe-area */
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
}
.stt-nc__ft-btn {
    width: 100%;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 9px;
    padding: 8px 10px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background 150ms, border-color 150ms, color 150ms;
    text-align: center;
    line-height: 1.4;
    letter-spacing: 0.01em;
    color: #1f2937;
    text-decoration: none;
    /* iPhone-friendly touch target */
    min-height: 36px;
}
.stt-nc__ft-btn:hover {
    text-decoration: none;
    color: inherit;
}
.stt-nc__ft-btn:focus {
    outline: 2px solid #c98a3c;
    outline-offset: 2px;
}
.stt-nc__ft-btn[hidden] {
    display: none;
}

/* Primary: subtle sage "Đánh dấu tất cả đã đọc". */
.stt-nc__ft-btn--primary {
    background: #e5f1e9;
    border-color: #cbe4d3;
    color: #33775d;
}
.stt-nc__ft-btn--primary:hover {
    background: #d8eadc;
    border-color: #b8dac5;
    color: #225c47;
}
.stt-nc__ft-btn--primary:active {
    background: #cbe4d3;
}

/* Secondary: destructive-muted "Xóa thông báo đã đọc". */
.stt-nc__ft-btn--danger {
    background: transparent;
    border-color: #e7d3ce;
    color: #b34a3a;
}
.stt-nc__ft-btn--danger:hover {
    background: #fde8e8;
    border-color: #e7b8b1;
    color: #8a362a;
}
.stt-nc__ft-btn--danger:active {
    background: #fcd4d4;
}

/* Mobile / iPhone — tighter sizing, footer vertical stack works at
 * 320px without overflow. We do NOT need a separate breakpoint for
 * the footer because it is already column-flex, but we tighten the
 * width and safe-area here for the panel itself.
 */
@media (max-width: 600px) {
    .stt-nc {
        top: 48px;
        right: 8px;
        left: 8px;
        width: auto;
        max-width: none;
        max-height: calc(100vh - 64px);
        border-radius: 12px;
    }
    .stt-nc__hd {
        padding: 10px 12px 8px;
    }
    .stt-nc__item {
        padding: 11px 12px;
    }
    .stt-nc__delete {
        width: 32px;
        height: 32px;
    }
    .stt-nc__ft {
        padding: 10px;
        padding-bottom: calc(10px + env(safe-area-inset-bottom));
    }
}

/* Desktop: allow the two footer controls to sit side-by-side when
 * there is enough room. This restores a non-noisy compact footer on
 * wider viewports while keeping the iPhone vertical stack.
 */
@media (min-width: 601px) {
    .stt-nc__ft {
        flex-direction: row;
        gap: 8px;
        padding: 9px 12px;
    }
    .stt-nc__ft-btn {
        width: auto;
        flex: 1;
    }
}
