/*
 * ============================================================
 *  Gestalt Educational Institute — Notification System CSS
 *  Matches the site's dark olive & gold design language.
 *  Supports light/dark mode via [data-theme="dark"].
 * ============================================================
 */

/* ── Bell Icon Button ─────────────────────────────────────── */
#notif-btn,
#mobile-notif-btn-header {
    position: relative;
    background: transparent;
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: #ffffff;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
    /* Don't let it collapse in a flex row */
}

#notif-btn svg,
#mobile-notif-btn-header svg {
    width: 18px;
    height: 18px;
    display: block;
}

#notif-btn:hover,
#mobile-notif-btn-header:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: white;
    transform: rotate(-15deg);
}

/* Scrolled-state overrides to match the theme toggle */
.main-header.scrolled-state #notif-btn,
.main-header.scrolled-state #mobile-notif-btn-header {
    color: var(--color-primary);
    border-color: var(--color-primary);
}

.main-header.scrolled-state #notif-btn:hover,
.main-header.scrolled-state #mobile-notif-btn-header:hover {
    background: var(--color-primary);
    color: white;
}

[data-theme="dark"] #notif-btn,
[data-theme="dark"] #mobile-notif-btn-header {
    border-color: var(--color-accent);
    color: var(--color-accent);
}

/* ── Unread Badge (red dot) ───────────────────────────────── */
#notif-badge,
#mobile-notif-badge-header {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 10px;
    height: 10px;
    background: #e53e3e;
    border-radius: 50%;
    border: 2px solid #fff;
    display: none;              /* shown by JS when there are unread items */
    animation: pulse-badge 2s ease-in-out infinite;
}

@keyframes pulse-badge {
    0%, 100% { transform: scale(1);   opacity: 1; }
    50%       { transform: scale(1.3); opacity: 0.7; }
}

/* ── Panel Container ──────────────────────────────────────── */
#notif-panel {
    position: fixed;
    top: 70px;
    right: 16px;
    width: 360px;
    max-width: calc(100vw - 32px);
    max-height: 80vh;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 18px;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.14),
        0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(47, 62, 47, 0.12);
    z-index: 20000;
    display: flex;
    flex-direction: column;
    overflow: hidden;

    /* Hidden by default */
    opacity: 0;
    transform: translateY(-12px) scale(0.97);
    transform-origin: top right;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

#notif-panel.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

[data-theme="dark"] #notif-panel {
    background: rgba(15, 20, 15, 0.97);
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.5),
        0 2px 8px rgba(0, 0, 0, 0.3);
}

/* ── Panel Header ─────────────────────────────────────────── */
.notif-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px 14px;
    border-bottom: 1px solid var(--color-border, #e0e0e0);
    flex-shrink: 0;
}

[data-theme="dark"] .notif-header {
    border-color: rgba(255, 255, 255, 0.08);
}

.notif-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.notif-header-icon {
    width: 34px;
    height: 34px;
    background: var(--color-primary, #2F3E2F);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
}

.notif-header-icon svg {
    width: 16px;
    height: 16px;
}

.notif-title {
    font-family: 'Playfair Display', serif;
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-primary, #2F3E2F);
    margin: 0;
}

[data-theme="dark"] .notif-title {
    color: #e0e0e0;
}

.notif-count-chip {
    font-family: 'Lato', sans-serif;
    font-size: 0.7rem;
    font-weight: 700;
    background: var(--color-accent, #D4AF37);
    color: #1a1a1a;
    padding: 2px 8px;
    border-radius: 50px;
    letter-spacing: 0.3px;
}

.notif-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-muted, #555);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: 6px;
    transition: background 0.2s, color 0.2s;
}

.notif-close-btn svg {
    width: 16px;
    height: 16px;
}

.notif-close-btn:hover {
    background: rgba(0, 0, 0, 0.07);
    color: var(--color-primary, #2F3E2F);
}

[data-theme="dark"] .notif-close-btn {
    color: #a0a0a0;
}

[data-theme="dark"] .notif-close-btn:hover {
    background: rgba(255, 255, 255, 0.07);
    color: #e0e0e0;
}

/* ── Scrollable List Area ─────────────────────────────────── */
.notif-list-wrap {
    overflow-y: auto;
    flex: 1;
    padding: 10px 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(47, 62, 47, 0.25) transparent;
}

.notif-list-wrap::-webkit-scrollbar {
    width: 4px;
}

.notif-list-wrap::-webkit-scrollbar-thumb {
    background: rgba(47, 62, 47, 0.25);
    border-radius: 4px;
}

/* ── Individual Notification Card ────────────────────────── */
.notif-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 18px;
    border-radius: 10px;
    margin: 0 8px;
    transition: background 0.2s ease;
    cursor: default;
    position: relative;
}

.notif-item:hover {
    background: rgba(47, 62, 47, 0.05);
}

[data-theme="dark"] .notif-item:hover {
    background: rgba(255, 255, 255, 0.04);
}

/* Newest notification highlight */
.notif-item.is-newest {
    background: linear-gradient(
        135deg,
        rgba(212, 175, 55, 0.08) 0%,
        rgba(47, 62, 47, 0.06) 100%
    );
    border: 1px solid rgba(212, 175, 55, 0.3);
}

[data-theme="dark"] .notif-item.is-newest {
    background: linear-gradient(
        135deg,
        rgba(212, 175, 55, 0.1) 0%,
        rgba(62, 79, 62, 0.15) 100%
    );
    border-color: rgba(212, 175, 55, 0.25);
}

/* Left accent dot */
.notif-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-primary, #2F3E2F);
    flex-shrink: 0;
    margin-top: 6px;
    opacity: 0;
    transition: opacity 0.3s, background 0.3s;
}

