/* Chat Panel Column Styles */
.chat-panel-column {
    width: 100%;
    background-color: var(--color-bg);
    border-left: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    position: relative;
}

/* Chat Panel Header */
.chat-panel-header {
    padding: calc(var(--spacing-unit) * 0.5) var(--spacing-unit);
    border-bottom: 1px solid var(--color-border);
    background-color: var(--color-bg-section);
    flex-shrink: 0;
    height: var(--standard-header-height, 35px); /* Match header height */
    display: flex;
    align-items: center;
    justify-content: space-between; /* Space between title and controls */
    box-sizing: border-box;
    gap: 12px; /* Add gap between elements */
}

.chat-panel-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text-main);
    flex: 1; /* Allow title to take remaining space */
}

/* Controls group in chat header */
.chat-panel-controls {
    display: flex;
    align-items: center;
    gap: 8px; /* Space between dropdown and button */
}

/* Mode selection dropdown in chat header */
.chat-panel-header .generation-mode-select {
    flex: 0 0 auto;
    min-width: 80px;
    padding: 4px 8px;
    font-size: 0.875rem;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    background-color: var(--color-bg);
    color: var(--color-text-main);
    cursor: pointer;
    transition: all 0.2s ease;
}

/* New chat button in header */
.new-chat-header-btn {
    flex: 0 0 auto;
    padding: 4px;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    background-color: var(--color-bg);
    color: var(--color-text-main);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.new-chat-header-btn:hover {
    border-color: var(--color-primary);
    background-color: var(--color-bg-hover, #f8f9fa);
}

.new-chat-header-btn svg {
    width: 16px;
    height: 16px;
}

.chat-panel-header .generation-mode-select:hover {
    border-color: var(--color-primary);
    background-color: var(--color-bg-hover, #f8f9fa);
}

.chat-panel-header .generation-mode-select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

/* Chat Messages Container */
.chat-messages-container {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-unit);
    padding-right: 4px; /* Minimal right padding to ensure scrollbar visibility */
    background-color: var(--color-bg);
    scroll-behavior: smooth;
    min-height: 0; /* Allow flexbox to shrink this */
    scrollbar-width: thin; /* Make scrollbar thin in Firefox */
    scrollbar-color: var(--color-text-secondary) var(--color-bg-section); /* thumb track */
}

.chat-messages-container::-webkit-scrollbar {
    width: 8px; /* Increased from 6px to make it more visible */
}

.chat-messages-container::-webkit-scrollbar-track {
    background: var(--color-bg-section);
    border-radius: 4px; /* Add slight rounding */
}

.chat-messages-container::-webkit-scrollbar-thumb {
    background: var(--color-text-secondary); /* More visible color */
    border-radius: 4px; /* Add slight rounding */
    opacity: 0.7;
}

.chat-messages-container::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-main); /* Darker on hover */
    opacity: 1;
}

/* Message Bubbles */
.message-bubble {
    margin-bottom: calc(var(--spacing-unit) * 1.5);
    padding: calc(var(--spacing-unit) * 0.75) var(--spacing-unit);
    border-radius: var(--border-radius);
    position: relative;
    max-width: 100%;
    word-wrap: break-word;
    animation: messageSlideIn 0.3s ease-out;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* User Messages */
.message-bubble.user-message {
    background-color: var(--color-primary);
    color: white;
    margin-left: auto;
    margin-right: 0;
    border-bottom-right-radius: 4px;
}

.message-bubble.user-message::before {
    content: '';
    position: absolute;
    bottom: 0;
    right: -8px;
    width: 0;
    height: 0;
    border: 8px solid transparent;
    border-bottom-color: var(--color-primary);
    border-right: none;
    border-bottom-right-radius: 4px;
}

/* AI Messages */
.message-bubble.ai-message {
    background-color: var(--color-bg-section);
    color: var(--color-text-main);
    border: 1px solid var(--color-border);
    margin-left: 0;
    margin-right: auto;
    border-bottom-left-radius: 4px;
}

.message-bubble.ai-message::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: -8px;
    width: 0;
    height: 0;
    border: 8px solid transparent;
    border-bottom-color: var(--color-bg-section);
    border-left: none;
    border-bottom-left-radius: 4px;
}

/* System Messages (Image Generation Events) */
.message-bubble.system-message {
    background-color: #f8f9fa;
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border);
    margin: 0 auto;
    text-align: center;
    font-style: italic;
    border-radius: var(--border-radius);
}

.message-bubble.system-message::before {
    display: none;
}

/* Message Content */
.message-content {
    font-size: 0.9rem;
    line-height: 1.4;
    margin: 0;
}

.message-content.user-content {
    font-weight: 500;
}

.message-content.ai-content {
    font-weight: 400;
}

