:root {
    --background-color: #000;
    --text-color: #fff;
    --input-background: #2a2a2a;
    --input-text-color: #ccc;
    --bubble-user-background: #3a3a3a;
    --bubble-assistant-text: #ddd;
    /* --header-background: #1a1a1a; /* Removed as header now uses body background */
    --icon-color: #8e8e93;
    --send-button-active: #007aff;
    --header-height: 51px;
    --input-area-padding-bottom: 20px; /* Base padding for input area bottom (e.g., for home bar) */
    --calculated-input-area-height: 80px; /* Default/initial input area height, JS updates this */
    --header-border-color: #2a2a2a; /* Darker border color */
}

html, body {
    height: 100%; /* Ensure full height */
    margin: 0;
    padding: 0;
    overflow: hidden; /* Prevent body scroll (vertical and horizontal) */
    width: 100%; /* Ensure html/body don't exceed viewport width */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    position: relative; /* Needed for potential absolute positioning inside */
    overflow-x: hidden; /* Explicitly prevent horizontal scroll */
}

.header {
    background-color: var(--background-color); /* Match body background */
    padding: 10px 15px; /* Reverted horizontal padding */
    display: flex;
    align-items: center;
    justify-content: flex-end; /* Push icon to the right, logo will be absolute */
    position: fixed; /* Keep header fixed */
    top: 0;
    left: 0;
    right: 0;
    width: 100%; /* Ensure header spans full width */
    z-index: 1000;
    border-bottom: 1px solid var(--header-border-color); /* Use darker border color */
    height: var(--header-height);
    box-sizing: border-box;
    flex-shrink: 0;
    position: relative; /* Needed for absolute positioning of logo */
}

.logo {
    height: 30px;
    position: absolute; /* Position absolutely within the header */
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%); /* Center the logo */
}

.header-icon {
    height: 24px; /* Standard icon size */
    width: 24px;
    cursor: pointer;
    filter: invert(50%) sepia(11%) saturate(282%) hue-rotate(216deg) brightness(93%) contrast(86%); /* Match other icons */
    /* No need for margin-left: auto as justify-content: flex-end handles it */
}

/* Removed .header h1 styles as the element is gone */

/* Container for the scrollable chat messages */
.chat-container {
    flex-grow: 1; /* Takes up available space */
    overflow-y: auto; /* Enables vertical scrolling */
    overflow-x: hidden; /* Prevent horizontal scroll within container */
    padding-left: 15px; /* Reverted left padding */
    padding-right: 15px; /* Reverted right padding */
    /* Explicitly position below header and above input */
    margin-top: var(--header-height); /* Push below header */
    margin-bottom: var(--calculated-input-area-height); /* Space for input area, JS updates */
    box-sizing: border-box;
}

/* Inner box for message alignment and max-width */
.chat-box {
    width: 100%;
    max-width: 800px;
    margin: 10px auto; /* Vertical margin inside the container */
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message {
    /* General padding removed, applied specifically below */
    border-radius: 18px;
    /* max-width: 80%; Removed general max-width */
    word-wrap: break-word;
    line-height: 1.4;
}

.message.user {
    background-color: var(--bubble-user-background);
    color: var(--text-color);
    align-self: flex-end;
    border-bottom-right-radius: 5px;
    padding: 8px 12px; /* Optimized padding */
    max-width: 60% !important; /* Make user bubble significantly narrower, use !important to override potential conflicts */
}

.message.assistant {
    background-color: transparent;
    color: var(--bubble-assistant-text);
    align-self: flex-start;
    padding: 8px 0; /* Vertical padding, no horizontal */
    max-width: 75%; /* Set max width to 75% */
}

.message.assistant img {
    max-width: 50%;
    border-radius: 10px;
    margin: 8px 0;
}

.message p {
    margin: 0; /* Remove default paragraph margins */
}

.message img.uploaded-image-preview {
    max-width: 100%;
    max-height: 200px;
    border-radius: 10px;
    margin-top: 5px;
    display: block;
}

/* Fixed input area at the bottom */
.input-area {
    position: fixed; /* Keep input area fixed */
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%; /* Ensure input area spans full width */
    background-color: var(--background-color);
    padding: 10px 15px var(--input-area-padding-bottom) 15px; /* Reverted horizontal padding */
    display: flex;
    align-items: flex-end;
    gap: 10px;
    box-sizing: border-box;
    z-index: 1000;
    flex-shrink: 0;
}

.input-bubble {
    flex-grow: 1;
    display: flex;
    align-items: center; /* Vertically center items within the bubble */
    background-color: var(--input-background);
    border-radius: 22px;
    padding: 5px 10px; /* Reverted to original horizontal padding, vertical padding handled by align-items */
    min-height: 34px;   /* Reverted to original min-height */
    box-sizing: border-box;
}

.input-bubble textarea {
    flex-grow: 1;
    background-color: transparent;
    color: var(--input-text-color);
    border: none;
    padding: 0 5px; /* Removed vertical padding, keep horizontal */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; /* Keep correct font */
    font-size: 1em;
    resize: none;
    overflow-y: hidden;
    max-height: 100px;
    line-height: 34px; /* Match .input-bubble min-height for single line centering */
    outline: none;
    box-shadow: none;
    margin: 0 5px;
}

.input-bubble textarea::placeholder {
    color: #666;
}

.icon-button {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.icon-button img:not(.thumbnail-preview) {
    width: 24px;
    height: 24px;
    filter: invert(50%) sepia(11%) saturate(282%) hue-rotate(216deg) brightness(93%) contrast(86%);
}

.file-upload-label {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 0;
    cursor: pointer;
    flex-shrink: 0;
}

.thumbnail-preview {
    width: 24px;
    height: 24px;
    object-fit: cover;
    border-radius: 4px;
    margin-left: 5px;
    background-color: transparent;
    filter: none;
    opacity: 1;
}

#send-button {
    padding: 0;
    margin-left: 5px;
    flex-shrink: 0;
}

#file-input {
    display: none;
}