.notif-item.is-unread .notif-dot {
    background: #e53e3e;
    opacity: 1;
    box-shadow: 0 0 6px rgba(229, 62, 62, 0.5);
}

.notif-item.is-newest .notif-dot {
    background: var(--color-accent, #D4AF37);
    opacity: 1;
    box-shadow: 0 0 6px rgba(212, 175, 55, 0.5);
}

/* If it is both unread and newest, prioritize the red unread dot, or keep it gold?
   We will let the red unread dot take precedence since it's an unread status indicator. */
.notif-item.is-unread.is-newest .notif-dot {
    background: #e53e3e;
    box-shadow: 0 0 6px rgba(229, 62, 62, 0.5);
}

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

.notif-msg {
    font-family: 'Lato', sans-serif;
    font-size: 0.88rem;
    color: var(--color-text-main, #2c2c2c);
    line-height: 1.5;
    margin: 0 0 4px;
    word-wrap: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.notif-msg em {
    font-style: italic;
}

.notif-msg strong {
    font-weight: 700;
}

.notif-read-more-wrap {
    margin-bottom: 4px;
}

[data-theme="dark"] .notif-msg {
    color: #ddd;
}

.notif-date {
    font-family: 'Lato', sans-serif;
    font-size: 0.72rem;
    color: var(--color-text-muted, #888);
    letter-spacing: 0.3px;
}

/* NEW badge on newest item */
.notif-new-badge {
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    background: var(--color-accent, #D4AF37);
    color: #1a1a1a;
    padding: 2px 6px;
    border-radius: 4px;
    flex-shrink: 0;
    margin-top: 4px;
}

/* Divider between items */
.notif-divider {
    height: 1px;
    background: var(--color-border, #e0e0e0);
    margin: 2px 18px;
    opacity: 0.5;
}

[data-theme="dark"] .notif-divider {
    background: rgba(255, 255, 255, 0.07);
}

/* ── Loading / Error / Empty States ──────────────────────── */
.notif-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 20px;
    gap: 10px;
    text-align: center;
}

.notif-state svg {
    width: 32px;
    height: 32px;
    color: var(--color-text-muted, #888);
    opacity: 0.5;
}

.notif-state p {
    font-family: 'Lato', sans-serif;
    font-size: 0.85rem;
    color: var(--color-text-muted, #888);
    margin: 0;
}

/* Spinning loader */
.notif-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--color-border, #e0e0e0);
    border-top-color: var(--color-primary, #2F3E2F);
    border-radius: 50%;
    animation: notif-spin 0.7s linear infinite;
}

[data-theme="dark"] .notif-spinner {
    border-color: rgba(255, 255, 255, 0.1);
    border-top-color: var(--color-accent, #D4AF37);
}

@keyframes notif-spin {
    to { transform: rotate(360deg); }
}

/* ── "View Past" / "Show Less" Footer Button ─────────────── */
.notif-footer {
    padding: 10px 14px 14px;
    border-top: 1px solid var(--color-border, #e0e0e0);
    flex-shrink: 0;
}

[data-theme="dark"] .notif-footer {
    border-color: rgba(255, 255, 255, 0.08);
}

#notif-view-past-btn {
    width: 100%;
    padding: 10px 16px;
    background: transparent;
    border: 1.5px solid var(--color-primary, #2F3E2F);
    border-radius: 10px;
    font-family: 'Lato', sans-serif;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--color-primary, #2F3E2F);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

#notif-view-past-btn:hover {
    background: var(--color-primary, #2F3E2F);
    color: #fff;
}

#notif-view-past-btn svg {
    width: 14px;
    height: 14px;
    transition: transform 0.25s ease;
}

#notif-view-past-btn.expanded svg {
    transform: rotate(180deg);
}

[data-theme="dark"] #notif-view-past-btn {
    border-color: var(--color-accent, #D4AF37);
    color: var(--color-accent, #D4AF37);
}

[data-theme="dark"] #notif-view-past-btn:hover {
    background: var(--color-accent, #D4AF37);
    color: #1a1a1a;
}

/* ── Past Notifications Expand Section ───────────────────── */
#notif-past-section {
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.35s ease;
}

#notif-past-section.expanded {
    max-height: 500px; /* large enough to reveal all items */
}

.notif-past-label {
    font-family: 'Lato', sans-serif;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--color-text-muted, #888);
    padding: 10px 18px 4px;
    display: block;
}

/* ── Click-outside backdrop ───────────────────────────────── */
#notif-backdrop {
    position: fixed;
    inset: 0;
    z-index: 19999;
    display: none;
}

#notif-backdrop.active {
    display: block;
}

/* ── Mobile Responsive ────────────────────────────────────── */
@media (max-width: 480px) {
    #notif-panel {
        top: 60px;
        right: 8px;
        left: 8px;
        width: auto;
        max-width: none;
        border-radius: 14px;
    }
}

/* ── Tappable notification card ───────────────────────────── */
.notif-tappable {
    cursor: pointer;
}

.notif-tappable:active {
    background: rgba(47, 62, 47, 0.09);
}

[data-theme="dark"] .notif-tappable:active {
    background: rgba(255, 255, 255, 0.07);
}

/* ── "Read more" inline link ──────────────────────────────── */
.notif-read-more {
    display: inline-block;
    font-family: 'Lato', sans-serif;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--color-primary, #2F3E2F);
    margin-left: 0;
    white-space: nowrap;
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
    transition: opacity 0.15s;
}

.notif-read-more:hover {
    opacity: 0.7;
}

[data-theme="dark"] .notif-read-more {
    color: var(--color-accent, #D4AF37);
}

/* ── Full-detail modal overlay ────────────────────────────── */
#notif-detail-modal {
    position: fixed;
    inset: 0;
    z-index: 25000;
    display: flex;
    align-items: flex-end;       /* card slides up from bottom */
    justify-content: center;
    pointer-events: none;
    visibility: hidden;
}

#notif-detail-modal.open {
    pointer-events: all;
    visibility: visible;
}

/* Semi-transparent backdrop behind the card */
#notif-detail-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.28s ease;
}

#notif-detail-modal.open #notif-detail-backdrop {
    opacity: 1;
}

/* The card itself */
#notif-detail-card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 420px;
    margin: 0 16px 24px;
    background: #ffffff;
    border-radius: 20px 20px 16px 16px;
    box-shadow:
        0 -4px 24px rgba(0, 0, 0, 0.15),
        0 8px 32px rgba(0, 0, 0, 0.12);
    overflow: hidden;

    /* slide-up animation */
    transform: translateY(40px) scale(0.97);
    opacity: 0;
    transition:
        transform 0.32s cubic-bezier(0.34, 1.2, 0.64, 1),
        opacity 0.28s ease;
}

