/* =============================================
   Parents Objections & Feedback — CSS
   The Eden School | Matching profile-style.css
   ============================================= */

:root {
    --primary-blue: #0f3057;
    --secondary-blue: #168aad;
    --gold: #d4af37;
    --gold-hover: #aa8436;
    --accent-glow: rgba(212, 175, 55, 0.3);
    --bg-light: #f8f9fa;
    --bg-card-light: rgba(255, 255, 255, 0.97);
    --text-dark: #1e293b;
    --text-muted: #64748b;
    --border-light: rgba(15, 48, 87, 0.08);

    --bg-dark-base: #0f172a;
    --bg-card-dark: rgba(30, 41, 59, 0.97);
    --text-light: #f1f5f9;
    --text-muted-dark: #94a3b8;
    --border-dark: rgba(255, 255, 255, 0.08);

    --dynamic-bg: var(--bg-light);
    --dynamic-card-bg: var(--bg-card-light);
    --dynamic-text: var(--text-dark);
    --dynamic-text-muted: var(--text-muted);
    --dynamic-border: var(--border-light);
    --transition-smooth: all 0.45s cubic-bezier(0.16, 1, 0.3, 1);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.16);
}

/* ── Dark Theme ─────────────────────────────── */
body.dark-theme {
    --dynamic-bg: var(--bg-dark-base);
    --dynamic-card-bg: var(--bg-card-dark);
    --dynamic-text: var(--text-light);
    --dynamic-text-muted: var(--text-muted-dark);
    --dynamic-border: var(--border-dark);
    color-scheme: dark;
}

/* ── FontAwesome spin fallback (only what FA doesn't already define) ── */
@keyframes fa-spin {
    0%   { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
.fa-spin { animation: fa-spin 1s linear infinite; }

/* Inline SVG icons (replacing FontAwesome webfont for offline/CDN-blocked reliability) */
i[class*="fa-"] { display: inline-flex; align-items: center; justify-content: center; line-height: 0; }
i[class*="fa-"] svg { display: block; width: 1em; height: 1em; }

/* ── Reset ──────────────────────────────────── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Poppins', sans-serif;
}

html, body {
    height: 100%;
    height: 100dvh;
    overflow: hidden;
    background-color: var(--dynamic-bg);
    color: var(--dynamic-text);
    transition: var(--transition-smooth);
}

/* Subtle dot grid — matches profile.html */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: radial-gradient(rgba(15, 48, 87, 0.03) 1px, transparent 1px);
    background-size: 24px 24px;
    z-index: 0;
    pointer-events: none;
}
body.dark-theme::before {
    background-image: radial-gradient(rgba(212, 175, 55, 0.025) 1px, transparent 1px);
}

/* ── Preloader ──────────────────────────────── */
#preloader {
    position: fixed;
    inset: 0;
    background: var(--primary-blue);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}
#preloader .pf-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255,255,255,0.15);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: pfSpin 0.9s linear infinite;
}
#preloader .pf-brand {
    font-family: 'Cinzel', serif;
    color: #fff;
    font-size: 0.8rem;
    letter-spacing: 0.12em;
    opacity: 0.85;
}
@keyframes pfSpin {
    to { transform: rotate(360deg); }
}
#preloader.hidden {
    opacity: 0;
    visibility: hidden;
}

/* ── Main Workspace (chat container) ────────── */
#mainWorkspace {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    max-width: 54rem;
    width: 100%;
    margin: 0 auto;
    background: var(--dynamic-card-bg);
    z-index: 1;
    overflow: hidden;
}

/* Desktop — floating card with margin */
@media (min-width: 768px) {
    #mainWorkspace {
        position: relative;
        margin: 1.5rem auto;
        height: calc(100dvh - 3rem);
        border-radius: 1.25rem;
        box-shadow: var(--shadow-lg), 0 0 0 1px var(--dynamic-border);
    }
}

