/* ChatPage Styles - Data Agent Chat */
.chat-page-container {
    display: flex;
    flex-direction: column;
    height: 90vh;
    height: 90dvh;
    max-width: 100%;
    margin: 0;
    padding: 0;
    gap: 0;
    width: 100%;
    overflow: hidden;
    position: relative;
}

/* Messages Area */
.messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 24px 20px 16px 20px;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    min-height: 0;
    width: 100%;
}

.messages-area.scrolling-to-bottom {
    scroll-behavior: auto;
}

.welcome-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 400px;
}

.welcome-card {
    max-width: 600px;
    background: var(--chat-primary-color, #667eea);
    border-radius: 24px;
}

.welcome-icon {
    font-size: 4rem;
    color: white;
}

.welcome-title {
    color: white;
    margin-bottom: 16px;
}

.welcome-subtitle {
    color: rgba(255, 255, 255, 0.9);
}

.welcome-suggestions-title {
    color: rgba(255, 255, 255, 0.8);
}

.suggestion-chip {
    background: rgba(255, 255, 255, 0.2) !important;
    color: white !important;
    cursor: pointer;
    border-radius: 20px;
}

.suggestion-chip:hover {
    background: rgba(255, 255, 255, 0.3) !important;
}

/* Messages Stack */
.messages-stack {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 8px;
}

.message-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    max-width: 70%;
    position: relative;
}

.message-row-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-row-bot {
    align-self: flex-start;
}

.message-avatar {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    margin-top: auto;
}

.message-content-wrapper {
    display: flex;
    flex-direction: column;
    max-width: 100%;
    gap: 4px;
}

.message-content-wrapper-user {
    align-items: flex-end;
}

.message-content-wrapper-bot {
    align-items: flex-start;
}

.message-actions-container {
    position: absolute;
    bottom: -36px;
    display: flex;
}

.message-actions-container-user {
    left: 52px;
}

.message-actions-container-bot {
    left: 52px;
}

.message-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.message-row:hover .message-actions {
    opacity: 1;
}

.action-btn {
    min-width: 28px;
    width: 28px;
    height: 28px;
    padding: 4px;
    color: #999;
}

.action-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--chat-primary-color, #667eea);
}

.message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 4px;
}

.message-user-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--chat-primary-color, #667eea);
}

.message-time {
    font-size: 0.75rem;
    color: #999;
}

.message-bubble {
    padding: 12px 16px;
    max-width: 100%;
    border-radius: 18px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.message-bubble-user {
    background: #f7f7f8;
    color: var(--chat-primary-color, #667eea);
    border-radius: 18px 18px 4px 18px;
}

.message-bubble-bot {
    background: #f7f7f8;
    color: var(--chat-primary-color, #667eea);
    border-radius: 18px 18px 18px 4px;
}

.message-content {
    margin-bottom: 0;
    font-size: 0.9rem;
    word-wrap: break-word;
    white-space: normal;
    line-height: 1.5;
}

.message-bubble-user .message-content {
    color: var(--chat-primary-color, #667eea);
}

.message-bubble-bot .message-content {
    color: var(--chat-primary-color, #667eea);
}

/* Markdown styles */
.message-content strong {
    font-weight: 700;
}

.message-content em {
    font-style: italic;
}

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

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

.message-content ul, .message-content ol {
    margin: 8px 0;
    padding-left: 24px;
}

.message-content li {
    margin-bottom: 4px;
}

.message-content code {
    background: rgba(0,0,0,0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9em;
}

.message-bubble-user .message-content code {
    background: rgba(255,255,255,0.2);
}

.message-content pre {
    background: rgba(0,0,0,0.05);
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 8px 0;
}

.message-content blockquote {
    border-left: 3px solid #667eea;
    padding-left: 12px;
    margin: 8px 0;
    color: #666;
}

/* Table styles */
.message-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 12px 0;
    font-size: 0.9rem;
}

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

.message-content th {
    background: rgba(102, 126, 234, 0.1);
    font-weight: 600;
}

.message-bubble-user .message-content table {
    border-color: rgba(255,255,255,0.3);
}

.message-bubble-user .message-content th {
    background: rgba(255,255,255,0.15);
}

.message-content tr:nth-child(even) {
    background: rgba(0,0,0,0.02);
}

.message-content tr:hover {
    background: rgba(0,0,0,0.05);
}

.message-timestamp {
    font-size: 0.7rem;
    margin-top: 6px;
    opacity: 0.7;
}

.message-bubble-user .message-timestamp {
    color: rgba(255, 255, 255, 0.8);
}

.message-bubble-bot .message-timestamp {
    color: #999;
}

.loading-bubble {
    background: #f5f5f5;
    padding: 16px 20px;
    border-radius: 24px 24px 24px 8px;
}

.loading-text {
    color: #666;
    font-style: italic;
    font-size: 0.85rem;
}

/* Input Row */
.input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    padding-bottom: max(12px, env(safe-area-inset-bottom, 12px));
    background: white;
    border-top: 1px solid #e0e0e0;
    flex-shrink: 0;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.05);
}

.chat-input-field {
    flex: 1;
    position: relative;
}

.chat-input-field .mud-input-outlined-border {
    border-radius: 30px !important;
}

.chat-input-field > div {
    background: #f5f5f5;
    border-radius: 30px !important;
}

.chat-textarea {
    width: 100%;
    padding: 12px 20px;
    font-size: 1rem;
    font-family: inherit;
    line-height: 1.6;
    border: none;
    outline: none;
    background: #f5f5f5;
    border-radius: 30px;
    resize: none;
    overflow-y: auto;
    box-sizing: border-box;
    vertical-align: middle;
    max-height: 240px;
    white-space: pre-wrap;
}

.chat-textarea:focus {
    background: #f0f0f0;
}

.chat-textarea:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.quick-prompts-menu {
    flex-shrink: 0;
}

.send-button {
    flex-shrink: 0;
}

.action-button {
    flex-shrink: 0;
}

/* Scrollbar Styling */
.messages-area {
    scrollbar-width: thin;
    scrollbar-color: #c1c1c1 transparent;
}

.messages-area::-webkit-scrollbar {
    width: 8px;
}

.messages-area::-webkit-scrollbar-track {
    background: transparent;
}

.messages-area::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.messages-area::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}
