/* POGIL support chat — shared modern engine */
:root {
    --pc-primary: #4A2D9F;
    --pc-dark: #1a0f3d;
    --pc-mid: #29166F;
    --pc-light: #6E52C7;
    --pc-bg: #f4f1fb;
    --pc-line: rgba(74, 45, 159, .12);
}

.pc-fab {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 1050;
    display: inline-flex;
    align-items: center;
    gap: .6rem;
    min-height: 54px;
    padding: 0 1.2rem 0 .75rem;
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    color: #fff;
    font: 800 .9rem/1 Manrope, system-ui, sans-serif;
    background: linear-gradient(135deg, var(--pc-light), var(--pc-mid));
    box-shadow: 0 16px 36px rgba(41, 22, 111, .3);
    transition: transform .2s ease, box-shadow .2s ease;
}
.pc-fab:hover { transform: translateY(-2px); box-shadow: 0 20px 40px rgba(41, 22, 111, .36); color: #fff; }
.pc-fab .pc-fab-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,.16);
    font-size: 1.05rem;
}
.pc-fab .pc-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 999px;
    background: #dc2626;
    color: #fff;
    font-size: .68rem;
    font-weight: 800;
    display: none;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
}
.pc-fab.has-unread .pc-badge { display: inline-flex; }

.pc-panel {
    position: fixed;
    right: 22px;
    bottom: 88px;
    z-index: 1050;
    width: min(400px, calc(100vw - 24px));
    height: min(620px, calc(100vh - 116px));
    background: #fff;
    border-radius: 24px;
    overflow: hidden;
    border: 1px solid var(--pc-line);
    box-shadow: 0 28px 70px rgba(26, 15, 61, .24);
    display: none;
    flex-direction: column;
    font-family: Manrope, system-ui, sans-serif;
}
.pc-panel.open { display: flex; animation: pcPop .28s cubic-bezier(.22,1,.36,1); }
.pc-panel.pc-no-fab { bottom: 22px; height: min(620px, calc(100vh - 44px)); }

.pc-head {
    padding: 1rem 1.05rem;
    color: #fff;
    background:
        radial-gradient(circle at 100% 0, rgba(110,82,199,.45), transparent 46%),
        linear-gradient(125deg, var(--pc-dark) 0%, var(--pc-mid) 55%, var(--pc-primary) 100%);
    display: flex;
    align-items: center;
    gap: .75rem;
}
.pc-avatar {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    background: rgba(255,255,255,.14);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    position: relative;
    flex-shrink: 0;
}
.pc-avatar .pc-online {
    position: absolute;
    right: -2px;
    bottom: -2px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: #22c55e;
    border: 2px solid var(--pc-mid);
}
.pc-head-copy { flex: 1; min-width: 0; }
.pc-head h3 { margin: 0; font-size: 1rem; font-weight: 800; letter-spacing: -.01em; }
.pc-status { margin: .18rem 0 0; font-size: .75rem; opacity: .86; font-weight: 600; display: flex; align-items: center; gap: .35rem; }
.pc-close {
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 11px;
    background: rgba(255,255,255,.12);
    color: #fff;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
}
.pc-close:hover { background: rgba(255,255,255,.2); }

