/* 
    Font faces 
*/

@font-face {
    font-family: 'PP Eiko Thin';
    src: local('PP Eiko'), local('ppeiko-thin'),
        url('fonts/PPEiko/ppeiko-thin.ttf') format('truetype');
    font-weight: 100;
    font-style: normal;
}

@font-face {
    font-family: 'PP Eiko';
    src: local('PP Eiko'), local('ppeiko-medium'),
        url('fonts/PPEiko/ppeiko-medium.ttf') format('truetype');
    font-weight: 300;
    font-style: normal;
}

@font-face {
    font-family: 'PP Eiko Heavy';
    src: local('PP Eiko'), local('ppeiko-heavy'),
        url('fonts/PPEiko/ppeiko-heavy.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
}

@font-face {
    font-family: 'Freight Sans Pro';
    src: local('Freight Sans Pro Light Regular'), local('Freight-Sans-Pro-Light-Regular'),
        url('fonts/FreightSansPro/FreightSansProLight-Regular.woff2') format('woff2'),
        url('fonts/FreightSansPro/FreightSansProLight-Regular.woff') format('woff'),
        url('fonts/FreightSansPro/FreightSansProLight-Regular.ttf') format('truetype');
    font-weight: 300;
    font-style: normal;
}

@font-face {
    font-family: 'Freight Sans Pro';
    src: local('Freight Sans Pro Medium Regular'), local('Freight-Sans-Pro-Medium-Regular'),
        url('fonts/FreightSansPro/FreightSansProMedium-Regular.woff2') format('woff2'),
        url('fonts/FreightSansPro/FreightSansProMedium-Regular.woff') format('woff'),
        url('fonts/FreightSansPro/FreightSansProMedium-Regular.ttf') format('truetype');
    font-weight: 500;
    font-style: normal;
}

@font-face {
    font-family: 'Freight Sans Pro';
    src: local('Freight Sans Pro Semi bold Regular'), local('Freight-Sans-Pro-Semi-bold-Regular'),
        url('fonts/FreightSansPro/FreightSansProSemibold-Regular.woff2') format('woff2'),
        url('fonts/FreightSansPro/FreightSansProSemibold-Regular.woff') format('woff'),
        url('fonts/FreightSansPro/FreightSansProSemibold-Regular.ttf') format('truetype');
    font-weight: 600;
    font-style: normal;
}

/* 
    General styling 
*/

html, body {
    height: 100%;
    margin: 0;
    overflow: hidden;
    background: #efeee6;
}

#Back {
    display: none;
}

a {
    color: #074728;
    text-decoration: underline;
}

.content-area {
    flex: 1 1 auto;
    display: flex;
    flex-direction: row;
    min-height: 0;
    max-width: 1900px;
    width: 100%;
    margin: 0 auto;
    padding: 16px 24px 24px;
    box-sizing: border-box;
    gap: 20px;
}

/*
    Font styling 
*/

h1 {
    font-family: "PP Eiko", serif;
    font-weight: 300;
    color: #074728;
}

h2 {
    font-family: "Freight Sans Pro", sans-serif;
    font-weight: 600;
    color: #2e6c4f;
}

h3, h4, h5, h6 {
    font-family: "Freight Sans Pro", sans-serif;
    font-weight: 500;
    color: #074728;
}

html, body, p, button, a, .chat-input input {
    font-family: "Freight Sans Pro", sans-serif;
    font-weight: 300;
}

p, .chat-input input {
    color: #538060;
}

a {
    color: #074728;
    text-decoration: underline;
}

/* Override non scrollable for persona page */
body.persona-page {
    overflow-y: auto;
    overflow-x: hidden;
}

