@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

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

body {
    font-family: 'Titillium Web', sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f9f9f9;
    margin: 0;
    padding: 0;
    height: 100vh;
    overflow: hidden;
}

/* Base container */
#app-container {
    position: relative;
    height: 100vh;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
}

/* Nav styling */
nav {
    height: 50px;
    background-color: #0066cc;
    width: 100%;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
}

/* Welcome screen */
.welcome-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0 2rem;
    text-align: center;
    max-width: 800px;
    margin: 0 auto;
    box-sizing: border-box;
    height: auto;
    min-height: 400px;
    position: relative;
    z-index: 2;
}

/* Logo container styling */
.logo-container {
    position: fixed !important;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    background-color: #e6f0ff !important;
    padding: 15px !important;
    z-index: 1;
    height: 70px;
}

/* Adjust the app container to provide proper spacing */
#app-container.mobile-friendly {
    margin-top: 0 !important;
    padding-bottom: 70px;
    height: calc(100vh - 50px - 70px);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Welcome screen container - the direct parent */
#welcome-screen {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    padding-bottom: 70px;
}

/* Add styling to create better spacing between elements */
#welcome-screen > h1 {
    margin-bottom: 2rem;
}

#welcome-screen > p {
    margin-bottom: 2rem;
}

#welcome-screen > textarea {
    margin-bottom: 1.5rem;
}

/* Make sure the bottom UN panel is positioned correctly */
.un-footer {
    margin-top: auto;
    padding-top: 1rem;
}

.welcome-title {
    font-size: 2.8rem;
    color: #0066cc;
    font-weight: 700;
    line-height: 1.2;
    margin: 0 0 2rem 0;
}

.welcome-subtitle {
    margin-bottom: 1.5rem;
    color: #555;
    font-size: 1.2rem;
    font-weight: 500;
}

.welcome-input-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 600px;
}

#initial-input {
    width: 100%;
    min-height: 120px;
    padding: 1.25rem;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1.1rem;
    resize: vertical;
    margin-bottom: 1.5rem;
    transition: border-color 0.3s;
    font-family: 'Titillium Web', sans-serif;
}

#initial-input:focus {
    outline: none;
    border-color: #0066cc;
}

.welcome-submit-btn {
    background-color: #0066cc;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 0.75rem 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
    align-self: flex-end;
}

.welcome-submit-btn:hover {
    background-color: #0055aa;
}

/* Chat area */
.chat-column {
    height: 100%;
    overflow-y: hidden;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.chat-container {
    height: 100%;
    overflow-y: auto;
    padding: 15px;
    width: 100%;
    box-sizing: border-box;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

#chat-history {
    max-width: 750px;
    margin: 0 auto;
    position: relative;
    text-align: left;
}

/* Input panel container - for both mobile and desktop */
.input-column {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid #ddd;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 100;
    padding: 16px 0;
    height: 92px; /* Updated: set exact height instead of auto */
    min-height: 92px;
}

.input-column-content {
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
}

#user-input {
    flex: 1;
    height: 60px;
    min-height: 60px;
    padding: 16px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    resize: none;
    margin: 0;
    line-height: 1.4;
    cursor: text !important; /* Always show text cursor */
}

#user-input:disabled {
    background-color: #f5f5f5;
    opacity: 0.8;
}

#submit-btn {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    background-color: #0066cc;
    color: white;
    border: none;
    transition: background-color 0.3s ease;
    cursor: pointer; /* Show pointer by default */
}

#submit-btn:disabled {
    background-color: #cccccc;
    cursor: not-allowed; /* Only show not-allowed on disabled button */
}