.pc-thread {
    flex: 1;
    overflow-y: auto;
    padding: 1rem .9rem 1.15rem;
    background:
        radial-gradient(circle at 0 0, rgba(110,82,199,.06), transparent 40%),
        linear-gradient(180deg, #f7f5fc, #fff);
}
.pc-empty {
    text-align: center;
    color: #6b7280;
    padding: 2.4rem 1.1rem;
    font-weight: 650;
    line-height: 1.5;
}
.pc-empty i, .pc-empty .pc-empty-icon {
    display: inline-flex;
    width: 56px;
    height: 56px;
    border-radius: 18px;
    align-items: center;
    justify-content: center;
    background: #efeafc;
    color: var(--pc-light);
    font-size: 1.4rem;
    margin-bottom: .75rem;
}
.pc-day {
    display: flex;
    justify-content: center;
    margin: .35rem 0 .85rem;
}
.pc-day span {
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: #6b7280;
    background: rgba(255,255,255,.9);
    border: 1px solid var(--pc-line);
    border-radius: 999px;
    padding: .22rem .65rem;
}

.pc-msg, .sc-bubble {
    max-width: 84%;
    margin-bottom: .7rem;
    padding: .72rem .85rem .6rem;
    border-radius: 16px;
    font-size: .9rem;
    line-height: 1.45;
    word-break: break-word;
    position: relative;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}
.pc-msg.mine, .sc-bubble.admin {
    margin-left: auto;
    background: linear-gradient(180deg, #5b3db3, var(--pc-primary));
    color: #fff;
    border-bottom-right-radius: 5px;
}
.pc-msg.theirs, .sc-bubble.student, .sc-bubble.guest {
    margin-right: auto;
    background: #fff;
    border: 1px solid #ebe7f5;
    color: #1f2937;
    border-bottom-left-radius: 5px;
}
.pc-msg.pending { opacity: .72; }
.pc-msg.failed { outline: 1px solid #fecaca; }
.pc-who, .sc-meta {
    font-size: .68rem;
    font-weight: 800;
    opacity: .7;
    margin-bottom: .2rem;
}
.pc-when { font-size: .66rem; opacity: .68; margin-top: .35rem; display: flex; align-items: center; gap: .35rem; }
.pc-msg.mine .pc-when { justify-content: flex-end; }
.pc-tick { font-size: .72rem; opacity: .8; }
.pc-file, .sc-file {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    margin-top: .4rem;
    font-weight: 750;
    font-size: .8rem;
    text-decoration: none;
    color: inherit;
}
.pc-msg.theirs .pc-file, .sc-bubble.student .sc-file, .sc-bubble.guest .sc-file { color: var(--pc-primary); }
.pc-msg img.pc-preview, .sc-bubble img {
    display: block;
    max-width: min(220px, 70vw);
    border-radius: 12px;
    margin-top: .45rem;
    cursor: zoom-in;
}

.pc-composer {
    border-top: 1px solid #f0ecf8;
    padding: .75rem;
    background: #fff;
    position: relative;
}
.pc-composer.is-drag::after {
    content: "Drop file to attach";
    position: absolute;
    inset: 8px;
    border: 2px dashed var(--pc-light);
    border-radius: 14px;
    background: rgba(244, 241, 251, .92);
    color: var(--pc-primary);
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}
.pc-guest {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .45rem;
    margin-bottom: .5rem;
}
.pc-guest input, .pc-composer textarea {
    width: 100%;
    border: 1px solid #e0daf0;
    border-radius: 12px;
    padding: .6rem .75rem;
    font: 600 .88rem/1.4 Manrope, system-ui, sans-serif;
    background: #faf9fd;
    color: var(--pc-mid);
}
.pc-composer textarea { flex: 1; min-height: 44px; max-height: 120px; resize: none; }
.pc-composer textarea:focus, .pc-guest input:focus {
    outline: 0;
    border-color: var(--pc-primary);
    box-shadow: 0 0 0 .15rem rgba(74,45,159,.12);
    background: #fff;
}
.pc-row { display: flex; gap: .45rem; align-items: flex-end; }
.pc-icon, .pc-send {
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.pc-icon { background: #f3f0fb; color: var(--pc-primary); }
.pc-send { background: linear-gradient(135deg, var(--pc-light), var(--pc-mid)); color: #fff; }
.pc-send:disabled { opacity: .55; cursor: wait; }
.pc-chip {
    display: none;
    align-items: center;
    gap: .45rem;
    margin-bottom: .45rem;
    font-size: .78rem;
    font-weight: 700;
    color: var(--pc-primary);
    background: #f5f3ff;
    border-radius: 12px;
    padding: .35rem .7rem;
    width: fit-content;
    max-width: 100%;
}
.pc-chip.show { display: inline-flex; }
.pc-chip img { width: 28px; height: 28px; object-fit: cover; border-radius: 7px; }
.pc-chip button { border: 0; background: transparent; color: #6b7280; cursor: pointer; }
.pc-hint { margin: .4rem 0 0; font-size: .68rem; color: #9ca3af; font-weight: 650; }
.pc-error {
    margin: 0 0 .5rem;
    padding: .45rem .65rem;
    border-radius: 10px;
    background: #fef2f2;
    color: #b91c1c;
    font-size: .78rem;
    font-weight: 700;
    display: none;
}
.pc-error.show { display: block; }

.pc-lightbox {
    position: fixed;
    inset: 0;
    z-index: 1200;
    background: rgba(15, 10, 32, .82);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}
.pc-lightbox.open { display: flex; }
.pc-lightbox img { max-width: 92vw; max-height: 86vh; border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }

@keyframes pcPop {
    from { opacity: 0; transform: translateY(12px) scale(.97); }
    to { opacity: 1; transform: none; }
}

@media (max-width: 576px) {
    .pc-fab span.pc-fab-label { display: none; }
    .pc-fab { width: 58px; height: 58px; padding: 0; justify-content: center; border-radius: 50%; }
    .pc-panel, .pc-panel.pc-no-fab {
        right: 0; left: 0; bottom: 0; width: 100vw;
        height: min(92vh, 720px); border-radius: 20px 20px 0 0;
    }
    .pc-guest { grid-template-columns: 1fr; }
}

/* Admin inbox */
.pc-inbox { --p:#4A2D9F; --pd:#29166F; --pl:#6E52C7; --muted:#6b7280; --line:rgba(74,45,159,.1); }
.pc-inbox .sc-hero, .sc-inbox .sc-hero {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem;
    padding: 1.25rem 1.35rem; margin-bottom: 1rem; border-radius: 20px; color: #fff;
    background: linear-gradient(125deg, #1a0f3d 0%, #29166F 48%, #4A2D9F 100%);
}
.pc-inbox .sc-hero h1, .sc-inbox .sc-hero h1 { margin: 0 0 .25rem; font-size: 1.45rem; color: #fff !important; }
.pc-inbox .sc-hero p, .sc-inbox .sc-hero p { margin: 0; opacity: .85; font-weight: 600; }
.pc-inbox .sc-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; margin-bottom: 1rem; }
.pc-inbox .sc-metric { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: .95rem 1.05rem; }
.pc-inbox .sc-metric label { display: block; font-size: .68rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.pc-inbox .sc-metric strong { font-size: 1.4rem; color: var(--pd); font-weight: 800; }
.pc-inbox .sc-metric.unread strong { color: #dc2626; }
.pc-row-card {
    display: grid;
    grid-template-columns: 48px 1fr auto;
    gap: .85rem;
    align-items: center;
    padding: .95rem 1rem;
    border: 1px solid var(--pc-line);
    border-radius: 16px;
    margin-bottom: .65rem;
    text-decoration: none;
    color: inherit;
    background: #faf9fd;
    transition: box-shadow .2s ease, transform .2s ease;
}
.pc-row-card:hover { box-shadow: 0 12px 26px rgba(41,22,111,.08); color: inherit; transform: translateY(-1px); }
.pc-row-card.is-unread { background: #fff5f5; border-color: #fecaca; }
.pc-row-ava {
    width: 48px; height: 48px; border-radius: 16px;
    display: inline-flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #6E52C7, #29166F); color: #fff;
    font-weight: 800; letter-spacing: .02em;
}
.pc-row-card h3 { margin: 0 0 .2rem; font-size: .98rem; font-weight: 800; color: #29166F; }
.pc-row-card .preview { margin: 0; font-size: .84rem; color: #6b7280; font-weight: 650; }
.pc-row-card .meta { font-size: .75rem; color: #6b7280; font-weight: 650; margin-top: .28rem; display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.pc-chan {
    display: inline-flex; padding: .16rem .5rem; border-radius: 999px;
    font-size: .66rem; font-weight: 800; background: #efeafc; color: #4A2D9F;
}
.pc-pill { display: inline-flex; padding: .28rem .65rem; border-radius: 999px; font-size: .72rem; font-weight: 800; }
.pc-pill.unread { background: #fee2e2; color: #b91c1c; }
.pc-pill.open { background: #dcfce7; color: #166534; }
.pc-pill.closed { background: #f3f4f6; color: #4b5563; }

/* Admin thread shell */
.pc-admin-shell { display: grid; grid-template-columns: 300px 1fr; gap: 1rem; min-height: 72vh; align-items: stretch; }
.pc-admin-side, .pc-admin-main { background: #fff; border: 1px solid #ebe7f5; border-radius: 20px; min-height: 72vh; }
.pc-admin-side { padding: 1.2rem; }
.pc-admin-main { display: flex; flex-direction: column; overflow: hidden; }
.pc-admin-head { padding: 1rem 1.15rem; border-bottom: 1px solid #f0ecf8; }
.pc-admin-head h5 { margin: 0; color: #29166F; font-weight: 800; }
.pc-admin-thread {
    flex: 1 1 auto; overflow-y: auto; padding: 1.1rem;
    min-height: 420px; max-height: calc(100vh - 300px);
    background: linear-gradient(180deg, #faf9fd, #fff);
}
.pc-admin-compose { border-top: 1px solid #f0ecf8; padding: .85rem 1rem 1rem; background: #fff; }
@media (max-width: 900px) {
    .pc-admin-shell { grid-template-columns: 1fr; }
    .pc-admin-side, .pc-admin-main { min-height: auto; }
    .pc-admin-thread { min-height: 320px; }
    .pc-inbox .sc-metrics { grid-template-columns: 1fr; }
    .pc-row-card { grid-template-columns: 48px 1fr; }
}