.page-shell {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

@supports (height: 100dvh) {
    .page-shell {
        height: 100dvh;
    }
}

/* 
    Navbar styling 
*/

.navbar {
    position: relative;
    height: 7vh;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    background: #e7e6dd;
    color: #074728;
    flex: 0 0 auto;
    overflow: hidden;
    border-bottom: 1px solid #dedcce;
}

/* Logo on the left side of the navbar*/
.navbar-left {
    position: absolute;
    left: 24px;
    height: 100%;
    display: flex;
    align-items: center;
}

.navbar-left a {
    height: 100%;
    display: flex;
    align-items: center;
    text-decoration: none;
}

.navbar-left img {
    display: block;
    max-height: 100%;
    width: auto;
    object-fit: contain;
}

.navbar-title {
    font-size: 24px;
    font-weight: 600;
    text-align: center;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.navbar-right {
    max-width: 100%;
    min-width: 0;
    position: absolute;
    right: 24px;
    height: 100%;
    display: flex;
    align-items: center;
    overflow: hidden;
}

.navbar-right .persona-buttons {
    width: 100%;
    min-width: 0;
    justify-content: flex-end;
    gap: 6px;
}

.navbar-right .persona-buttons > * {
    min-width: 0;
    flex: 1 1 0;
}

.navbar-right .persona-buttons > :only-child {
    flex: 0 1 auto;
}

.navbar-right .persona-buttons form {
    width: auto;
    overflow: hidden;
}

.navbar-right .persona-buttons button {
    display: block;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    white-space: wrap;
    text-align: center;
    padding-left: 8px;
    padding-right: 8px;
}



/* 
    interview.php specific styling
*/

.chatbox {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: #e7e6dd;
    border-radius: 18px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
    overflow: hidden;
}

.chat-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column-reverse;
    padding: 24px 28px;
    box-sizing: border-box;
}

.message-row {
    display: flex;
    margin-bottom: 18px;
}

.message-row.ai {
    justify-content: flex-start;
}

.message-row.person {
    justify-content: flex-end;
}

/* wraps the sender name + bubble, keeps the width cap in one place */
.message-group {
    display: flex;
    flex-direction: column;
    max-width: 78%;
}

.message-sender {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #8a8878;
    margin-bottom: 4px;
}

/* your name sits on the right above your bubbles */
.message-row.person .message-sender {
    text-align: right;
}

.message-bubble {
    max-width: 100%;
    padding: 14px 18px;
    word-wrap: break-word;
    border-radius: 14px;
    line-height: 1.5;
    font-size: 15.5px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.12);
}

.message-row.person .message-bubble {
    background: #143d2e;
    color: #f3f2ea;
}

.message-row.ai .message-bubble {
    background: #f1efe4;
    color: #074728;
    border: 1px solid #dedcce;
}

.message-counter {
    font-size: 20px;
    color: red;
    text-align: center;
    margin-top: 6px;
}

.chat-input {
    flex: 0 0 auto;
    width: 100%;
    background: transparent;
    padding: 12px 20px calc(18px + env(safe-area-inset-bottom));
    box-sizing: border-box;
    height: auto;
    min-height: auto;
}

.chat-input form {
    height: 100%;
    display: flex;
    align-items: stretch;
    gap: 10px;
}

/* Hides a label visually but keeps it available to screen readers.
   Not display:none, that would remove it from the accessibility tree too. */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    border: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
}

.chat-input input {
    flex: 1 1 auto;
    min-width: 0;
    height: 52px;
    padding: 14px 18px;
    font-size: 16px;
    border: 2px solid #004728;
    border-radius: 14px;
    background: #fdfcf6;
    box-sizing: border-box;
    outline: none;
}

.chat-input button {
    flex: 0 0 auto;
    height: 52px;
    width: 54px;
    background: #004728;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-input button:hover {
    background: #316c50;
}

.chat-input button img {
    display: block;
    height: 45%;
    max-height: 100%;
    width: auto;
    object-fit: contain;
    filter: brightness(0) invert(1); /* white icon on green, remove if icon already white */
}

.persona-info {
    flex: 0 0 auto;
    width: 300px;
    background: #e7e6dd;
    color: #074728;
    padding: 20px;
    box-sizing: border-box;
    border-radius: 18px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);

    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.persona-info h1 {
    font-family: "PP Eiko";
    font-size: 24px;
    margin-top: 0;
}

.persona-info p {
    white-space: pre-wrap;
    font-size: 13.5px;
    line-height: 1.5;
}

