/**
 * AI Summary Popup Styles
 */

/* AI Summary Button on Lead Cards */
.lead-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.lead-card-header h3 {
    flex: 1;
    min-width: 0;
}

.ai-summary-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    border-radius: var(--radius-md, 8px);
    background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    margin-left: auto;
}

.ai-summary-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.ai-summary-btn:active {
    transform: scale(0.95);
}

.ai-summary-btn svg {
    width: 16px;
    height: 16px;
}

/* Popup Overlay */
.ai-summary-popup {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(2px);
    z-index: 9999;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 20px;
}

.ai-summary-popup.show {
    display: flex;
}

/* Popup Content */
.ai-summary-content {
    background: var(--bg-primary, #ffffff);
    border-radius: var(--radius-lg, 16px);
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(99, 102, 241, 0.1);
    width: 100%;
    max-width: 480px;
    max-height: 600px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: aiPopupIn 0.25s ease-out;
}

@keyframes aiPopupIn {
    from {
        opacity: 0;
        transform: translateY(-10px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Header */
.ai-summary-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 50%, #4f46e5 100%);
    color: white;
}

.ai-summary-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    font-size: 15px;
}

.ai-summary-title .ai-icon {
    width: 24px;
    height: 24px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.ai-summary-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.ai-summary-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Body */
.ai-summary-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    min-height: 150px;
}

/* Loading State */
.ai-summary-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 40px 20px;
    color: var(--text-secondary, #6b7280);
}

.ai-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color, #e5e7eb);
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: aiSpin 0.8s linear infinite;
}

@keyframes aiSpin {
    to { transform: rotate(360deg); }
}

/* Summary Text */
.ai-summary-text {
    font-size: 15px;
    line-height: 1.85;
    color: var(--text-primary, #1f2937);
    text-align: right;
}

.ai-summary-text p {
    margin: 0 0 16px 0;
}

.ai-summary-text p:last-child {
    margin-bottom: 0;
}

.ai-summary-text strong {
    color: #6366f1;
    font-weight: 600;
    background: rgba(99, 102, 241, 0.08);
    padding: 1px 4px;
    border-radius: 4px;
}

/* Error State */
.ai-summary-error {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 20px;
    text-align: center;
}

.ai-error-icon {
    font-size: 32px;
}

.ai-error-text {
    color: var(--text-secondary, #6b7280);
    font-size: 13px;
}

.ai-set-key-btn {
    background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius-md, 8px);
    font-size: 13px;
    cursor: pointer;
    margin-top: 8px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.ai-set-key-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

/* Footer */
.ai-summary-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border-color, #e5e7eb);
    display: flex;
    justify-content: flex-end;
    background: var(--bg-secondary, #f9fafb);
}

.ai-regenerate-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: 1px solid var(--border-color, #e5e7eb);
    padding: 8px 16px;
    border-radius: var(--radius-md, 8px);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary, #6b7280);
    cursor: pointer;
    transition: all 0.2s;
}

.ai-regenerate-btn:hover {
    border-color: #6366f1;
    color: #6366f1;
    background: rgba(99, 102, 241, 0.08);
    transform: translateY(-1px);
}

.ai-regenerate-btn svg {
    width: 16px;
    height: 16px;
}

/* Dark Mode Support */
body.dark-mode .ai-summary-content {
    background: var(--bg-primary, #1f2937);
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(139, 92, 246, 0.2);
}

body.dark-mode .ai-summary-text {
    color: var(--text-primary, #f3f4f6);
}

body.dark-mode .ai-summary-text strong {
    color: #a78bfa;
    background: rgba(139, 92, 246, 0.15);
}

body.dark-mode .ai-summary-loading {
    color: var(--text-secondary, #9ca3af);
}

body.dark-mode .ai-spinner {
    border-color: var(--border-color, #374151);
    border-top-color: #8b5cf6;
}

body.dark-mode .ai-summary-footer {
    border-top-color: var(--border-color, #374151);
    background: var(--bg-tertiary, #111827);
}

body.dark-mode .ai-regenerate-btn {
    border-color: var(--border-color, #374151);
    color: var(--text-secondary, #9ca3af);
}

body.dark-mode .ai-regenerate-btn:hover {
    border-color: #8b5cf6;
    color: #a78bfa;
    background: rgba(139, 92, 246, 0.15);
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .ai-summary-content {
        position: fixed !important;
        top: auto !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        max-width: none;
        max-height: 80vh;
        border-radius: 20px 20px 0 0;
        animation: aiSlideUp 0.3s ease-out;
    }

    @keyframes aiSlideUp {
        from {
            transform: translateY(100%);
        }
        to {
            transform: translateY(0);
        }
    }
    
    .ai-summary-body {
        padding: 20px;
    }

    .ai-summary-btn {
        width: 26px;
        height: 26px;
    }

    .ai-summary-btn svg {
        width: 14px;
        height: 14px;
    }
}

/* Scrollbar styling */
.ai-summary-body::-webkit-scrollbar {
    width: 6px;
}

.ai-summary-body::-webkit-scrollbar-track {
    background: transparent;
}

.ai-summary-body::-webkit-scrollbar-thumb {
    background: var(--border-color, #d1d5db);
    border-radius: 3px;
}

.ai-summary-body::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary, #9ca3af);
}

body.dark-mode .ai-summary-body::-webkit-scrollbar-thumb {
    background: var(--border-color, #4b5563);
}

body.dark-mode .ai-summary-body::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary, #6b7280);
}
