:root {
    --google-blue: #1a73e8;
    --google-green: #34a853;
    /* Sens */
    --google-red: #ea4335;
    /* Res */
    --google-yellow: #fbbc04;
    --bg-color: #f8f9fa;
    --text-primary: #202124;
    --text-secondary: #5f6368;
    --border: #dadce0;
}

body {
    font-family: 'Roboto', 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    line-height: 1.5;
}

/* Header */
header {
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    font-size: 1.4rem;
    color: var(--text-primary);
    margin: 0;
}

.status {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Main Layout - Split Screen */
main {
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 1rem;
    display: grid;
    grid-template-columns: 40% 60%;
    gap: 1.5rem;
    align-items: start;
}

/* Left Panel - Scrolling Results */
.left-panel {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    max-height: 85vh;
    /* Keep it within view */
    overflow-y: auto;
    /* Scroll if content overflows */
}

/* Right Panel - Sticky Analysis */
.right-panel {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    position: sticky;
    top: 2rem;
    min-height: 600px;
    display: flex;
    flex-direction: column;
}

/* Cards */
.card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0;
    /* Removing padding from parent card to let header/body handle it */
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    /* For smooth corners */
    flex-shrink: 0;
}

.card-header {
    background: #f8f9fa;
    padding: 1rem 1.5rem;
    cursor: pointer;
    border-bottom: 1px solid transparent;
    /* Prepare for border */
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s;
}

.card-header:hover {
    background: #e8f0fe;
}

.card-header h3 {
    margin: 0;
    font-size: 1rem;
    color: var(--text-primary);
}

.card-body {
    padding: 1.5rem;
    border-top: 1px solid var(--border);
    display: block;
    /* Default open */
}

.arrow {
    font-size: 0.8rem;
    color: var(--text-secondary);
    transition: transform 0.3s ease;
    transform: rotate(0deg);
    /* Down arrow */
}

/* Fix table card flex behavior */
.table-card {
    display: flex;
    flex-direction: column;
}

.table-card .card-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    /* Remove padding for flush table */
    display: flex;
    /* Ensure wrapper fills height */
    flex-direction: column;
}

.table-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

/* Inputs */
.input-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

textarea {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: monospace;
    resize: vertical;
    transition: border 0.2s;
}

textarea:focus {
    outline: none;
    border-color: var(--google-blue);
    box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.2);
}

button.primary-btn {
    background-color: var(--google-blue);
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 4px;
    font-weight: 500;
    cursor: pointer;
    margin-top: 1rem;
    transition: background 0.2s;
    width: 100%;
}

button.primary-btn:hover {
    background-color: #1557b0;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

/* Tables */
.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

th {
    text-align: left;
    padding: 0.8rem;
    border-bottom: 2px solid var(--border);
    color: var(--text-secondary);
    font-weight: 500;
}

td {
    padding: 0.8rem;
    border-bottom: 1px solid var(--border);
}

tr:hover {
    background-color: #f1f3f4;
    cursor: pointer;
}

tr.selected {
    background-color: #e8f0fe;
    /* Light Blue */
}

/* Badges */
.badge {
    background: #e8f0fe;
    color: var(--google-blue);
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

/* Tabs */
.tabs {
    display: flex;
    border-bottom: 2px solid var(--border);
    margin-bottom: 1.5rem;
}

.tab-btn {
    flex: 1;
    background: none;
    border: none;
    padding: 1rem;
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-weight: 500;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: color 0.2s;
    text-align: center;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: #f8f9fa;
}

.tab-btn.active {
    color: var(--google-blue);
    border-bottom-color: var(--google-blue);
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
    flex: 1;
    overflow-y: auto;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Left Panel Tabs */
.left-tab-btn {
    border-bottom: none;
    border-right: 1px solid var(--border);
    flex: 1;
    text-align: center;
    padding: 0.8rem 0.5rem;
    font-size: 0.85rem;
    background: #f8f9fa;
    cursor: pointer;
    border-top: 3px solid transparent;
    /* Highlight top for these tabs if desired */
}

.left-tab-btn:last-child {
    border-right: none;
}

.left-tab-btn.active {
    background: #fff;
    color: var(--google-blue);
    font-weight: 500;
    border-bottom: 2px solid var(--google-blue);
    /* Visual indicator */
}

.left-tab-content {
    display: none;
    animation: fadeIn 0.2s ease;
    height: 100%;
    /* Important for internal scheduling */
    flex-direction: column;
}

.left-tab-content.active {
    display: flex;
    /* Flex to allow scrolling internal components */
}

/* Visualization Containers */
.plot-container {
    background: #fff;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
}

.plot-image {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}

.note {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: -0.5rem;
    margin-bottom: 1rem;
}


/* Chat Differentiation */
.chat-message {
    padding: 0.8rem 1rem;
    margin-bottom: 0.5rem;
    border-radius: 8px;
    max-width: 85%;
    font-size: 0.9rem;
    line-height: 1.4;
}

.chat-message.user {
    background-color: #e8f0fe;
    /* Light Blue */
    color: var(--text-primary);
    margin-left: auto;
    /* Right align */
    border-top-right-radius: 0;
}

.chat-message.assistant {
    background-color: #f1f3f4;
    /* Gray */
    color: var(--text-primary);
    margin-right: auto;
    /* Left align */
    border-top-left-radius: 0;
}

/* Chat Controls */
.chat-controls {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.secondary-btn {
    background-color: #fff;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.secondary-btn:hover {
    background-color: #f8f9fa;
    color: var(--text-primary);
    border-color: #ccc;
}