.persona-info img.persona-image {
    width: 100%;
    height: auto;
    border-radius: 10px;
    margin-bottom: 12px;
}

.persona-content {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.persona-buttons {
    flex: 0 0 auto;
    display: flex;
    gap: 10px;
}

.persona-buttons form {
    display: flex;
    margin: 0;
}

.persona-card .persona-buttons {
    margin-bottom: 10px;
}

.persona-buttons button {
    background: #e7b654;
    color: #fff;
    border: none;
    padding: 10px 20px;
    cursor: pointer;
    border-radius: 8px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    text-decoration: none;
}

.persona-buttons button:hover {
    background: #e7d993;
}

.persona-buttons a {
    color: inherit;
    text-decoration: none;
}


/*
    persona_select.php specific styling
*/

.persona-selection {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 1900px;
    width: 100%;
    margin: 0 auto;
    gap: 16px;
    padding: 16px;
    box-sizing: border-box;
}

.content-area h3 {
    width: 100%;
    margin-top: 0;
    text-align: center;
}

.persona-card {
    display: flex;
    flex-direction: column;
    flex: 0 1 320px;
    background: #fdfcf6;
    border: 1px solid #dedcce;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s;
    max-width: 20%;
    min-width: 260px;
    height: auto;
    white-space: pre-wrap;
}

.persona-card:hover {
    background: #e7e6dd;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.persona-card img {
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 8px;
}

.persona-card h3 {
    font-size: 24px;
}

.index-actions .persona-card {
    justify-content: center;
}

.index-card button {
    width: 100%;
    min-height: 120px;
    padding: 16px;
    border: none;
    background: transparent;
    color: #074728;
    font: inherit;
    font-size: 18px;
    cursor: pointer;
}

.tc-card {
    background: #fdfcf6;
    border: 1px solid #dedcce;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
    height: auto;
    white-space: normal;
    width: min(100%, 800px);
    box-sizing: border-box;
}


/*
    login.php specific
*/

.loginForm {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.loginForm .form-label,
.loginForm .form-control {
    width: 100%;
    box-sizing: border-box;
}

.loginForm .form-label {
    font-size: 18px;
    color: #074728;
}

.loginForm .form-control {
    min-height: 48px;
    padding: 10px 14px;
    font-size: 17px;
}

.loginForm .persona-buttons {
    width: 100%;
    justify-content: center;
    margin-top: 8px;
}

.loginForm button {
    width: 100%;
    min-height: 48px;
    font-size: 17px;
}


/*
    admin_panel.php specific
*/

.admin-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 20px;
}

.admin-panel button {
    width: 100%;
    min-height: 48px;
    font-size: 17px;
}

/* 
    Accordion and panel styling partially copied from https://www.w3schools.com/howto/howto_js_accordion.asp 
    CfLS styling has been applied
*/
.accordion {
    cursor: pointer;
    color: #fff;
    background-color: #004728;
    padding: 18px;
    border: none;
    border-radius: 8px;
    outline: none;
    transition: 0.4s;
}

.active, .accordion:hover {
    background-color: #316c50;
}

.panel {
    padding-left: 18px;
    padding-right: 18px;
    padding-bottom: 18px;
    width: 100%;
    display: none;
    overflow: hidden;
}

.panel input,
.panel select {
    border: 2px solid #004728;
    border-radius: 14px;
    background-color: #fff;
    font-family: inherit;
    font-size: 16px;
    color: #074728;
}

.panel button {
    border: none;
    border-radius: 8px;
    color: #fff;
    background-color: #004728;
}

.panel button:hover {
    background-color: #316c50;
}

/* Admin Alert & Status Banners */
.admin-alert {
    width: 100%;
    margin: 12px auto 0;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 15px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

.admin-alert-success {
    background-color: #e7eee6;
    border: 1px solid #cbdccd;
    color: #074728;
}

.admin-alert-error {
    background-color: #f5e4e2;
    border: 1px solid #e3c2bf;
    color: #9c322c;
}

.admin-alert-warning {
    background-color: #f5ede2;
    border: 1px solid #e3d6bf;
    color: #b4741c;
}

/* API Status & Metrics Components */
.api-status-box {
    margin-bottom: 16px;
    padding: 12px;
    background-color: #fdfcf6;
    border: 1px solid #dedcce;
    border-radius: 10px;
}

.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 15px;
    margin: 4px 0;
    padding: 4px 10px;
    border-radius: 6px;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.status-connected {
    color: #074728;
    background-color: #e7eee6;
}

.status-connected .status-dot {
    background-color: #074728;
}

.status-disconnected {
    color: #9c322c;
    background-color: #f5e4e2;
}

.status-disconnected .status-dot {
    background-color: #9c322c;
}

.status-detail {
    margin: 4px 0 0;
    font-size: 13px;
    color: #555;
}

.api-metrics-box {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid #e7e6dd;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
    margin-top: 8px;
}

.metric-item {
    background-color: #fdfcf6;
    border: 1px solid #dedcce;
    border-radius: 8px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
}

.metric-label {
    font-size: 12px;
    color: #538060;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-value {
    font-size: 20px;
    font-weight: bold;
    color: #074728;
    margin-top: 4px;
}

/*
    Desktop Styles
*/

@media (min-width: 801px) {
    .navbar-title {
        max-width: 40%;
        white-space: nowrap;
    }

    .navbar-title h3 {
        width: 100%;
        margin: 1em 0;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
    }

    .navbar-right {
        left: 70%;
        right: 24px;
        width: auto;
    }
}

/* 
    Mobile Styles 
*/

@media (max-width: 800px) {
    h1 {
        font-size: 45px !important;
    }

    .persona-info {
        display: none; 
    }

    .navbar {
        position: relative;
        justify-content: flex-start;
        padding: 12px 16px;
    }

    .navbar-left {
        left: 0px;
        position: absolute;
    }
    
    .navbar-title {
        display: none;
    }

    .navbar-right {
        left: 96px;
        right: 16px;
    }
}

/* ==========================================================================
    Admin pages (admin_panel.php, persona_manage.php)
    Appended block. Everything is scoped to .admin-page so the student
    pages above are not affected.
   ========================================================================== */

/* width includes padding, otherwise a 100% wide button overflows its card */
.admin-page *,
.admin-page *::before,
.admin-page *::after {
    box-sizing: border-box;
}

body.admin-page {
    display: flex;
    flex-direction: column;
    height: 100vh;
    min-height: 0;
    overflow: hidden;
}

/* 
    Admin topbar 
*/

.admin-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 24px;
    background: #e7e6dd;
    border-bottom: 1px solid #dedcce;
}

.admin-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    text-decoration: none;
}