/* Responsive adjustments */
@media (max-width: 829px) {
    .message.user {
        max-width: 70% !important; /* Significantly narrower on mobile too */
    }
    .message.assistant {
        max-width: 90%; /* Keep assistant wider on mobile */
    }
    /* Removed .header h1 styles as the element is gone */
}

@media (min-width: 830px) {
    /* Center input area on larger screens */
    .input-area {
        max-width: 830px;
        margin-left: auto;
        margin-right: auto;
        left: 0; /* Ensure it spans width before centering */
        right: 0;
        /* Reverted padding */
        padding-left: 15px;
        padding-right: 15px;
    }
}



/* Tip Jar Popup Styles */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000; /* Higher than header */
}

.popup-content {
    background-color: var(--input-background);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 400px;
    text-align: center;
    position: relative;
    color: var(--text-color);
}

.close-popup {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 24px;
    font-weight: bold;
    color: var(--icon-color);
    cursor: pointer;
}

.popup-content h2 {
    margin-top: 0;
    margin-bottom: 10px; /* Reduced margin */
    font-size: 1.4em; /* Slightly smaller */
}

.promise-text {
    font-size: 0.9em;
    color: #bbb;
    margin-bottom: 20px;
}

.tip-options {
    display: flex;
    flex-wrap: wrap; /* Allow buttons to wrap on smaller screens */
    justify-content: center; /* Center buttons */
    gap: 8px; /* Space between buttons */
    margin-bottom: 20px;
}

.tip-button {
    background-color: var(--bubble-user-background);
    color: var(--text-color);
    border: none;
    padding: 8px 12px; /* Adjusted padding */
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9em; /* Adjusted font size */
    transition: background-color 0.2s;
    flex-grow: 1; /* Allow buttons to grow if space allows */
    min-width: 50px; /* Minimum width for each button */
}

/* Remove custom-tip styles as the element is gone */

.stripe-info {
    font-size: 0.8em;
    color: #aaa;
    margin-top: 15px; /* Added margin top */
}



.tip-message-area {
    margin-top: 15px;
    padding: 10px;
    border-radius: 6px;
    font-size: 0.9em;
    min-height: 20px; /* Ensure it's visible even when empty initially */
}

.tip-message-area.processing {
    background-color: #4a4a4a; /* Darker grey for processing */
    color: #fff;
}

.tip-message-area.success {
    background-color: #3c763d; /* Green for success */
    color: #fff;
}

.tip-message-area.error {
    background-color: #a94442; /* Red for error */
    color: #fff;
}



#card-element-container {
    margin-top: 15px;
    margin-bottom: 15px;
    width: 100%;
    box-sizing: border-box;
}

#card-element {
    border: 1px solid var(--header-border-color);
    border-radius: 6px;
    padding: 12px;
    background-color: var(--input-background);
    margin-bottom: 20px;
    min-height: 40px; /* Give it some default height */
}

#card-element-container #submit-payment-button.tip-button {
    width: 100%;
    box-sizing: border-box;
    margin-top: 0; /* card-element has margin-bottom */
    padding: 12px;
    font-size: 1em;
}




/* Styles for the new payment methods container */
.payment-methods-container {
    display: flex;
    flex-direction: column; /* Stack payment methods vertically */
    align-items: center; /* Center items horizontally */
    width: 100%;
    margin-top: 20px; /* Add some space above the payment methods */
}

/* Ensure each payment method block takes full width and has some bottom margin */
#apple-pay-button-placeholder,
#payment-request-button-container,
#card-element-container {
    width: 100%;
    max-width: 350px; /* Max width for better appearance on wider screens */
    margin-bottom: 15px; /* Space between payment method blocks */
    box-sizing: border-box;
}

/* Specific styling for the card label if needed */
.card-label {
    font-size: 0.9em;
    color: #bbb;
    margin-bottom: 8px; /* Space between label and card element */
    text-align: left;
}

/* Ensure the submit payment button also takes full width within its context */
#submit-payment-button.tip-button {
    width: 100%;
    max-width: 350px; /* Match other payment blocks */
    box-sizing: border-box;
    margin-top: 10px; /* Adjusted from 15px to be slightly closer after card element */
    padding: 12px;
    font-size: 1em;
}

/* Apple Pay button placeholder */
#apple-pay-button-placeholder {
    min-height: 44px; /* Default height for Stripe PRB consistency */
}

/* Ensure Payment Request Button (Google Pay) container is ready */
#payment-request-button-container {
    min-height: 44px; /* Default height for Stripe PRB */
}

/* Ensure card element container is ready */
#card-element-container {
    /* display: none; /* JS will control this based on PRB availability or as fallback */
}

/* Ensure submit button is ready and styled */
#submit-payment-button {
    /* display: none; /* JS will control this, shown with card element */
}


/* Styles for Tip Jar Steps */
#tip-selection-step {
    /* This div contains .tip-options. It's visible by default. */
    /* .tip-options already has margin-bottom: 20px; */
}

#payment-method-step {
    /* This div contains .payment-methods-container. 
       It's hidden by default (style="display: none;" in HTML) 
       and shown by JavaScript after a tip amount is selected. */
    /* .payment-methods-container already has margin-top: 20px; */
}

/* Ensure the main payment methods container within the second step is ready */
/* .payment-methods-container is already styled further down */

