/**
 * AI Excel Assistant - Chat Interface Styles
 * 
 * @package AIFreeTools
 * @since 1.0.0
 */

/* Chat Interface Container */
.excel-chat-interface {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    height: 80vh;
    max-height: 800px;
    display: flex;
    flex-direction: column;
    margin-top: 20px;
}

/* Split Layout Container */
.chat-split-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Left side - Chat */
.chat-left-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 400px;
}

/* Right side - Preview */
.chat-right-panel {
    width: 40%;
    min-width: 350px;
    max-width: 500px;
    border-left: 1px solid #dee2e6;
    display: flex;
    flex-direction: column;
    background: #f8f9fa;
}

/* Chat Header */
.chat-header {
    background: linear-gradient(135deg, #007cba 0%, #005a87 100%);
    color: #fff;
    padding: 15px 20px;
    border-radius: 8px 8px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.chat-icon {
    font-size: 32px;
}

.chat-title h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
}

.chat-subtitle {
    margin: 3px 0 0;
    font-size: 13px;
    opacity: 0.9;
}

.chat-header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.file-badge {
    background: rgba(255,255,255,0.2);
    padding: 6px 12px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.btn-close-chat {
    background: rgba(255,255,255,0.2);
    border: none;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease;
}

.btn-close-chat:hover {
    background: rgba(255,255,255,0.3);
}

/* Spreadsheet Preview */
.spreadsheet-preview {
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.preview-tabs {
    background: #e9ecef;
    padding: 8px 15px;
    display: flex;
    gap: 5px;
    border-bottom: 1px solid #dee2e6;
}

.sheet-tab {
    background: #fff;
    border: 1px solid #dee2e6;
    padding: 5px 15px;
    border-radius: 4px 4px 0 0;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.3s ease;
}

.sheet-tab:hover {
    background: #f8f9fa;
}

.sheet-tab.active {
    background: #007cba;
    color: #fff;
    border-color: #007cba;
}

.preview-content {
    padding: 10px;
    overflow: auto;
    flex: 1;
}

.sheet-preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.sheet-preview-table th {
    background: #e9ecef;
    padding: 5px 8px;
    text-align: left;
    font-weight: 600;
    border: 1px solid #dee2e6;
    position: sticky;
    top: 0;
}

.sheet-preview-table td {
    padding: 4px 8px;
    border: 1px solid #dee2e6;
    background: #fff;
}

.preview-note {
    margin: 10px 0 0;
    font-size: 11px;
    color: #6c757d;
    text-align: center;
}

/* Preview Controls */
.preview-controls {
    padding: 10px;
    text-align: center;
    background: #fff;
    border-top: 1px solid #dee2e6;
}

.btn-show-more-rows {
    background: #007cba;
    color: #fff;
    border: none;
    padding: 8px 20px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    margin-top: 10px;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.btn-show-more-rows:hover {
    background: #005a87;
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.15);
}

.btn-show-more-rows .icon {
    font-size: 10px;
    transition: transform 0.3s ease;
}

.btn-show-more-rows:hover .icon {
    transform: translateY(2px);
}

/* Preview wrapper for better scrolling */
.preview-wrapper {
    max-height: 100%;
    overflow: auto;
    display: flex;
    flex-direction: column;
}

/* Chat Messages Area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #fafafa;
}

.chat-message {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    animation: slideIn 0.3s ease;
}

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

.chat-message-user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.chat-message-user .message-avatar {
    background: #e7f3ff;
}

.chat-message-assistant .message-avatar {
    background: linear-gradient(135deg, #007cba 0%, #005a87 100%);
    color: #fff;
    box-shadow: 0 2px 5px rgba(0, 124, 186, 0.3);
}

.message-content {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
}

.chat-message-user .message-content {
    background: #007cba;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-message-assistant .message-content {
    background: #fff;
    border: 1px solid #dee2e6;
    border-bottom-left-radius: 4px;
}

/* Chat Welcome Message */
.chat-welcome h4 {
    color: #007cba;
    margin: 0 0 10px;
}

.chat-welcome ul {
    margin: 10px 0;
    padding-left: 20px;
}

.chat-welcome li {
    margin: 5px 0;
}

/* Formula Result in Chat */
.formula-result-chat {
    background: #e7f3ff;
    border: 1px solid #b3d9ff;
    border-radius: 6px;
    padding: 12px;
    margin: 10px 0;
}

.formula-result-chat h4 {
    margin: 0 0 8px;
    color: #004085;
    font-size: 14px;
}

.formula-result-chat .excel-formula {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 14px;
    color: #0066cc;
    display: block;
    margin: 8px 0;
    word-break: break-all;
}

.btn-copy-inline {
    background: #007cba;
    color: #fff;
    border: none;
    padding: 4px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.3s ease;
}

.btn-copy-inline:hover {
    background: #005a87;
}

/* Explanation in Chat */
.explanation-chat {
    margin-top: 10px;
}

.explanation-chat h4 {
    color: #333;
    font-size: 14px;
    margin: 15px 0 8px;
}

.explanation-chat ul {
    margin: 8px 0;
    padding-left: 20px;
}

.explanation-chat li {
    margin: 4px 0;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 8px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Chat Suggestions */
.chat-suggestions {
    padding: 12px 20px;
    background: #f8f9fa;
    border-top: 1px solid #dee2e6;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.suggestion-chip {
    background: #fff;
    border: 1px solid #dee2e6;
    color: #333;
    padding: 6px 14px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 5px;
}

.suggestion-chip:hover {
    background: #007cba;
    color: #fff !important;
    border-color: #007cba;
    transform: translateY(-2px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* Ensure emoji/img icons in suggestion chips work properly */
.suggestion-chip img.emoji {
    display: inline-block;
    width: 16px;
    height: 16px;
    vertical-align: middle;
}

/* Chat Input Area */
.chat-input-area {
    padding: 15px 20px;
    background: #fff;
    border-top: 1px solid #dee2e6;
    border-radius: 0 0 8px 8px;
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid #dee2e6;
    border-radius: 20px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    transition: border-color 0.3s ease;
    min-height: 40px;
    max-height: 100px;
}

.chat-input:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 0 2px rgba(0,124,186,0.1);
}

.btn-send-chat {
    background: linear-gradient(135deg, #007cba 0%, #005a87 100%);
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.3s ease;
}

.btn-send-chat:hover {
    background: linear-gradient(135deg, #005a87 0%, #004a6f 100%);
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

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

.send-icon {
    font-size: 16px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .excel-chat-interface {
        height: 90vh;
        margin: 10px;
    }
    
    .chat-header {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    .chat-header-right {
        width: 100%;
        justify-content: space-between;
    }
    
    .message-content {
        max-width: 85%;
    }
    
    .chat-suggestions {
        padding: 8px;
    }
    
    .suggestion-chip {
        font-size: 12px;
        padding: 5px 10px;
    }
    
    .spreadsheet-preview {
        max-height: 150px;
    }
}