/* =================================================================== */
/* --- 1. CORE DESIGN TOKENS (from your website) --- */
/* =================================================================== */
:root {
    /* Main Brand Colors */
    --sage-dark: #4D5B46;
    /* hsl(142 35% 35%) */
    --sage-medium: #798D7A;
    /* hsl(142 25% 55%) */
    --sage-light: #BCC5B6;
    /* hsl(142 15% 85%) */
    --sage-pale: #F2F5F2;
    /* hsl(142 10% 95%) */
    --purple-medium: #A899AA;
    /* hsl(282 20% 70%) */

    /* Background & Text Colors */
    --background: #ffffff;
    /* hsl(0 0% 100%) */
    --foreground: #0c0a09;
    /* hsl(222.2 84% 4.9%) - A very dark gray/off-black */
    --foreground-muted: #78716c;
    /* A muted gray for secondary text */

    /* Component Colors */
    --card-background: #ffffff;
    --border-color: #D6DBD5;
    /* Based on sage-light */
    --input-color: #D6DBD5;
    /* Based on sage-light */
    --text-on-primary: #ffffff;
}

/* =================================================================== */
/* --- 2. GLOBAL STYLES & RESETS --- */
/* =================================================================== */
body {
    /* Using the "Inter" font to match your website */
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    margin: 0;
    background-color: var(--sage-pale);
    /* Use the pale sage for the main page background */
    color: var(--foreground);
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Add a Google Font import at the top for "Inter" */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap');

* {
    box-sizing: border-box;
}

/* =================================================================== */
/* --- 3. LAYOUT & CORE COMPONENTS --- */
/* =================================================================== */
header {
    background-color: var(--card-background);
    padding: 15px 30px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

h1 {
    margin: 0;
    font-size: 1.5em;
    font-weight: 700;
}

main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    min-height: 0;
}

.hidden {
    display: none !important;
}

/* Generic Button Style to match ".btn-brand" */
button {
    border: none;
    border-radius: 1rem;
    /* Rounded corners */
    background-color: var(--sage-medium);
    padding: 0.75rem 1.5rem;
    /* Adjusted padding */
    font-weight: 600;
    color: var(--text-on-primary);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

button:hover {
    background-color: var(--sage-dark);
    transform: scale(1.05);
    /* Hover effect */
}

/* =================================================================== */
/* --- 4. AUTHENTICATION VIEW --- */
/* =================================================================== */
#auth-view-container {
    max-width: 400px;
    margin: 40px auto;
    padding: 30px;
    background-color: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 1.5rem;
    /* Match .card-modern */
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
}

#signin-form,
#signup-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#signin-form input,
#signup-form input {
    padding: 12px;
    border-radius: 8px;
    /* Slightly more rounded */
    border: 1px solid var(--input-color);
    background-color: var(--background);
    font-size: 1em;
}

#signin-form input:focus,
#signup-form input:focus {
    outline: 2px solid transparent;
    outline-offset: 2px;
    border-color: var(--sage-medium);
    box-shadow: 0 0 0 2px var(--background), 0 0 0 4px var(--sage-medium);
}

#sign-out-button {
    background-color: #8D798C;
    /* A purple tone from your site */
}

#sign-out-button:hover {
    background-color: #745C76;
}

.auth-toggle {
    text-align: center;
    margin-top: 20px;
    font-size: 1.2em;
    color: var(--foreground);
}

.auth-toggle a {
    color: var(--sage-dark);
    font-weight: 600;
    text-decoration: none;
}

.auth-toggle a:hover {
    text-decoration: underline;
}

.auth-message {
    text-align: center;
    min-height: 1.2em;
    font-size: 0.9em;
}

p#signup-message.success-message {
    color: var(--sage-dark);
}

p#signup-message.error-message {
    color: #c0392b;
    /* Red */
}

/* =================================================================== */
/* --- 5. CONVERSATION LIST VIEW --- */
/* =================================================================== */
#conversation-list-container {
    max-width: 800px;
    margin: 20px auto;
    padding: 20px 30px;
    background-color: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 1.5rem;
    /* Match .card-modern */
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
}

.list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.list-header h2 {
    margin: 0;
    padding-right: 15px;
    font-weight: 700;
}

#new-chat-button {
    background-color: var(--purple-medium);
    padding: 8px 16px;
    font-weight: 600;
}

#new-chat-button:hover {
    background-color: #8D798C;
    /* Darker purple */
}

.conversation-item {
    padding: 15px;
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    /* Rounded */
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

.conversation-item:hover {
    border-color: var(--sage-medium);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px -2px rgba(0, 0, 0, 0.08);
}

.conversation-item h4 {
    margin: 0 0 5px 0;
    color: var(--sage-dark);
    font-weight: 600;
}

.conversation-item p {
    margin: 0;
    font-size: 0.9em;
    color: var(--foreground-muted);
}

/* =================================================================== */
/* --- 6. CHAT VIEW --- */
/* =================================================================== */
#chat-container {
    max-width: 800px;
    width: 100%;
    margin: 0 auto;

    display: flex;
    flex-direction: column;
    flex-grow: 1;
    /* Make it fill the available space in <main> */
    min-height: 0;
    /* Prevents strange overflow bugs in some browsers */
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

#chat-title {
    margin: 0;
    font-weight: 600;
}

