/* Reset box-sizing for everything */
*, *::before, *::after {
    box-sizing: border-box;
}

/* Base styles */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    min-height: 95vh;
    margin: 0;
    padding: 0;
    background-color: #f5f7fa;
    color: #333;
    box-sizing: border-box;
    overflow-x: hidden;
}

/* Container: centered app look */
.container {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    max-width: 800px;
    margin: 10px auto;
    height: 95vh; /*calc(100vh - 80px);   Subtract top + bottom margin */
    display: flex;
    flex-direction: column;
}

/* When running inside Tableau (iframe), use all available space */
body.in-extension .container {
    max-width: 100vw !important;
    width: 100vw !important;
    margin: 0 !important;
    border-radius: 0;
    height: 100vh;
    min-height: 0;
}

/* Chat box should flex and scroll as needed */
.chat-box {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    background: #fafbfc;
    min-height: 0;
}

/* Header styles */
header {
    background: #2c3e50;
    color: white;
    padding: 22px 24px;
    text-align: center;
}

header h1 {
    margin: 0 0 10px 0;
    font-size: 2em;
}

header p {
    margin: 0;
    opacity: 0.9;
}

.status-row {
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.status-chip {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.2px;
}

.status-connected {
    background: #d5f5e3;
    color: #145a32;
}

.status-standalone {
    background: #f4f6f7;
    color: #566573;
}

.debug-toggle {
    border: 1px solid #b5c0cb;
    background: #ffffff;
    color: #32404d;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    cursor: pointer;
}

.debug-toggle:hover {
    background: #f2f5f8;
}

.context-panel {
    padding: 12px 18px;
    border-bottom: 1px solid #e6eaef;
    background: #f7f9fc;
}

.context-panel.is-hidden {
    display: none;
}

.context-title {
    margin: 0 0 8px 0;
    font-size: 14px;
    color: #263238;
}

.context-line {
    font-size: 13px;
    color: #2f3b46;
    margin-bottom: 4px;
}

.context-label {
    font-weight: 600;
    color: #1d2730;
}

.context-subsection {
    margin-top: 8px;
}

.context-list {
    margin: 4px 0 0 0;
    padding: 6px 8px;
    max-height: 74px;
    overflow: auto;
    border: 1px solid #e1e8ef;
    border-radius: 6px;
    background: #ffffff;
    font-size: 12px;
    color: #34495e;
    white-space: pre-wrap;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* Chat message styles */
.message {
    margin: 15px 0;
    padding: 12px 16px;
    border-radius: 8px;
    max-width: 80%;
    line-height: 1.4;
    white-space: pre-wrap;
}

.message.user {
    background: #007bff;
    color: white;
    margin-left: auto;
    text-align: right;
}

.message.bot {
    background: #e9ecef;
    color: #495057;
}

/* Input area at the bottom */
.input-area {
    display: flex;
    gap: 10px;
    padding: 20px;
    background: white;
    border-top: 1px solid #dee2e6;
}

#messageInput {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    font-size: 16px;
    outline: none;
    transition: border-color 0.2s;
}

#messageInput:focus {
    border-color: #007bff;
}

#sendBtn {
    padding: 12px 24px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    transition: background-color 0.2s;
}

#sendBtn:hover {
    background: #0056b3;
}

#sendBtn:disabled {
    background: #6c757d;
    cursor: not-allowed;
}

/* Responsive for smaller screens */
@media (max-width: 600px) {
    .container {
        max-width: 100vw;
        width: 100vw;
        margin: 0;
        border-radius: 0;
        height: 100vh;
    }
    body {
        padding: 0;
    }
    header {
        padding: 20px;
    }
    header h1 {
        font-size: 1.5em;
    }
    .chat-box {
        padding: 15px;
    }
    .context-panel {
        padding: 12px;
    }
    .context-title {
        font-size: 13px;
    }
    .context-line {
        font-size: 12px;
    }
    .input-area {
        padding: 15px;
        flex-direction: column;
    }
    #sendBtn {
        padding: 12px;
    }
}
