/* ==========================================
   CHAT APPLICATION STYLES
   ========================================== */

/* Chat-specific sidebar styles */
.chat-new-btn-container {
    padding: 16px;
}

.chat-new-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chat-new-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.chat-new-icon {
    font-size: 18px;
    font-weight: bold;
}

/* Chat Lists */
.chat-lists {
    flex: 1;
    overflow-y: auto;
    padding: 0 12px;
}

.chat-list-section {
    margin-bottom: 24px;
}

.chat-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 8px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.chat-list-title {
    font-size: 12px;
    font-weight: 600;
    color: rgba(255,255,255,0.6);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.chat-list-count {
    background: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.8);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.chat-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.chat-list-empty {
    padding: 12px 8px;
    color: rgba(255,255,255,0.4);
    font-size: 13px;
    font-style: italic;
}

.chat-list-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    margin: 4px 0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    color: rgba(255,255,255,0.8);
}

.chat-list-item:hover {
    background: rgba(255,255,255,0.08);
}

.chat-list-item.active {
    background: rgba(102, 126, 234, 0.3);
    color: white;
}

.chat-item-icon {
    font-size: 16px;
    margin-right: 10px;
    opacity: 0.7;
}

.chat-item-content {
    flex: 1;
    min-width: 0;
}

.chat-item-title {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item-meta {
    font-size: 11px;
    color: rgba(255,255,255,0.4);
    margin-top: 2px;
}

.chat-item-shared-badge {
    background: rgba(102, 126, 234, 0.3);
    color: #a5b4fc;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    margin-left: 8px;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.back-to-dashboard {
    display: flex;
    align-items: center;
    gap: 8px;
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    font-size: 13px;
    padding: 10px 12px;
    border-radius: 8px;
    transition: all 0.15s ease;
}

.back-to-dashboard:hover {
    background: rgba(255,255,255,0.08);
    color: white;
}

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

/* ==========================================
   MAIN CHAT AREA
   ========================================== */
.chat-main {
    flex: 1;
    margin-left: 240px;
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: #f8fafc;
}

/* Chat Header */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: white;
    border-bottom: 1px solid #e2e8f0;
    min-height: 70px;
}

.chat-header-info {
    flex: 1;
}

#chatTitle {
    font-size: 18px;
    font-weight: 600;
    color: #1e293b;
    margin: 0;
}

.chat-header-sub {
    font-size: 13px;
    color: #64748b;
}

.chat-header-actions {
    display: flex;
    gap: 8px;
}

.chat-action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid #e2e8f0;
    background: white;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    color: #475569;
}

.chat-action-btn:hover {
    border-color: #667eea;
    color: #667eea;
    background: #f8fafc;
}

.chat-action-btn.shared {
    background: #eef2ff;
    border-color: #667eea;
    color: #667eea;
}

.chat-action-danger:hover {
    border-color: #ef4444;
    color: #ef4444;
    background: #fef2f2;
}

.action-icon {
    font-size: 14px;
}

/* ==========================================
   MESSAGES CONTAINER
   ========================================== */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Welcome State */
.chat-welcome {
    max-width: 600px;
    margin: auto;
    text-align: center;
    padding: 40px 20px;
}

.welcome-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.chat-welcome h2 {
    font-size: 24px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 8px;
}

.chat-welcome > p {
    color: #64748b;
    margin-bottom: 24px;
}

.welcome-features {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 32px;
}

.welcome-feature {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: white;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    text-align: left;
}

.feature-icon {
    font-size: 20px;
}

.feature-text {
    font-size: 13px;
    color: #475569;
    font-weight: 500;
}

.welcome-examples {
    text-align: left;
}

.examples-title {
    font-size: 14px;
    font-weight: 600;
    color: #475569;
    margin-bottom: 12px;
}

.example-btn {
    display: block;
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 8px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 13px;
    color: #475569;
    text-align: left;
    cursor: pointer;
    transition: all 0.15s ease;
}

.example-btn:hover {
    border-color: #667eea;
    color: #667eea;
    background: #f8fafc;
}

/* ==========================================
   MESSAGE BUBBLES
   ========================================== */
.message {
    display: flex;
    gap: 12px;
    max-width: 85%;
    animation: fadeIn 0.2s ease;
}

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