#back-to-conversations-button {
    background-color: transparent;
    color: var(--sage-medium);
    border: 1px solid var(--sage-light);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    padding: 0;
    line-height: 1;
    font-size: 1.2em;
}

#back-to-conversations-button:hover {
    background-color: var(--sage-pale);
    border-color: var(--sage-medium);
}

#chat-window {
    flex-grow: 1;
    overflow-y: auto;
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 15px;
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
}

.message {
    padding: 10px 15px;
    border-radius: 18px;
    max-width: 80%;
    word-wrap: break-word;
    line-height: 1.5;
}

.user-message {
    background-color: var(--sage-medium);
    /* Use brand color for user */
    color: var(--text-on-primary);
    align-self: flex-end;
    border-bottom-right-radius: 5px;
}

.bot-message {
    background-color: var(--sage-pale);
    /* Use lighter color for bot */
    color: var(--foreground);
    border: 1px solid var(--sage-light);
    align-self: flex-start;
    align-content: start;
    border-bottom-left-radius: 5px;
}

#chat-form {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

#message-input {
    flex-grow: 1;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--input-color);
    resize: none;
    font-size: 1em;
}

#send-button {
    padding: 0 20px;
    /* Give send button nice padding */
}

#loading-indicator {
    display: flex;
    justify-content: center;
    padding: 10px;
}

.spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border-left-color: var(--sage-medium);
    /* Match brand color */
    animation: spin 1s ease infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.loading-full-chat {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
}

.feedback-container {
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px solid var(--sage-light);
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 0.9em;
    color: var(--foreground-muted);
}

.feedback-buttons button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.5em;
    padding: 0 5px;
    transform: scale(1);
    transition: transform 0.2s ease;
}

.feedback-buttons button:hover {
    transform: scale(1.2);
}

/* Modal Styles */
#feedback-modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

#feedback-modal {
    background-color: var(--card-background);
    padding: 25px;
    border-radius: 1rem;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

#feedback-modal h4 {
    margin-top: 0;
    margin-bottom: 20px;
    font-weight: 600;
}

.feedback-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 15px;
}

.feedback-options label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

#feedback-other-text {
    width: 100%;
    min-height: 80px;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--input-color);
    resize: vertical;
    margin-bottom: 20px;
    display: none;
    /* Hidden by default */
}

.modal-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

#cancel-feedback-button {
    background-color: #6c757d;
    /* Gray */
}

/* ... (keep all existing styles) ... */

/* --- NEW STYLES FOR CONVERSATION FEEDBACK --- */
#conversation-feedback-container {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

#convo-feedback-form h4 {
    margin-top: 0;
    margin-bottom: 15px;
    font-weight: 600;
}

#convo-feedback-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.rating-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.rating-group label {
    font-weight: 500;
}

/* Star Rating CSS Trick */
.star-rating {
    display: flex;
    flex-direction: row-reverse;
    /* Important for the hover/checked effect */
    justify-content: center;
}

.star-rating input[type="radio"] {
    display: none;
    /* Hide the actual radio button */
}

.star-rating label {
    font-size: 2em;
    color: #ccc;
    cursor: pointer;
    transition: color 0.2s ease;
}

.star-rating input[type="radio"]:checked~label,
.star-rating label:hover,
.star-rating label:hover~label {
    color: #fdd835;
    /* Gold color for stars */
}

/* End Star Rating Trick */

.yes-no-rating {
    display: flex;
    gap: 15px;
}

.yes-no-rating label {
    display: flex;
    align-items: center;
    gap: 5px;
}

#convo-feedback-form textarea {
    width: 100%;
    min-height: 80px;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--input-color);
    resize: vertical;
}

#convo-feedback-thanks p {
    text-align: center;
    font-weight: 600;
    color: var(--sage-dark);
}

#open-convo-feedback-container {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

#open-convo-feedback-button {
    background-color: transparent;
    color: var(--sage-dark);
    border: 1px solid var(--sage-medium);
    font-weight: 600;
    transition: all 0.2s ease;
}

#open-convo-feedback-button:hover {
    background-color: var(--sage-pale);
    border-color: var(--sage-dark);
    transform: scale(1.02);
}

/* --- UPDATED MODAL STYLES --- */
#convo-feedback-modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

#convo-feedback-modal {
    background-color: var(--card-background);
    padding: 25px;
    border-radius: 1rem;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

#convo-feedback-thanks {
    text-align: center;
}

#convo-feedback-thanks p {
    margin: 15px 0;
}

#close-convo-feedback-button {
    margin: 0 auto;
    /* Center the close button */
}

/* Copy these styles from the message feedback modal */
.modal-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

#cancel-convo-feedback-button {
    background-color: #6c757d;
    /* Gray */
}