:root {
    --primary-color: #000000;
    --bg-color: #ffffff;
    --text-primary: #333333;
    --text-secondary: #666666;
    --border-color: #e5e7eb;
    --input-bg: #ffffff;
    --avatar-bg: #000000;
}

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

.hidden {
    display: none !important;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Prevent body scroll to fix layout */
}

/* Header Styles */
.app-header {
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.dropdown select {
    appearance: none;
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 14px;
    background: white;
    padding-right: 30px;
    cursor: pointer;
    font-weight: 500;
}

.dropdown {
    position: relative;
}

.dropdown i {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    font-size: 10px;
}

#provider-select {
    border-color: #ff980033;
    padding-left: 32px;
}

.dropdown .fa-robot {
    left: 12px;
    right: auto;
    font-size: 14px;
    color: #ff9800;
}

.user-avatar {
    width: 32px;
    height: 32px;
    background: var(--avatar-bg);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
}

/* Main Chat Area */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 20px;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
    overflow: hidden;
    /* Container doesn't scroll, child window does */
}

.initial-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.initial-view h2 {
    font-size: 24px;
    font-weight: 400;
    margin-bottom: 40px;
    color: #1a1a1a;
}

.chat-window {
    width: 100%;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 20px 0;
    scrollbar-width: thin;
    scrollbar-color: #e5e7eb transparent;
}

/* Custom Scrollbar for Chrome/Safari */
.chat-window::-webkit-scrollbar {
    width: 6px;
}

.chat-window::-webkit-scrollbar-track {
    background: transparent;
}

.chat-window::-webkit-scrollbar-thumb {
    background-color: #e5e7eb;
    border-radius: 20px;
}

.chat-window::-webkit-scrollbar-thumb:hover {
    background-color: #d1d5db;
}

.chat-window.hidden {
    display: none;
}

/* Input Area */
.input-wrapper {
    width: 100%;
    max-width: 850px;
    padding: 10px 0 20px 0;
    background: var(--bg-color);
    z-index: 10;
}

.chat-input-box {
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    background: white;
}

#user-input {
    width: 100%;
    border: none;
    outline: none;
    resize: none;
    font-size: 16px;
    color: #333;
    min-height: 40px;
    font-family: inherit;
}

.input-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    margin-top: 4px;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 18px;
    transition: color 0.2s;
}

.icon-btn:hover {
    color: var(--primary-color);
}

.send-btn {
    background: black;
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s;
}

.send-btn:hover {
    transform: scale(1.1);
}

/* Messages */
.message {
    max-width: 80%;
    padding: 10px 16px;
    border-radius: 12px;
    font-size: 15px;
    line-height: 1.5;
}

.message.user {
    align-self: flex-end;
    background-color: #f3f4f6;
    color: #1a1a1a;
}

.message.ai {
    align-self: flex-start;
    background-color: transparent;
    color: #1a1a1a;
    padding-left: 0;
}

.logs-container {
    margin-bottom: -10px;
    /* Bring logs closer to the answer */
    padding-top: 0;
    padding-bottom: 0;
}

.log-message {
    font-size: 13px;
    color: var(--text-secondary);
    font-style: italic;
    opacity: 0.8;
    margin-bottom: -10px;
}

/* Loading Dots */
.loading-dots {
    display: flex;
    gap: 4px;
}

.dot {
    width: 4px;
    height: 4px;
    background: #ccc;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

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

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

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

.ms-2 {
    margin-left: 0.5rem;
}

.ms-3 {
    margin-left: 1rem;
}

/* Markdown Styling */
.message-content h1,
.message-content h2,
.message-content h3 {
    margin: 16px 0 8px 0;
    font-weight: 600;
}

.message-content h3 {
    font-size: 1.1rem;
}

.message-content h4 {
    font-size: 1rem;
    margin-top: 12px;
}

.message-content p {
    margin-bottom: 8px;
}

.message-content ul,
.message-content ol {
    margin-left: 20px;
    margin-bottom: 12px;
}

.message-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.message-content th,
.message-content td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.message-content th {
    background-color: #f9fafb;
    font-weight: 600;
    color: var(--text-primary);
}

.message-content tr:last-child td {
    border-bottom: none;
}

.message-content hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 16px 0;
}

.message-content blockquote {
    border-left: 4px solid var(--border-color);
    padding-left: 12px;
    color: var(--text-secondary);
    font-style: italic;
    margin: 12px 0;
}

/* Collapsible Logs Styling */
.logs-details {
    margin: 10px 0;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    background: #f9fafb;
    max-width: fit-content;
}

.logs-details summary {
    padding: 8px 16px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    list-style: none;
    user-select: none;
}

.logs-details summary::-webkit-details-marker {
    display: none;
}

.logs-details summary i {
    font-size: 10px;
    transition: transform 0.2s ease;
}

.logs-details[open] summary i {
    transform: rotate(180deg);
}

.logs-list {
    padding: 0 16px 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.log-item {
    font-size: 13px;
    color: var(--text-secondary);
    font-style: italic;
}

.analysis-time {
    background-color: #ff9800;
    color: white;
    border-radius: 12px;
    padding: 2px 8px;
    margin-left: 10px;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 500;
}

/* Timing Breakdown Styles */
.timing-breakdown {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.timing-header {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.timing-header i {
    color: #ff9800;
}

.agent-timing {
    margin-bottom: 16px;
    padding: 10px;
    background: white;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
}

.agent-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid #f3f4f6;
}

.timing-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.timing-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    padding: 4px 0;
}

.timing-label {
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
}

.timing-value {
    font-weight: 600;
    color: var(--text-primary);
    font-family: 'Courier New', monospace;
}

.timing-total {
    margin-top: 4px;
    padding-top: 6px;
    border-top: 1px solid #f3f4f6;
    font-weight: 600;
}

.timing-total .timing-label {
    color: var(--text-primary);
}

.timing-total .timing-value {
    color: #ff9800;
    font-size: 13px;
}