.admin-brand img {
    height: 42px;
    width: auto;
}

.admin-brand span {
    font-family: "PP Eiko", serif;
    font-size: 22px;
    color: #074728;
}

/* the small ADMINISTRATION line under the name */
.admin-brand small {
    display: block;
    font-family: "Freight Sans Pro", sans-serif;
    font-size: 11px;
    letter-spacing: 2px;
    color: #538060;
}

.admin-logout {
    padding: 10px 18px;
    background: #fdfcf6;
    border: 1px solid #dedcce;
    border-radius: 8px;
    color: #074728;
    text-decoration: none;
}

.admin-logout:hover {
    background: #e7eee6;
}

/* 
    Admin sidebar and main column 
*/

.admin-layout {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    align-items: stretch;
}

.admin-sidebar {
    flex: 0 0 220px;
    padding: 24px 16px;
    background: #e7e6dd;
    border-right: 1px solid #dedcce;
}

.admin-sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.admin-sidebar nav a {
    padding: 12px 16px;
    border-radius: 8px;
    color: #074728;
    text-decoration: none;
}

.admin-sidebar nav a:hover {
    background: #e7eee6;
}

/* the page you are on */
.admin-sidebar nav a[aria-current] {
    background: #074728;
    color: #efeee6;
}

.admin-main {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    overflow-y: auto;
    padding: 32px;
}

.admin-heading {
    width: 100%;
    max-width: 800px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin-bottom: 24px;
}

