/* ========== ROOT VARIABLES ========== */
:root {
    /* Color palette */
    --background-color: #21593B;
    --panel-background: #EEF3EE;
    --button-color: #103930;
    --button-text: #F6DA2E;
    --button-hover-color: #F6DA2E;
    --button-hover-text: #103930;
    --drag-area: #61A450;
    --thinking-text: #F6DA2E;
    --primary-text: #57605a;
    --secondary-text: #8c9c91;
    --model-text: #103930;
    --header-background: #61A450;
    --header-rule: #C7C9C7;
    --light-text: #EEF3EE;
    --dark-text: #000000;
}

/* ========== BASE STYLES ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: NunitoSans, sans-serif;
    font-weight: 400;
    font-style: normal;
    font-size: 1rem;
    line-height: 1.5625;
    background-color: var(--background-color);
    color: var(--primary-text);
    padding: 20px;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: 'Amiri', serif;
    -webkit-font-smoothing: antialiased;
    font-weight: 500;
    font-style: normal;
    color: var(--dark-text);
    line-height: 1.0714285714;
    letter-spacing: -.6px;
    margin-bottom: 15px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ========== HEADER STYLES ========== */
header {
    padding: 20px 0;
    text-align: center;
}

.logo-container {
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.logo {
    display: block;
    width: 290px;
    height: 90px;
    fill: #fff;
    flex-shrink: 0;
    margin-right: 220px;
}

header h1 {
    color: var(--light-text);
    font-weight: 500;
    font-size: 1.75rem;
    /* text-shadow: 0 0 4px rgba(0, 0, 0, .65); */
    margin: 0;
    padding-left: 342px;
    /* for 75% width */
    /* padding-left: 220px; */
    /* for 66% width */
    align-self: flex-end;
}

/* ========== TOOLTIP STYLES ========== */
.tooltip-container {
    position: relative;
    display: inline-block;
    cursor: help;
}

.tooltip {
    visibility: hidden;
    width: 240px;
    background-color: rgba(238, 243, 238, 0.8);
    color: var(--primary-text);
    text-align: center;
    border-radius: 2px;
    padding: 8px 12px;
    font-family: 'Nunito Sans', sans-serif;
    font-size: 1rem;
    font-weight: 400;
    letter-spacing: 0.01em;
    text-shadow: none;

    /* Position the tooltip */
    position: absolute;
    z-index: 100;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%) translateY(100%);

    /* Add a subtle border */
    border: 1px solid rgba(0, 0, 0, 0.1);

    /* Add drop shadow */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);

    /* Add transition for smooth appearance */
    opacity: 0;
    transition: opacity 0.3s, visibility 0.3s;
}

/* Add a small arrow at the top of the tooltip */
.tooltip::before {
    content: "";
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 0 6px 6px 6px;
    border-style: solid;
    border-color: transparent transparent var(--panel-background) transparent;
}

/* Show the tooltip when hovering over the container */
.tooltip-container:hover .tooltip {
    visibility: visible;
    opacity: 1;
}

/* ========== INPUT CONTAINER STYLES ========== */
.input-container {
    background-color: var(--panel-background);
    border-radius: 2px;
    overflow: hidden;
    width: 75%;
    margin: 0 auto;
    box-shadow: inset 0 3px 6px 0 rgba(0, 0, 0, .1);
}

.text-image-input {
    position: relative;
    min-height: 150px;
}

#user-input {
    width: 100%;
    min-height: 150px;
    padding: 20px;
    border: none;
    background-color: transparent;
    font-family: 'Nunito Sans', sans-serif;
    font-size: 1rem;
    color: var(--primary-text);
    resize: vertical;
    outline: none;
}

#user-input::placeholder {
    color: var(--secondary-text);
}

/* ========== IMAGE UPLOAD AREA STYLES ========== */
.image-drop-area {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(97, 164, 80, 0.2);
    /* Use a semi-transparent version of --model-text (#61A450) */
    border: 2px dashed var(--button-color);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

.image-drop-area p {
    color: var(--primary-text);
    font-weight: 600;
}

.image-drop-area.active {
    display: flex;
}

.image-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 20px;
}

.image-preview img {
    max-width: 100px;
    max-height: 100px;
    object-fit: cover;
    border-radius: 2px;
}

.image-preview .image-item {
    position: relative;
}

.image-preview .remove-image {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: var(--button-color);
    color: var(--light-text);
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
}

.image-item.submitted {
    opacity: 0.5;
    border: 0px solid var(--button-color);
    pointer-events: none;
}

.image-item.submitted .remove-image {
    display: none;
}

/* ========== INPUT CONTROLS STYLES ========== */
.input-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 10px;
    /* padding: 10px 20px; */
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

/* Redesigned add-image-btn as a rectangular button */
.add-image-btn {
    background-color: var(--button-color);
    color: var(--light-text);
    border: none;
    border-radius: 2px;
    /* Changed to 2px */
    width: 36px;
    height: 36px;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    /* Ensure no padding affects centering */
    line-height: 1;
    /* Help with vertical centering */
}