.amazon-btn {
    height: 36px;
    width: 36px;
    padding: 8px;
    background-color: #0066cc;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Chat interface */
.chat-interface {
    display: block;
    height: 100vh;
    padding-bottom: 92px;
}

/* Message styling */
.message {
    margin: 0.75rem 0;
    clear: both;
    max-width: 85%;
}

.message.user {
    float: right;
    background-color: #0066cc;
    color: white;
    border-radius: 18px 18px 0 18px;
    padding: 12px 16px;
    margin-left: 15%;
}

.message.assistant {
    float: left;
    background-color: #e6f3ff;
    border-radius: 18px 18px 18px 0;
    padding: 12px 16px;
    margin-right: 15%;
}

.message.system {
    text-align: center;
    font-style: italic;
    color: #777;
    padding: 8px;
    margin: 1rem auto;
    max-width: 80%;
}

/* Intervention modified styling - single definition */
.intervention-modified {
    clear: both;
    margin: 1.5rem 0;
    padding: 1rem 1.5rem;
    background-color: #f8f9fa;
    position: relative;
}

.intervention-modified::before {
    content: '';
    position: absolute;
    left: 0;
    top: 1rem;
    height: calc(100% - 2rem);
    width: 3px;
    background-color: #666;
}

.intervention-modified strong {
    display: block;
    margin-bottom: 0.75rem;
    color: #333;
}

.intervention-modified ul {
    list-style-type: disc;
    padding-left: 1.5rem;
    margin: 0;
}

.intervention-modified li {
    font-style: italic;
    margin-bottom: 0.5rem;
}

.intervention-modified li:last-child {
    margin-bottom: 0;
}

/* Summary styling - update existing styles */
.summary {
    margin: 15px 0;
    padding: 15px;
    background-color: #f0f7ff;
    border-left: 3px solid #0066cc;
}

.summary p {
    margin: 0 0 10px 0; /* Reduce bottom margin from default */
    line-height: 1.5; /* Slightly tighter line height */
}

.summary p:last-child {
    margin-bottom: 0; /* No margin on last paragraph */
}

/* Remove any extra vertical spacing that might be added */
.summary br {
    display: none; /* Hide extra line breaks */
}

/* Bold the summary title */
.summary p:first-child,
.summary h1:first-child,
.summary h2:first-child,
.summary h3:first-child {
    font-weight: bold;
    margin-top: 0;
}

/* Ensure consistent spacing */
.summary p:first-child {
    margin-top: 0;
}

.summary p:last-child {
    margin-bottom: 0;
}

/* Add new styles for summary content formatting */
.summary h2 {
    font-size: 1.3rem;
    color: #333;
    margin-bottom: 1.5rem;
}

.summary h3 {
    font-size: 1.1rem;
    color: #444;
    margin: 1.25rem 0 0.75rem 0;
}

/* Numbered list styling */
.summary ol {
    counter-reset: item;
    padding-left: 0;
    margin: 1rem 0;
}

.summary ol > li {
    display: block;
    margin-bottom: 1rem;
    padding-left: 2rem;
    position: relative;
}

.summary ol > li:before {
    content: counter(item) ".";
    counter-increment: item;
    position: absolute;
    left: 0;
    color: #0066cc;
    font-weight: bold;
}

/* Nested list styling */
.summary ol ol {
    margin: 0.5rem 0;
}

.summary ol ol > li {
    padding-left: 2.5rem;
}

.summary ol ol > li:before {
    content: counter(item, lower-alpha) ".";
}

/* Section spacing */
.summary section {
    margin-bottom: 1.5rem;
}

.summary section:last-child {
    margin-bottom: 0;
}

/* Key points and subsections */
.summary strong {
    color: #333;
}

/* Spacing between major sections */
.message + .intervention-modified {
    margin-top: 2rem;
}

.intervention-modified + .summary {
    margin-top: 2.5rem;
}

.timer {
    display: none;
}

/* Download button */
#download-btn {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 50%;
    width: 3rem;
    height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    z-index: 10;
}

/* Remove ALL previous mobile-specific styles */

/* Then add this single, comprehensive mobile media query at the end of the file */
@media (max-width: 768px) {
    .input-column {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: auto;
        min-height: 100px; /* Match desktop */
        padding: 20px;
        background: white;
        border-top: 1px solid #ddd;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
        z-index: 100;
    }

    .input-column-content {
        display: flex;
        flex-direction: row;
        align-items: flex-start;
        gap: 12px;
        height: 100%;
        padding: 0;
    }

    #user-input {
        flex: 1;
        height: 60px; /* Match desktop */
        min-height: 60px;
        padding: 16px;
        border: 1px solid #ddd;
        border-radius: 8px;
        font-size: 14px;
        resize: none;
        overflow-y: auto;
        margin: 0;
    }

    #submit-btn {
        width: 60px;
        height: 60px;
        border-radius: 8px;
    }

    /* Adjust other elements for shorter input panel */
    .chat-column {
        margin-top: 0; /* Remove the 50px margin */
        height: calc(100vh - 50px - 92px); /* Adjust height calculation */
    }
    
    .welcome-container {
        justify-content: flex-start;
        height: auto;
        padding-bottom: 80px;
    }

    .chat-controls {
        bottom: 120px;
    }

    .chat-container {
        padding-bottom: 100px;
    }

    /* Fix for white space and scrolling issues on mobile */
    .welcome-container {
        justify-content: flex-start;
    }
    
    /* Fix the navbar-related spacing issue */
    #app-container.mobile-friendly {
        justify-content: flex-start;
    }

    #welcome-screen {
        justify-content: flex-start;
    }
}

/* Remove any top margin from the first element inside welcome-container */
.welcome-container > * {
    margin-top: 0;
}