.admin-heading h1 {
    font-size: 38px;
    margin: 0 0 8px;
}

.admin-heading p {
    margin: 0 0 18px;
}

/* 
    Admin buttons 
*/

.admin-form {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: center;
}

.admin-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 20px;
    background: #074728;
    border: 1px solid #074728;
    border-radius: 8px;
    color: #efeee6;
    font-family: "Freight Sans Pro", sans-serif;
    font-size: 16px;
    text-decoration: none;
    cursor: pointer;
}

.admin-button:hover {
    background: #04331d;
    color: #efeee6;
}

/* edit sits next to delete, so it stays quiet */
.admin-button-quiet {
    background: #e7eee6;
    border-color: #cbdccd;
    color: #074728;
}

.admin-button-quiet:hover {
    background: #d9e5da;
    color: #074728;
}

.admin-button-delete {
    background: #fff;
    border-color: #e3c2bf;
    color: #9c322c;
}

.admin-button-delete:hover {
    background: #f5e4e2;
    color: #9c322c;
}

/* 
    Persona cards 
*/

.persona-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 16px;
}

.persona-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 0 1 300px;
    padding: 20px;
    background: #fdfcf6;
    border: 1px solid #dedcce;
    border-radius: 12px;
}

.persona-tile h2 {
    font-size: 20px;
    margin: 0 0 6px;
    overflow-wrap: anywhere;
}

.persona-tile p {
    font-size: 14px;
    margin: 0 0 16px;
}

/* the about text can be short, this keeps the buttons lined up */
.persona-tile form {
    margin: 8px 0 0;
}

.persona-tile .admin-button {
    width: 100%;
}

.persona-tile .admin-button-quiet {
    margin-top: auto;
}

/* round photo, or the initials when there is no photo */
.persona-photo {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 96px;
    height: 96px;
    margin-bottom: 16px;
    background: #e7eee6;
    border-radius: 50%;
    overflow: hidden;
    color: #074728;
    font-family: "PP Eiko", serif;
    font-size: 30px;
}

.persona-photo img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 
    Add and edit popovers 
*/

.admin-page [popover] {
    width: min(92vw, 520px);
    /* the edit form is taller than a laptop screen, so let it scroll */
    max-height: 85vh;
    overflow-y: auto;
    padding: 28px;
    background: #fdfcf6;
    border: 1px solid #dedcce;
    border-radius: 12px;
}

.admin-page [popover]::backdrop {
    background: rgba(7, 51, 29, 0.35);
}

.admin-page [popover] h2 {
    margin: 0 0 16px;
}

.admin-page [popover] form {
    display: flex;
    flex-direction: column;
}

.admin-page [popover] label {
    margin: 16px 0 6px;
    color: #074728;
}

.admin-page [popover] label:first-of-type {
    margin-top: 0;
}

.admin-page [popover] input,
.admin-page [popover] textarea {
    padding: 10px 12px;
    background: #fff;
    border: 1px solid #dedcce;
    border-radius: 8px;
    font-family: "Freight Sans Pro", sans-serif;
    font-size: 15px;
    color: #074728;
}

.admin-page [popover] textarea {
    min-height: 90px;
    resize: vertical;
}

/* the prompt is the long one, give it more room than the about text */
.admin-page [popover] #add-prompt,
.admin-page [popover] #edit-prompt {
    min-height: 150px;
}

.admin-page [popover] button {
    margin-top: 22px;
}

/* 
    Admin mobile styles 
*/

@media (max-width: 768px) {

    .admin-sidebar {
        border-right: none;
        border-bottom: 1px solid #dedcce;
        padding: 12px 16px;
    }

    .admin-sidebar nav {
        flex-direction: row;
    }

    .admin-layout {
        display: block;
    }

    .admin-main {
        overflow: visible;
    }

    .persona-tile {
        flex-basis: 100%;
    }

    body.admin-page {
        height: auto;
        min-height: 100vh;
        overflow-y: auto;
        overflow-x: hidden;
    }

    html:has(body.admin-page) {
        height: auto;
        overflow-y: auto;
        overflow-x: hidden;
    }
}