.add-image-btn:hover {
    color: var(--button-text);
}

.add-image-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    color: var(--light-text);
}

.model-info {
    color: var(--model-text);
    font-weight: 400;
    /* font-style: italic; */
    font-size: 0.8rem;
    margin-right: 20px;
    margin-left: auto;
}

/* Submit button - keeping original styling */
.send-button {
    background-color: var(--button-color);
    color: var(--light-text);
    border: none;
    border-radius: 2px;
    /* Changed from 8px to 2px */
    padding: 10px 24px;
    font-size: 0.8rem;
    font-weight: 400;
    cursor: pointer;
    transition: color 0.3s ease;
}

.send-button:hover {
    color: var(--button-text);
}

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    color: var(--light-text);
}

/* ========== THINKING INDICATOR STYLES ========== */
.thinking-indicator {
    display: none;
    text-align: center;
    padding: 20px;
}

.thinking-indicator p {
    color: var(--thinking-text);
    font-family: 'Amiri', serif;
    -webkit-font-smoothing: antialiased;
    font-size: 1.4rem;
    font-weight: 400;
}

/* ========== RESPONSE CONTAINER STYLES ========== */
.response-container {
    display: none;
    flex-direction: column;
    gap: 20px;
    width: 75%;
    margin: 0 auto;
}

.response-complete {
    text-align: center;
    padding: 10px;
}

.response-complete p {
    color: var(--thinking-text);
    font-family: 'Amiri', serif;
    -webkit-font-smoothing: antialiased;
    font-size: 1.4rem;
    font-weight: 400;
}

.response-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.email-response,
.maple-reasoning {
    background-color: var(--panel-background);
    border-radius: 2px;
    /* This sets the 2px border radius */
    padding: 20px;
    min-height: 300px;
    overflow: hidden;
    /* Add this to contain the child elements */
}

/* Column headers (at the top of each panel) */
.email-response>h2,
.maple-reasoning>h2 {
    font-family: 'Amiri', serif;
    -webkit-font-smoothing: antialiased;
    font-weight: 600;
    font-style: normal;
    line-height: 1.0714285714;
    letter-spacing: -.6px;
    padding: 10px 20px;
    margin: -20px -20px 20px -20px;
    position: relative;
    border-bottom: 2px solid #C7C9C7;
    border-radius: 2px 2px 0 0;
    font-size: 1.5rem;
    color: var(--button-color);
}

/* Add specific styling for h2 elements within the content */
/* h2 elements within the content */
#reasoning-content h2 {
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    color: var(--button-color);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    padding-bottom: 0.5rem;
    background-color: transparent;
    padding: 0;
    margin: 1.5rem 0 0.75rem 0;
    border-radius: 0;
    font-size: 1.25rem;
    /* Slightly smaller than the column headers */
}

#email-content,
#reasoning-content {
    font-family: 'Nunito Sans', sans-serif;
    color: var(--primary-text);
    line-height: 1.6;
}

#reasoning-content p,
#email-content p {
    margin-bottom: 1.2em;
}

/* ========== CONTENT FORMATTING STYLES ========== */
#reasoning-content ul,
#reasoning-content ol {
    padding-left: 1.5rem;
    margin-left: 0.5rem;
}

#reasoning-content li {
    margin-bottom: 0.5rem;
}

#reasoning-content h2 {
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    color: var(--button-color);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    padding-bottom: 0.5rem;
}

#reasoning-content strong {
    color: var(--button-color);
    font-weight: 600;
}

/* ========== METRICS PANEL STYLES ========== */
.metrics-panel {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    font-family: 'Nunito Sans', sans-serif;
}

.metrics-panel h3 {
    font-family: 'Amiri', serif;
    font-size: 1.5rem;
    margin-bottom: 15px;
    color: var(--dark-text);
}

.metrics-panel h4 {
    font-family: 'Amiri', serif;
    font-size: 1.2rem;
    margin-top: 15px;
    color: var(--button-color);
}

#response-times,
#token-usage,
#cost-metrics {
    font-size: 0.9rem;
    color: var(--secondary-text);
    margin-bottom: 5px;
}

/* ========== ACTION BUTTONS STYLES ========== */
.action-buttons {
    display: flex;
    justify-content: flex-start;
    /* Align to the left */
    width: 75%;
    margin: 20px auto 0;
    gap: 0;
    /* Remove the gap */
}

.action-button {
    background-color: var(--button-hover-color);
    /* Yellow background */
    color: var(--button-hover-text);
    /* Green text */
    border: none;
    border-radius: 2px;
    padding: 12px 24px;
    font-size: 0.8rem;
    font-weight: 400;
    cursor: pointer;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.action-button:hover {
    background-color: var(--button-color);
    /* Green on hover */
    color: var(--button-text);
    /* Yellow text on hover */
}

/* Position the first button (Download CSV) at the left edge of the first column */
.action-buttons .action-button:first-child {
    margin-right: 0;
}

/* Position the second button (Start over) a specific distance from the first button */
.action-buttons .action-button:last-child {
    margin-left: 20px;
    /* Adjust this value to control the space between buttons */
}


/* Make sure the email response container uses flex layout */
.email-response {
    display: flex;
    flex-direction: column;
}

#email-content {
    flex-grow: 1;
}