/* Table styles */
.ai-response table {
    border-collapse: collapse;
    width: 100%;
    margin-bottom: 1em;
    font-size: 0.9em;
    border: 1px solid #ddd;
}

.ai-response th, .ai-response td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
}

.ai-response th {
    background-color: #f2f2f2;
    font-weight: bold;
}

.ai-response tr:nth-child(even) {
    background-color: #f9f9f9;
}

.ai-response tr:hover {
    background-color: #f5f5f5;
}

/* Responsive table */
@media screen and (max-width: 600px) {
    .ai-response table, .ai-response thead, .ai-response tbody, .ai-response th, .ai-response td, .ai-response tr {
        display: block;
    }

    .ai-response thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    .ai-response tr {
        border: 1px solid #ccc;
        margin-bottom: 0.5em;
    }

    .ai-response td {
        border: none;
        border-bottom: 1px solid #eee;
        position: relative;
        padding-left: 50%;
    }

    .ai-response td:before {
        content: attr(data-label);
        position: absolute;
        left: 6px;
        width: 45%;
        padding-right: 10px;
        white-space: nowrap;
        font-weight: bold;
    }
}

.error-message {
    color: #ff4d4d;
    font-weight: bold;
    margin-top: 10px;
    font-family: 'ao_mono', monospace;
}

/* Add styles for zoom controls */
.zoom-controls {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1000;
}

.zoom-btn {
    background-color: #0066cc;
    color: white;
    border: none;
    padding: 5px 10px;
    margin: 0 2px;
    cursor: pointer;
    border-radius: 3px;
}

/* Update message loading styles */
.message-loading {
    padding: 12px 16px;
    background-color: #f0f2f5;
    border-radius: 18px;
    width: fit-content;
    max-width: 60%;
    margin: 8px 0;
    height: 40px; /* Fixed height */
    display: flex;
    align-items: center;
}

/* Facebook-style typing indicator */
.typing-indicator {
    background-color: #f1f0f0;
    padding: 15px 20px;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    width: auto;
    margin: 15px 0;
}

.typing-dot {
    height: 8px;
    width: 8px;
    margin: 0 3px;
    background-color: #90949c;
    border-radius: 50%;
    display: inline-block;
    animation: typing-dot-bounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) {
    animation-delay: 0s;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing-dot-bounce {
    0%, 80%, 100% { 
        transform: translateY(0);
    }
    40% { 
        transform: translateY(-8px);
    }
}

/* Hide old shimmer effect (keeping it for backward compatibility) */
.shimmer-effect {
    display: none;
}

#app-container {
    position: relative;
    margin-top: 50px; /* Reduce from 105px to match nav height */
}

.chat-column, .flowchart-column {
    position: relative;
    z-index: 2;
}

#download-btn {
    position: absolute;
    z-index: 3;
}
.menu-toggle {
    position: fixed;
    top: 20px;
    left: 10px;
    font-size: 24px;
    color: white;
    cursor: pointer;
    z-index: 1001;
}

nav {
    position: relative;
    width: 100%;
}

.nav-logo {
    display: none;
}

nav a {
    color: white;
    padding: 10px 15px;
    text-decoration: none;
    display: inline-block;
    font-family: 'ao_mono', monospace;
}

nav a:hover {
    background-color: rgba(255, 255, 255, 0.2);  /* A more subtle hover effect that matches the design */
    color: white;
}

#app-container {
    position: relative;
    margin-top: 20px;
}

/* Update intro line styling */
.intro-line {
    margin: 1.5rem 0;
    text-align: left;
    color: #555;
    font-size: 1.1rem;
    font-style: italic;
    padding: 0 1rem;
    display: block;
    clear: both;
}

/* Stakeholder styling */
.stakeholder-name {
    font-weight: 700;
    margin-bottom: 0.75rem;
    color: #0066cc;
    font-size: 1.1rem;
}

.stakeholder-content {
    line-height: 1.6;
    max-width: 100%;
}

.stakeholder-content p {
    margin-bottom: 0.75rem;
}

/* Limit the number of paragraphs shown */
.stakeholder-content p:nth-child(n+3) {
    display: none; /* Hide paragraphs beyond the second one */
}

/* Ensure proper spacing for financial implications and capital contributed */
.financial-implications,
.capital-contributed {
    margin-top: 1rem;
    margin-bottom: 1rem;
}

/* Adjust spacing between sections */
.message + .intervention-modified,
.intervention-modified + .summary {
    margin-top: 1.5rem;
}

/* Message content styling */
.message-content {
    word-wrap: break-word;
}