/* ── Chat Header ────────────────────────────── */
.pf-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--primary-blue);
    color: #fff;
    border-bottom: 2.5px solid var(--gold);
    flex-shrink: 0;
    gap: 0.75rem;
    position: relative;
    z-index: 2;
}

.pf-header__left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.pf-back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 50%;
    color: #fff;
    text-decoration: none;
    transition: background 0.2s;
    flex-shrink: 0;
}
.pf-back-btn i { color: #fff; font-size: 1.05rem; }
.pf-back-btn:hover {
    background: rgba(22, 138, 173, 0.25);
}

.pf-avatar-wrap {
    position: relative;
    flex-shrink: 0;
}
.pf-avatar-wrap img {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--gold);
    background: #fff;
    display: block;
}
.pf-online-dot {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 0.75rem;
    height: 0.75rem;
    background: #4ade80;
    border: 2px solid var(--primary-blue);
    border-radius: 50%;
}

.pf-header__info {
    min-width: 0;
}
.pf-header__name {
    font-family: 'Cinzel', serif;
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.04em;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.pf-header__sub {
    font-size: 0.68rem;
    color: #cbd5e1;
    font-weight: 300;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    margin-top: 0.15rem;
}
.pf-header__sub i {
    color: var(--gold);
}

.pf-header__right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* Consecutive message badge */
#consecutiveBadge {
    font-family: 'Courier New', monospace;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--gold);
    background: rgba(15, 48, 87, 0.8);
    border: 1px solid rgba(212,175,55,0.3);
    padding: 0.2rem 0.6rem;
    border-radius: 0.3rem;
    white-space: nowrap;
}
#consecutiveBadge.hidden { display: none; }

/* Dark-mode toggle button in header */
.pf-theme-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: #cbd5e1;
    cursor: pointer;
    font-size: 0.95rem;
    transition: background 0.2s, color 0.2s;
}
.pf-theme-btn i { color: #cbd5e1; }
.pf-theme-btn:hover {
    background: rgba(22,138,173,0.25);
    color: var(--gold);
}
.pf-theme-btn:hover i { color: var(--gold); }

/* ── Chat Window ────────────────────────────── */
#chatWindow {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 1rem;
    background: var(--dynamic-bg);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    scroll-behavior: smooth;
}
body.dark-theme #chatWindow {
    background: #0f172a;
}

/* Custom scrollbar */
#chatWindow::-webkit-scrollbar { width: 5px; }
#chatWindow::-webkit-scrollbar-track { background: transparent; }
#chatWindow::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}
body.dark-theme #chatWindow::-webkit-scrollbar-thumb { background: #334155; }

/* ── Empty / Placeholder State ───────────────── */
.pf-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: 0.6rem;
    padding: 2rem 1rem;
    text-align: center;
    color: var(--dynamic-text-muted);
    animation: pfFadeIn 0.4s ease;
}
.pf-empty i {
    font-size: 3rem;
    color: rgba(15,48,87,0.45);
    margin-bottom: 0.25rem;
}
body.dark-theme .pf-empty i {
    color: rgba(212,175,55,0.45);
}
.pf-empty h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--dynamic-text);
}
.pf-empty p {
    font-size: 0.75rem;
    max-width: 18rem;
    line-height: 1.5;
}
.pf-empty .pf-reply-note {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--gold);
}

/* ── Date Dividers ──────────────────────────── */
.pf-date-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0.75rem 0 0.5rem;
}
.pf-date-divider span {
    background: rgba(203,213,225,0.55);
    color: #64748b;
    font-size: 0.625rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 0.2rem 0.75rem;
    border-radius: 9999px;
}
body.dark-theme .pf-date-divider span {
    background: rgba(51,65,85,0.55);
    color: #94a3b8;
}

/* ── Message Bubbles ────────────────────────── */
.pf-bubble-row {
    display: flex;
    width: 100%;
    animation: pfSlideIn 0.25s ease;
}
.pf-bubble-row.parent { justify-content: flex-end; }
.pf-bubble-row.admin  { justify-content: flex-start; }