.message.user {
    margin-left: auto;
    flex-direction: row-reverse;
}

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

.message.user .message-avatar {
    background: #667eea;
    color: white;
}

.message.assistant .message-avatar {
    background: #1e293b;
    color: white;
}

.message-content {
    background: white;
    padding: 14px 18px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    line-height: 1.6;
}

.message.user .message-content {
    background: #667eea;
    color: white;
    border-bottom-right-radius: 4px;
}

.message.assistant .message-content {
    border-bottom-left-radius: 4px;
}

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

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

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

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

.message-content pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 12px 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 12px 0;
}

.message-content pre code {
    background: none;
    padding: 0;
    color: inherit;
}

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

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

.message-content strong {
    font-weight: 600;
}

.message-content a {
    color: #667eea;
    text-decoration: underline;
}

.message.user .message-content a {
    color: #c7d2fe;
}

/* Tool Calls Indicator */
.tool-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #fef3c7;
    border-radius: 6px;
    font-size: 12px;
    color: #92400e;
    margin-bottom: 8px;
}

.tool-indicator-icon {
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

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

.typing-dot {
    width: 8px;
    height: 8px;
    background: #94a3b8;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-6px); }
}

/* ==========================================
   INPUT AREA
   ========================================== */
.chat-input-container {
    padding: 16px 24px 24px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
}

.chat-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 8px 12px;
    transition: border-color 0.15s ease;
}

.chat-input-wrapper:focus-within {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.chat-input {
    flex: 1;
    border: none;
    outline: none;
    resize: none;
    font-size: 14px;
    line-height: 1.5;
    padding: 8px 4px;
    max-height: 150px;
    font-family: inherit;
}

.chat-input::placeholder {
    color: #94a3b8;
}

.chat-send-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: #667eea;
    color: white;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.chat-send-btn:hover:not(:disabled) {
    background: #5568d3;
    transform: scale(1.05);
}

.chat-send-btn:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
}

.chat-input-hint {
    text-align: center;
    font-size: 11px;
    color: #94a3b8;
    margin-top: 8px;
}

/* ==========================================
   RESPONSIVE DESIGN
   ========================================== */
@media (max-width: 1024px) {
    .chat-main {
        margin-left: 200px;
    }
    
    .welcome-features {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 60px;
    }
    
    .chat-new-text,
    .chat-list-title,
    .chat-list-count,
    .chat-item-content,
    .chat-item-shared-badge,
    .back-text {
        display: none;
    }
    
    .chat-new-btn {
        padding: 12px;
    }
    
    .chat-list-item {
        justify-content: center;
        padding: 12px;
    }
    
    .chat-item-icon {
        margin: 0;
        font-size: 20px;
    }
    
    .back-to-dashboard {
        justify-content: center;
    }
    
    .chat-main {
        margin-left: 60px;
    }
    
    .chat-messages {
        padding: 16px;
    }
    
    .message {
        max-width: 95%;
    }
    
    .chat-input-container {
        padding: 12px 16px 16px;
    }
}

/* ==========================================
   SCROLLBAR STYLING
   ========================================== */
.chat-messages::-webkit-scrollbar,
.chat-lists::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track,
.chat-lists::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.chat-lists::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.chat-lists::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.3);
}

/* ==========================================
   ERROR STATE
   ========================================== */
.message-error {
    background: #fef2f2 !important;
    border: 1px solid #fecaca;
    color: #dc2626;
}

.error-retry-btn {
    margin-top: 8px;
    padding: 6px 12px;
    background: #dc2626;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
}

.error-retry-btn:hover {
    background: #b91c1c;
}

/* ==========================================
   ACTION PROPOSAL CARDS
   ========================================== */
.action-proposal-card {
    max-width: 85%;
    margin: 12px 0;
    background: white;
    border: 2px solid #667eea;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.15);
    overflow: hidden;
    animation: fadeIn 0.3s ease;
}

.action-proposal-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 20px;
    background: linear-gradient(135deg, #eef2ff 0%, #f0f4ff 100%);
    border-bottom: 1px solid #e0e7ff;
}

.action-proposal-icon {
    font-size: 24px;
    line-height: 1;
    flex-shrink: 0;
    margin-top: 2px;
}

.action-proposal-title-group {
    flex: 1;
}

.action-proposal-title {
    font-size: 16px;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 4px;
}