/* Message Timestamp */
.message-timestamp {
    font-size: 0.75rem;
    opacity: 0.7;
    margin-top: calc(var(--spacing-unit) * 0.5);
    text-align: right;
}

.ai-message .message-timestamp {
    text-align: left;
}

.system-message .message-timestamp {
    text-align: center;
}

/* Image Generation Event Styling */
.image-generation-event {
    display: flex;
    align-items: center;
    gap: calc(var(--spacing-unit) * 0.75);
    padding: calc(var(--spacing-unit) * 0.75);
    background-color: var(--color-bg-section);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    margin-bottom: calc(var(--spacing-unit) * 1.5);
}

.image-generation-thumbnail {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    object-fit: cover;
    border: 1px solid var(--color-border);
    flex-shrink: 0;
}

.image-generation-details {
    flex: 1;
    min-width: 0;
}

.image-generation-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text-main);
    margin: 0 0 4px 0;
}

.image-generation-prompt {
    font-size: 0.75rem;
    color: var(--color-text-secondary);
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Empty State */
.chat-panel-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--color-text-secondary);
    text-align: center;
    padding: calc(var(--spacing-unit) * 2);
}

.chat-panel-empty-icon {
    font-size: 3rem;
    margin-bottom: var(--spacing-unit);
    opacity: 0.5;
}

.chat-panel-empty-message {
    font-size: 0.9rem;
    margin: 0;
}

/* Loading State */
.chat-panel-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--color-text-secondary);
}

.chat-panel-loading-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--color-border);
    border-top: 2px solid var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: var(--spacing-unit);
}

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

.chat-panel-loading-message {
    font-size: 0.9rem;
    margin: 0;
}

/* Chat Input Section */
.chat-input-section {
    flex-shrink: 0;
    border-top: 1px solid var(--color-border);
    background-color: black;
}

.chat-input-section .chat-status-bar {
    padding: calc(var(--spacing-unit) * 0.5) var(--spacing-unit);
    background-color: var(--color-bg-section);
    border-bottom: 1px solid var(--color-border);
    font-size: 0.85rem;
    min-height: 24px;
    display: flex;
    align-items: center;
}

.chat-input-section .chat-interface-content {
    padding: var(--spacing-unit) 0 0 0;
    width: 100%;
    margin-left: 0;
    box-sizing: border-box;
}

.chat-input-section .prompt-input-wrapper {
    padding: calc(var(--spacing-unit) * 0.25) 0;
    border-bottom: 1px solid var(--color-border-light);
    margin-bottom: calc(var(--spacing-unit) * 0.5);
}

.chat-input-section .prompt-input-div {
    width: 100%;
    min-height: 80px; /* Match chat images container height */
    max-height: 160px; /* Limit expansion to twice the initial size */
    padding: calc(var(--spacing-unit) * 0.5);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    background-color: var(--color-bg);
    color: var(--color-text-main);
    font-family: inherit;
    font-size: 0.9rem;
    line-height: 1.4;
    resize: vertical;
    overflow-y: auto; /* Enable scrolling when content exceeds max-height */
    box-sizing: border-box;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.chat-input-section .prompt-input-div:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(0, 105, 199, 0.2);
}

.chat-input-section .prompt-input-div:empty:before {
    content: attr(placeholder);
    color: var(--color-text-secondary);
    opacity: 0.7;
}

.chat-input-section .controls-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: calc(var(--spacing-unit) * 0.5);
    flex-wrap: wrap;
}

.chat-input-section .controls-left {
    display: flex;
    align-items: center;
    gap: calc(var(--spacing-unit) * 0.5);
    flex: 1;
    min-width: 0;
}

.chat-input-section .controls-right {
    display: flex;
    align-items: center;
    gap: calc(var(--spacing-unit) * 0.5);
    flex-shrink: 0;
}

.chat-input-section .icon-button {
    background: none;
    border: none;
    color: var(--color-text-secondary);
    font-size: 1.1rem;
    padding: calc(var(--spacing-unit) * 0.5);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: color 0.2s ease, background-color 0.2s ease;
}

.chat-input-section .icon-button:hover {
    color: var(--color-text-main);
    background-color: var(--color-bg-section);
}

.chat-input-section .generation-mode-select,
.chat-input-section .image-dimension-select,
.chat-input-section .style-select {
    padding: calc(var(--spacing-unit) * 0.25) calc(var(--spacing-unit) * 0.5);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    background-color: var(--color-bg);
    color: var(--color-text-main);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chat-input-section .generation-mode-select:hover,
.chat-input-section .image-dimension-select:hover,
.chat-input-section .style-select:hover {
    border-color: var(--color-primary);
}

.chat-input-section .generation-mode-select:focus,
.chat-input-section .image-dimension-select:focus,
.chat-input-section .style-select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(var(--color-primary-rgb, 0, 105, 199), 0.25);
}