@keyframes pfSlideIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.pf-bubble {
    max-width: 76%;
    padding: 0.625rem 0.875rem;
    border-radius: 1.1rem;
    box-shadow: 0 2px 6px rgba(0,0,0,0.07);
    word-break: break-word;
    white-space: pre-wrap;
    overflow-wrap: break-word;
}
@media (min-width: 768px) {
    .pf-bubble { max-width: 62%; }
}

/* Parent bubble (right, blue) */
.pf-bubble-row.parent .pf-bubble {
    background: var(--primary-blue);
    color: #fff;
    border-bottom-right-radius: 0.2rem;
}
body.dark-theme .pf-bubble-row.parent .pf-bubble {
    background: #1e3a5f;
}

/* Admin bubble (left, light) */
.pf-bubble-row.admin .pf-bubble {
    background: var(--dynamic-card-bg);
    color: var(--dynamic-text);
    border: 1px solid var(--dynamic-border);
    border-bottom-left-radius: 0.2rem;
}

.pf-bubble__text {
    font-size: 0.82rem;
    line-height: 1.55;
    margin-top: 0.2rem;
}

.pf-bubble__time {
    font-size: 0.58rem;
    text-align: right;
    margin-top: 0.3rem;
    opacity: 0.65;
}

/* Image inside bubble */
.pf-bubble__img-wrap {
    position: relative;
    overflow: hidden;
    border-radius: 0.6rem;
    margin-bottom: 0.35rem;
    cursor: pointer;
}
.pf-bubble__img-wrap img {
    display: block;
    width: 100%;
    max-height: 12rem;
    object-fit: cover;
    border-radius: 0.6rem;
    transition: opacity 0.2s;
}
.pf-bubble__img-wrap:hover img { opacity: 0.88; }
.pf-bubble__img-badge {
    position: absolute;
    bottom: 0.3rem;
    right: 0.4rem;
    background: rgba(0,0,0,0.6);
    color: #fff;
    font-size: 0.55rem;
    padding: 0.15rem 0.45rem;
    border-radius: 0.25rem;
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* ── Lock Warning Banner ────────────────────── */
#lockBanner {
    background: #fffbeb;
    border-top: 1px solid #fde68a;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    font-size: 0.78rem;
    color: #92400e;
    flex-shrink: 0;
    line-height: 1.45;
}
body.dark-theme #lockBanner {
    background: rgba(120,60,0,0.18);
    border-color: rgba(212,175,55,0.25);
    color: #fcd34d;
}
#lockBanner.hidden { display: none; }
#lockBanner i {
    color: var(--gold);
    font-size: 1.1rem;
    margin-top: 0.05rem;
    flex-shrink: 0;
    display: inline-block;
}
#lockBanner strong { font-weight: 600; }

/* ── Image Upload Preview Panel ─────────────── */
#imagePreviewContainer {
    background: var(--dynamic-card-bg);
    border-top: 1px solid var(--dynamic-border);
    padding: 0.5rem 0.875rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    gap: 0.5rem;
    animation: pfFadeIn 0.2s ease;
}
#imagePreviewContainer.hidden { display: none; }

.pf-preview-left {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.pf-preview-thumb {
    position: relative;
    width: 3rem;
    height: 3rem;
    border-radius: 0.4rem;
    overflow: hidden;
    border: 1px solid var(--dynamic-border);
    flex-shrink: 0;
}
.pf-preview-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
#uploadSpinner {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.85rem;
}
#uploadSpinner.hidden { display: none; }

.pf-preview-info p:first-child {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--dynamic-text);
}
#imageStatus {
    font-size: 0.68rem;
    color: var(--dynamic-text-muted);
    margin-top: 0.1rem;
}

