/* =========================================
   HARE KRISHNA YOGA CENTER - STUDENT PORTAL
========================================= */

:root {
    --green: #628a52;
    --green-dark: #294f3c;
    --blue: #205e78;
    --cream: #fbf8f2;
    --white: #ffffff;
    --text: #34443d;
    --muted: #758078;
    --light: #f5f7f5;
    --border: #e4e9e3;
    --danger: #a5402d;
    --amber: #9a6a12;
    --heading-font: "Trebuchet MS", Arial, sans-serif;
    --body-font: Arial, Helvetica, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--body-font);
    color: var(--text);
    background: var(--cream);
    line-height: 1.6;
    min-height: 100vh;
}

button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue); }
[hidden] { display: none !important; }

/* header */
.p-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 14px 24px;
    background: var(--white);
    border-bottom: 1px solid var(--border);
}
.p-logo {
    font-family: var(--heading-font);
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--green-dark);
    text-decoration: none;
}
.p-om { color: var(--green); font-size: 1.3rem; }
.p-header-right { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; font-size: .95rem; }
.p-link { background: none; border: 0; color: var(--blue); cursor: pointer; text-decoration: underline; }

.p-main { max-width: 1180px; margin: 0 auto; padding: 28px 16px 60px; }
.p-muted { color: var(--muted); font-size: .92rem; }
.p-block { display: block; font-weight: normal; }
h1, h2, h3 { font-family: var(--heading-font); color: var(--green-dark); line-height: 1.25; }
h1 { font-size: 1.6rem; margin-bottom: 6px; }
h2 { font-size: 1.25rem; margin-bottom: 12px; }
h3 { font-size: 1.05rem; margin-bottom: 6px; }

/* cards & forms */
.p-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 22px;
    margin-bottom: 18px;
}
.p-auth { max-width: 440px; margin: 20px auto; }
.p-form { display: grid; gap: 14px; }
.p-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.p-field { display: grid; gap: 5px; }
.p-field label { font-weight: 700; font-size: .9rem; }
.p-field small { color: var(--muted); font-size: .82rem; }
.p-field input, .p-field select, .p-field textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #cfd8ce;
    border-radius: 8px;
    background: var(--white);
}
.p-field textarea { resize: vertical; min-height: 90px; }
.p-field input:focus, .p-field select:focus, .p-field textarea:focus {
    outline: 2px solid var(--green);
    outline-offset: 1px;
}
.p-field input[readonly], .p-field textarea[readonly], .p-field select:disabled { background: var(--light); }

.p-btn {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 999px;
    border: 0;
    background: var(--green);
    color: var(--white);
    font-weight: 700;
    cursor: pointer;
}
.p-btn:hover { background: var(--green-dark); }
.p-btn:disabled { opacity: .6; cursor: wait; }
.p-btn.secondary { background: var(--white); color: var(--green-dark); border: 1px solid var(--green); }
.p-btn.danger { background: var(--white); color: var(--danger); border: 1px solid var(--danger); }
.p-btn.small { padding: 6px 14px; font-size: .85rem; }
.p-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.p-msg { font-size: .92rem; min-height: 1.2em; }
.p-msg.error { color: var(--danger); }
.p-msg.ok { color: var(--green-dark); }

.p-switch { display: flex; gap: 6px; margin-bottom: 18px; }
.p-switch button {
    flex: 1;
    padding: 9px;
    border: 1px solid var(--border);
    background: var(--light);
    border-radius: 8px;
    cursor: pointer;
}
.p-switch button[aria-selected="true"] { background: var(--green); color: var(--white); border-color: var(--green); }

.p-auth-alt {
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
    display: grid;
    gap: 10px;
    justify-items: center;
    text-align: center;
}

.p-lock {
    font-size: .85rem;
    color: var(--muted);
    background: var(--light);
    border-radius: 8px;
    padding: 10px 12px;
}

/* layout for teachers */
.p-layout { display: grid; gap: 20px; grid-template-columns: 280px 1fr; align-items: start; }
.p-sidebar { position: sticky; top: 16px; }
.p-student-list { list-style: none; display: grid; gap: 6px; max-height: 70vh; overflow-y: auto; }
.p-student-list button {
    width: 100%;
    text-align: left;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--white);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    gap: 8px;
    align-items: center;
}
.p-student-list button[aria-current="true"] { border-color: var(--green); background: #eef4eb; }
.p-badges { display: flex; gap: 4px; flex-shrink: 0; }
.p-badge {
    font-size: .72rem;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--green);
    color: var(--white);
    white-space: nowrap;
}
.p-badge.q { background: var(--blue); }
.p-badge.grey { background: var(--muted); }