.action-proposal-summary {
    font-size: 13px;
    color: #64748b;
    margin: 0;
    line-height: 1.4;
}

.action-proposal-warning {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: #fffbeb;
    border-bottom: 1px solid #fef3c7;
    font-size: 12px;
    color: #92400e;
}

.warning-icon {
    font-size: 14px;
    flex-shrink: 0;
}

.action-items-list {
    padding: 12px 20px;
}

.action-item {
    padding: 12px 14px;
    margin-bottom: 8px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    transition: all 0.15s ease;
}

.action-item:last-child {
    margin-bottom: 0;
}

.action-item:hover {
    border-color: #cbd5e1;
    background: #f1f5f9;
}

.action-item-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.action-item-icon {
    font-size: 16px;
}

.action-type-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.action-type-badge.move_deal_close_date {
    background: #dbeafe;
    color: #1d4ed8;
}

.action-type-badge.add_company_note {
    background: #dcfce7;
    color: #16a34a;
}

.action-type-badge.create_task {
    background: #fef3c7;
    color: #d97706;
}

.action-item-target {
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 4px;
}

.action-item-description {
    font-size: 13px;
    color: #64748b;
    line-height: 1.4;
}

.action-proposal-count {
    padding: 8px 20px;
    font-size: 12px;
    color: #94a3b8;
    border-top: 1px solid #e2e8f0;
    text-align: center;
}

.action-proposal-buttons {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
}

.action-btn-confirm {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.action-btn-confirm:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.4);
}

.action-btn-confirm:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.action-btn-cancel {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    background: white;
    color: #64748b;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.action-btn-cancel:hover:not(:disabled) {
    border-color: #ef4444;
    color: #ef4444;
    background: #fef2f2;
}

.action-btn-cancel:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

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

/* Action Cancelled State */
.action-cancelled {
    border-color: #e2e8f0;
    opacity: 0.7;
}

.action-cancelled-content {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    color: #94a3b8;
    font-size: 14px;
}

.cancelled-icon {
    font-size: 18px;
}

/* ==========================================
   ACTION RESULTS CARD
   ========================================== */
.action-results-card {
    max-width: 85%;
    margin: 12px 0;
    background: white;
    border: 2px solid #22c55e;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(34, 197, 94, 0.15);
    overflow: hidden;
    animation: fadeIn 0.3s ease;
}

.action-results-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    border-bottom: 1px solid #bbf7d0;
}

.results-icon {
    font-size: 20px;
}

.action-results-header h3 {
    flex: 1;
    font-size: 15px;
    font-weight: 700;
    color: #166534;
    margin: 0;
}

.results-count {
    font-size: 12px;
    color: #16a34a;
    font-weight: 600;
    background: white;
    padding: 3px 10px;
    border-radius: 10px;
}

.action-results-list {
    padding: 12px 20px;
}

.action-result-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    margin-bottom: 6px;
    border-radius: 6px;
}

.action-result-item:last-child {
    margin-bottom: 0;
}

.action-result-item.success {
    background: #f0fdf4;
}

.action-result-item.error {
    background: #fef2f2;
}

.result-icon {
    font-size: 16px;
    flex-shrink: 0;
    margin-top: 2px;
}

.result-detail {
    flex: 1;
}

.result-detail strong {
    display: block;
    font-size: 13px;
    color: #1e293b;
    margin-bottom: 2px;
}

.result-detail span {
    font-size: 12px;
    color: #64748b;
}

.action-result-item.error .result-detail span {
    color: #dc2626;
}

.action-results-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
}

.action-btn-undo {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: white;
    color: #d97706;
    border: 2px solid #fcd34d;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.action-btn-undo:hover {
    background: #fffbeb;
    border-color: #f59e0b;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.2);
}

.action-batch-id {
    font-size: 11px;
    color: #94a3b8;
    font-family: 'Monaco', 'Menlo', monospace;
}

/* Historical Proposal (loaded from past conversation) */
.action-historical {
    opacity: 0.75;
    border-color: #94a3b8;
}

.action-proposal-historical {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: #f1f5f9;
    border-top: 1px solid #e2e8f0;
    font-size: 13px;
    color: #64748b;
}

.historical-icon {
    font-size: 16px;
    flex-shrink: 0;
}