#clearImageBtn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border: none;
    background: transparent;
    border-radius: 50%;
    color: #ef4444;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.2s, color 0.2s;
    flex-shrink: 0;
}
#clearImageBtn i { color: #ef4444; }
#clearImageBtn:hover { background: rgba(239,68,68,0.1); color: #dc2626; }
#clearImageBtn:hover i { color: #dc2626; }

/* ── Chat Input Form ────────────────────────── */
#chatForm {
    background: var(--dynamic-card-bg);
    border-top: 1px solid var(--dynamic-border);
    padding: 0.6rem 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
    position: relative;
    z-index: 2;
}

/* Attach button */
#attachBtn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.4rem;
    height: 2.4rem;
    border: none;
    background: transparent;
    border-radius: 50%;
    color: #64748b;
    cursor: pointer;
    font-size: 1.05rem;
    transition: color 0.2s, background 0.2s;
    flex-shrink: 0;
}
body.dark-theme #attachBtn { color: #94a3b8; }
#attachBtn:hover:not(:disabled) {
    color: var(--primary-blue);
    background: rgba(15,48,87,0.07);
}
body.dark-theme #attachBtn:hover:not(:disabled) {
    color: var(--gold);
    background: rgba(212,175,55,0.1);
}
#attachBtn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Text input */
#messageInput {
    flex: 1;
    min-width: 0;
    padding: 0.55rem 1rem;
    border: 1.5px solid var(--dynamic-border);
    border-radius: 9999px;
    font-size: 0.82rem;
    background: var(--dynamic-bg);
    color: var(--dynamic-text);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
#messageInput:focus {
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(15,48,87,0.08);
}
body.dark-theme #messageInput:focus {
    border-color: var(--secondary-blue);
    box-shadow: 0 0 0 3px rgba(22,138,173,0.12);
}
#messageInput::placeholder { color: var(--dynamic-text-muted); }
#messageInput:disabled {
    background: rgba(203,213,225,0.15);
    cursor: not-allowed;
    opacity: 0.75;
}

/* Send button */
#sendBtn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border: none;
    border-radius: 50%;
    background: var(--gold);
    color: #fff;
    cursor: pointer;
    font-size: 0.9rem;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
    box-shadow: 0 2px 8px rgba(212,175,55,0.3);
}
#sendBtn i { color: #fff; }
#sendBtn:hover:not(:disabled) {
    background: var(--gold-hover);
    transform: scale(1.05);
}
#sendBtn:active:not(:disabled) { transform: scale(0.97); }
#sendBtn:disabled {
    background: #cbd5e1;
    color: #94a3b8;
    box-shadow: none;
    cursor: not-allowed;
}
#sendBtn:disabled i { color: #94a3b8; }
body.dark-theme #sendBtn:disabled { background: #334155; color: #64748b; }

/* ── Fullscreen Image Modal ──────────────────── */
#fullscreenModal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.92);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: pfFadeIn 0.2s ease;
}
#fullscreenModal.hidden { display: none; }
#fullscreenModal img {
    max-height: 90dvh;
    max-width: 100%;
    object-fit: contain;
    border-radius: 0.6rem;
    box-shadow: 0 25px 50px rgba(0,0,0,0.6);
}
.pf-modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(255,255,255,0.12);
    border: none;
    color: #fff;
    font-size: 1.3rem;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.pf-modal-close i { color: #fff; }
.pf-modal-close:hover { background: rgba(255,255,255,0.22); }

/* ── Toast Notification ─────────────────────── */
#pfToast {
    position: fixed;
    bottom: 5.5rem;
    left: 50%;
    transform: translateX(-50%) translateY(1.5rem);
    background: #1e293b;
    color: #f1f5f9;
    font-size: 0.78rem;
    font-weight: 500;
    padding: 0.55rem 1.1rem;
    border-radius: 9999px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
    z-index: 9990;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}
#pfToast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
#pfToast.error { background: #7f1d1d; }
#pfToast.success { background: #14532d; }

/* ── Utility ────────────────────────────────── */
@keyframes pfFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.hidden { display: none !important; }