/* tabs */
.p-tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.p-tabs button {
    padding: 10px 14px;
    border: 0;
    background: none;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    color: var(--muted);
    font-weight: 700;
}
.p-tabs button[aria-selected="true"] { color: var(--green-dark); border-bottom-color: var(--green); }

/* chat */
.p-chat { display: flex; flex-direction: column; height: min(60vh, 560px); }
.p-chat-log {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    background: var(--light);
    border-radius: 10px;
    margin-bottom: 12px;
}
.p-bubble {
    max-width: 78%;
    padding: 8px 12px;
    border-radius: 12px;
    background: var(--white);
    border: 1px solid var(--border);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.p-bubble.mine { align-self: flex-end; background: #e3efdd; border-color: #cfe1c6; }
.p-bubble .meta { display: block; font-size: .72rem; color: var(--muted); margin-top: 3px; }
.p-chat-form { display: flex; gap: 8px; }
.p-chat-form textarea {
    flex: 1;
    padding: 10px;
    border: 1px solid #cfd8ce;
    border-radius: 8px;
    resize: none;
    height: 60px;
}

/* lists */
.p-list { display: grid; gap: 12px; }
.p-item { border: 1px solid var(--border); border-radius: 10px; padding: 14px; background: var(--white); }
.p-item-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.p-pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.p-answer { margin-top: 10px; padding: 10px 12px; border-left: 3px solid var(--green); background: #f3f8f1; }
.p-status { font-size: .78rem; font-weight: 700; padding: 2px 10px; border-radius: 999px; background: var(--light); }
.p-status.pending { color: var(--amber); }
.p-status.reflecting { color: var(--blue); }
.p-status.answered { color: var(--green-dark); background: #e3efdd; }
.p-status.ignored { color: var(--muted); }
.p-stars { color: #c9921b; letter-spacing: 2px; }

.p-table-wrap { overflow-x: auto; }
.p-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.p-table th, .p-table td { text-align: left; padding: 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.p-table select { padding: 5px; border-radius: 6px; border: 1px solid #cfd8ce; max-width: 180px; }

dialog.p-dialog {
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 22px;
    max-width: 440px;
    width: calc(100% - 32px);
    margin: auto;
}
dialog.p-dialog::backdrop { background: rgba(20, 30, 25, .45); }
dialog.p-dialog-wide { max-width: 520px; max-height: calc(100vh - 32px); overflow-y: auto; }
.p-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 6px; }
.p-list:empty { display: none; }
.p-list-row { display: flex; gap: 6px; align-items: center; }
.p-list-row input { flex: 1; min-width: 0; }
.p-field > .p-btn.small { justify-self: start; }
.p-badge.danger { background: var(--danger); }
.p-row-deleted td { opacity: .75; }
.p-row-deleted td:last-child { opacity: 1; }

@media (max-width: 820px) {
    .p-layout { grid-template-columns: 1fr; }
    .p-sidebar { position: static; }
    .p-student-list { max-height: 240px; }
    .p-header { padding: 12px 16px; }
    .p-bubble { max-width: 92%; }
}

/* sign-up: "I am a teacher" + choosing a teacher */
.p-check { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: .95rem; cursor: pointer; }
.p-check input { width: 18px; height: 18px; accent-color: var(--green, #2f6b4f); }
.p-choose-teacher { margin: 4px 0 14px; }
.p-inline { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; }
.p-inline .p-field { min-width: 240px; }

/* logged-in name + menu, top-right corner */
.p-user { position: relative; margin-left: auto; }
.p-user-btn {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 12px; border: 1px solid var(--border); border-radius: 999px;
    background: var(--white); cursor: pointer; color: var(--green-dark);
}
.p-user-btn:hover, .p-user-btn[aria-expanded="true"] { border-color: var(--green); }
.p-avatar { font-size: 1.05rem; }
.p-user-text { display: grid; text-align: left; line-height: 1.15; font-weight: 700; max-width: 220px; }
.p-user-text span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-user-text small { font-weight: normal; color: var(--muted); font-size: .75rem; }
.p-user-menu {
    position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 190px;
    display: grid; padding: 6px; background: var(--white);
    border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
}
.p-user-menu button { text-align: left; padding: 9px 12px; border: 0; border-radius: 6px; background: none; cursor: pointer; }
.p-user-menu button:hover, .p-user-menu button:focus-visible { background: var(--light); color: var(--green-dark); }