#notif-detail-modal.open #notif-detail-card {
    transform: translateY(0) scale(1);
    opacity: 1;
}

[data-theme="dark"] #notif-detail-card {
    background: #1A221A;
    box-shadow:
        0 -4px 24px rgba(0, 0, 0, 0.5),
        0 8px 32px rgba(0, 0, 0, 0.4);
}

/* Header bar inside the card */
#notif-detail-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 18px 14px;
    background: var(--color-primary, #2F3E2F);
    color: #fff;
}

.notif-detail-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.notif-detail-icon svg {
    width: 18px;
    height: 18px;
    color: #fff;
}

.notif-detail-label {
    font-family: 'Playfair Display', serif;
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
    flex: 1;
    letter-spacing: 0.3px;
}

#notif-detail-close {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    cursor: pointer;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px;
    border-radius: 8px;
    transition: background 0.2s;
    flex-shrink: 0;
}

#notif-detail-close svg {
    width: 16px;
    height: 16px;
}

#notif-detail-close:hover {
    background: rgba(255, 255, 255, 0.28);
}

/* Body area */
#notif-detail-body {
    padding: 20px 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#notif-detail-msg {
    font-family: 'Lato', sans-serif;
    font-size: 0.95rem;
    color: var(--color-text-main, #2c2c2c);
    line-height: 1.65;
    margin: 0;
    word-wrap: break-word;
}

#notif-detail-msg em {
    font-style: italic;
}

#notif-detail-msg strong {
    font-weight: 700;
}

[data-theme="dark"] #notif-detail-msg {
    color: #ddd;
}

#notif-detail-date {
    font-family: 'Lato', sans-serif;
    font-size: 0.75rem;
    color: var(--color-text-muted, #888);
    letter-spacing: 0.3px;
}

/* Drag handle pill (purely decorative) */
#notif-detail-card::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.4);
    margin: 10px auto 0;
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
}

/* Desktop: centre the card instead of bottom-sheet */
@media (min-width: 520px) {
    #notif-detail-modal {
        align-items: center;
    }

    #notif-detail-card {
        margin: 0;
        border-radius: 20px;
        max-width: 400px;
    }

    #notif-detail-card::before {
        display: none;
    }
}