/* ========== LINK STYLES ========== */
.morton-link {
    color: #006400;
    font-weight: 500;
    text-decoration: underline;
    position: relative;
    padding-right: 18px;
}

.morton-link::after {
    content: '↗';
    position: absolute;
    right: 0;
    top: 0;
    font-size: 0.8em;
}

.morton-link:hover {
    text-decoration: none;
    background-color: rgba(0, 100, 0, 0.05);
}

/* ========== RESPONSIVE DESIGN ========== */
@media (max-width: 768px) {
    .response-columns {
        grid-template-columns: 1fr;
    }

    .container {
        padding: 10px;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .input-container,
    .response-container {
        width: 100%;
    }
}

/* ========== COPY BUTTON ========== */
/* Copy button styling */
/* .copy-button-container {
    margin-top: 20px;
    margin-bottom: 20px;
    text-align: left;
}

.copy-button {
    background: none;
    border: none;
    color: var(--button-color);
    font-size: 0.9rem;
    cursor: pointer;
    padding: 5px 0;
    text-decoration: underline;
    font-family: 'Nunito Sans', sans-serif;
}

.copy-button:hover {
    color: var(--drag-area);
}

/* Accessibility improvements */
/* .copy-button:focus {
    outline: 2px solid var(--button-color);
    outline-offset: 2px;
}

/* Feedback message for copy operation */
/*.copy-feedback {
    display: inline-block;
    margin-left: 10px;
    color: var(--drag-area);
    font-size: 0.9rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.copy-feedback.visible {
    opacity: 1;
} */

.copy-button {
    background-color: var(--button-color);
    color: var(--light-text);
    border: none;
    border-radius: 2px;
    padding: 10px 24px;
    font-size: 0.8rem;
    font-weight: 400;
    cursor: pointer;
    transition: color 0.3s ease;
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.copy-button:hover {
    color: var(--button-text);
}

.copy-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    color: var(--light-text);
}

.copy-button-container {
    margin-top: 20px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
}

/* Ensure the copy feedback is properly styled */
.copy-feedback {
    display: inline-block;
    margin-left: 10px;
    color: var(--drag-area);
    font-size: 0.9rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.copy-feedback.visible {
    opacity: 1;
}

/* ========== ACCESSIBILITY BITS ========== */

/* Add skip link for keyboard navigation */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--button-color);
    color: var(--button-text);
    padding: 8px;
    z-index: 100;
    transition: top 0.3s;
}

.skip-link:focus {
    top: 0;
}

/* Add screen-reader-only class */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Improve focus styles for all interactive elements */
a:focus,
button:focus,
textarea:focus,
input:focus,
[tabindex]:focus {
    outline: 3px solid var(--button-text);
    outline-offset: 2px;
}

/* Ensure sufficient touch target sizes */
button,
.action-button,
.add-image-btn,
.send-button {
    min-height: 44px;
    min-width: 44px;
}

/* Improve color contrast where needed
.model-info {
    color: #103930;
    /* Ensure sufficient contrast against background (close comment here if block is uncommented)
    font-weight: 600;
    /* Make text more readable (close comment here if block is uncommented)
} */

.secondary-text {
    color: #555555;
    /* Darker for better contrast */
}

/* Ensure text can resize without breaking layout */
html {
    font-size: 100%;
}

body {
    font-size: 1rem;
    line-height: 1.5;
}

/* Improve visibility of error messages */
.error-message {
    background-color: #f8d7da;
    color: #721c24;
    padding: 10px 15px;
    margin: 10px 0;
    border: 1px solid #f5c6cb;
    border-radius: 2px;
    font-weight: 500;
}

/* Ensure form elements have visible focus states */
#user-input:focus {
    border: 2px solid var(--button-color);
    box-shadow: 0 0 0 2px rgba(16, 57, 48, 0.25);
}

/* Add non-color indicators for important states */
.image-item.submitted {
    opacity: 0.5;
    border: 2px solid var(--button-color);
    position: relative;
}

.image-item.submitted::after {
    content: "✓";
    position: absolute;
    top: 5px;
    right: 5px;
    background: var(--button-color);
    color: var(--light-text);
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Remove focus outline from query panel */
#user-input:focus {
    outline: none;
    box-shadow: none;
    border: none;
}

/* Remove focus outline from thinking indicator */
.thinking-indicator:focus,
.thinking-indicator p:focus,
.response-complete:focus {
    outline: none;
    box-shadow: none;
}

/* Remove yellow background from focused elements */
:focus {
    outline-color: transparent;
}

/* Maintain accessibility for keyboard users while hiding visual focus indicators */
.keyboard-user :focus {
    /* This will only show focus indicators for keyboard users */
    outline: 3px solid var(--button-text);
    outline-offset: 2px;
}