/* Stakeholder count styling */
.stakeholder-count {
    font-size: 0.85rem;
    font-weight: normal;
    color: #666;
    margin-left: 0.5rem;
}

/* Disabled input styles */
textarea.disabled {
    background-color: #f5f5f5;
    cursor: not-allowed;
    opacity: 0.7;
}

/* Email overlay */
.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.overlay-content {
    background: white;
    padding: 24px;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.overlay-content h2 {
    margin-top: 0;
    margin-bottom: 16px;
}

.overlay-content input {
    width: 100%;
    padding: 8px;
    margin: 16px 0;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.overlay-buttons {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 16px;
}

.overlay-buttons button {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

#send-email-btn {
    background-color: #0066cc;
    color: white;
}

#cancel-email-btn {
    background-color: #ddd;
}

.input-panel {
    display: none;
}

/* Update progress bar styles */
.progress-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: transparent;
    z-index: 101; /* Above the nav but below dropdowns */
}

/* Ensure no margin on chat history */
#chat-history {
    margin: 0; /* Remove any margin */
    padding: 0; /* Remove any padding */
}

/* Fix numbered list styling */
.message-content ol {
    margin: 0;
    padding-left: 24px; /* Add proper padding for numbers */
}

.message-content ol li {
    margin-bottom: 8px; /* Add spacing between list items */
}

/* Remove extra space before lists */
.message-content > ol:first-child {
    margin-top: 0;
}

/* Ensure proper text wrapping in messages */
.message-content p {
    margin: 0 0 8px 0;
}

.message-content p:last-child {
    margin-bottom: 0;
}

/* Email overlay styles */
.email-response {
    margin-top: 15px;
    padding: 10px;
    border-radius: 4px;
    display: none;
    font-size: 14px;
    color: #333; /* Changed from red to dark gray */
}

.email-response.error {
    background-color: #fff8f8;
    border: 1px solid #ffebeb;
    color: #333; /* Changed from red to dark gray */
}

.email-response.success {
    background-color: #f0fff0;
    border: 1px solid #e0f8e0;
    color: #333; /* Consistent color */
}

.email-response pre {
    margin-top: 8px;
    padding: 8px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
    overflow-x: auto;
    font-size: 12px;
}

.shimmer-line {
    height: 15px;
    background: #f6f7f8;
    background-image: linear-gradient(
        to right,
        #f6f7f8 0%,
        #edeef1 20%,
        #f6f7f8 40%,
        #f6f7f8 100%
    );
    background-repeat: no-repeat;
    background-size: 800px 104px;
    margin-bottom: 12px;
    border-radius: 4px;
    animation: shimmer 1.5s infinite linear;
}

@keyframes shimmer {
    0% {
        background-position: -468px 0;
    }
    100% {
        background-position: 468px 0;
    }
}

/* Remove old shimmer styles that we don't need anymore */
.typing-dots, .typing-dots::after {
    display: none;
}

/* Remove the status-bar styles and update the controls positioning */
.chat-controls {
    position: fixed;
    bottom: calc(92px + 16px); /* input panel height + gap */
    right: calc((100% - 800px) / 2 + 24px); /* Align with input panel content */
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 100;
}

/* Update loading indicator styles */
.loading-indicator {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: -24px;
    width: 28px; /* Set explicit width */
    height: 28px; /* Set explicit height */
}

.loading-circle {
    width: 27px;
    height: 27px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #0066cc;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    position: absolute;
    top: 0; /* Explicitly position */
    left: 0; /* Explicitly position */
}

.loading-count {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #0066cc;
    background: white;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    animation: none !important;
    transform: none !important;
    z-index: 2;
    top: 4px; /* Center within the circle */
    left: 4px; /* Center within the circle */
}

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

/* Email button styling */
.email-button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #0066cc;
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.email-button:hover {
    background: #0052a3;
}

.email-button i {
    font-size: 14px;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .chat-controls {
        right: 28px; /* Simple right margin on mobile */
    }
}

/* First, find and remove ALL previous loading-count styles throughout the file */

/* Then at the very end of the file, add this with higher specificity to ensure it overrides any other styles */
.chat-controls .loading-count {
    position: absolute;
    top: 25%;
    left: 25%;
    width: 12px;
    height: 12px;
    background: white;
    border-radius: 50%;
    color: #0066cc;
    font-size: 12px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    padding: 2px;
    /* Ensure no transforms or animations affect the positioning */
    transform: none !important;
    animation: none !important;
}

/* Add new styles for mobile-friendly layout */
#app-container.mobile-friendly {
    margin-top: 0 !important;
}

/* Also ensure the messages don't stretch too wide */
.user-message, .ai-response, .assistant-message, .intro-line, .summary, .intervention-modified {
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
}