.chat-input-section #generate-button {
    background-color: var(--color-primary);
    color: white;
    padding: calc(var(--spacing-unit) * 0.75);
    font-size: 1.2rem;
    border-radius: var(--border-radius);
}

.chat-input-section #generate-button:hover {
    background-color: var(--color-primary-hover, #0056b3);
}

.chat-input-section #image-previews {
    display: flex;
    gap: calc(var(--spacing-unit) * 0.25);
    align-items: center;
    overflow-x: auto;
    max-width: 150px;
    padding: calc(var(--spacing-unit) * 0.125) 0;
}

.chat-input-section #image-previews img {
    width: 16px;
    height: 16px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid var(--color-border);
    flex-shrink: 0;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .chat-panel-column {
        width: 30%;
    }
}

@media (max-width: 768px) {
    .chat-panel-column {
        width: 100%;
        position: relative; /* Changed from absolute for proper mobile layout */
        top: auto;
        right: auto;
        z-index: auto;
        background-color: var(--color-bg);
        border-left: none; /* Remove border on mobile */
        box-shadow: none; /* Remove shadow on mobile */
        height: 100%; /* Full height on mobile */
    }
    
    .message-bubble {
        max-width: 85%;
    }
    
    .chat-input-section .prompt-input-div {
        padding: calc(var(--spacing-unit) * 0.5) calc(var(--spacing-unit) * 0.75);
        min-height: 50px !important; /* Reduced height for mobile */
        max-height: 100px !important; /* Reduced max height */
    }
    
    .chat-input-section .prompt-input-div:empty:before {
        font-size: 0.85rem;
    }
    
    /* Remove the forced nowrap that was causing issues */
    .chat-input-section .controls-row {
        padding: 0 calc(var(--spacing-unit) * 0.25) !important; /* Reduced padding */
    }
    
    .chat-input-section .controls-left {
        margin-bottom: 0 !important;
    }
    
    .chat-input-section .controls-right {
        flex-shrink: 0 !important;
    }
    
    /* Ensure proper spacing for controls */
    .chat-input-section .generation-mode-select,
    .chat-input-section .image-dimension-select {
        height: 32px !important; /* Consistent height with new layout */
        padding: 4px 6px !important; /* Compact padding */
        font-size: 12px !important; /* Smaller font */
    }
    
    .chat-input-section #generate-button {
        height: 32px !important; /* Match other controls */
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 6px 10px !important; /* Compact padding */
        font-size: 16px !important; /* Maintain readable size for icon */
    }
    
    .chat-input-section .icon-button {
        min-width: 32px !important;
        min-height: 32px !important;
        padding: 6px !important;
        font-size: 14px !important;
    }
}

@media (max-width: 480px) {
    .message-bubble {
        max-width: 90%;
        padding: calc(var(--spacing-unit) * 0.5) calc(var(--spacing-unit) * 0.75);
    }
    
    .message-content {
        font-size: 0.85rem;
    }
    
    .message-timestamp {
        font-size: 0.7rem;
    }
    
    .image-generation-event {
        padding: calc(var(--spacing-unit) * 0.5);
    }
    
    .image-generation-thumbnail {
        width: 32px;
        height: 32px;
    }
    
    .image-generation-title {
        font-size: 0.8rem;
    }
    
    .image-generation-prompt {
        font-size: 0.7rem;
    }
    
    /* Consistent with new compact layout */
    .chat-input-section .prompt-input-div {
        padding: calc(var(--spacing-unit) * 0.5) calc(var(--spacing-unit) * 0.75);
        min-height: 45px !important; /* Even more compact on small screens */
        max-height: 90px !important; /* Further reduced */
    }
    
    .chat-input-section .prompt-input-div:empty:before {
        font-size: 0.8rem; /* Smaller placeholder text */
    }
    
    /* Further compact controls for very small screens */
    .chat-input-section .generation-mode-select,
    .chat-input-section .image-dimension-select {
        height: 30px !important;
        padding: 3px 4px !important;
        font-size: 11px !important;
    }
    
    #generation-mode-select {
        width: 50px !important; /* Even more compact */
    }
    
    #image-dimension-select {
        width: 70px !important; /* Even more compact */
    }
    
    .chat-input-section #generate-button {
        height: 30px !important;
        padding: 4px 8px !important;
        font-size: 14px !important;
        min-width: 45px !important;
    }
    
    .chat-input-section .icon-button {
        min-width: 30px !important;
        min-height: 30px !important;
        padding: 4px !important;
        font-size: 12px !important;
    }
} 