/**
 * Super Assistant - Chat Widget Styles
 * Modern, clean design for AI chat interface
 */

:root {
    --sa-primary: #667eea;
    --sa-primary-dark: #5a67d8;
    --sa-secondary: #764ba2;
    --sa-success: #10b981;
    --sa-error: #ef4444;
    --sa-warning: #f59e0b;
    --sa-text: #1f2937;
    --sa-text-light: #6b7280;
    --sa-bg: #ffffff;
    --sa-bg-light: #f9fafb;
    --sa-border: #e5e7eb;
    --sa-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --sa-shadow-lg: 0 20px 50px -12px rgba(0, 0, 0, 0.25);
}

/* Confirmation Modal */
.sa-confirm-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    display: none;
}

.sa-confirm-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 16px;
    box-shadow: var(--sa-shadow-lg);
    z-index: 10001;
    max-width: 500px;
    width: calc(100vw - 48px);
    max-height: calc(100vh - 48px);
    overflow: auto;
    display: none;
}

.sa-confirm-header {
    padding: 24px;
    border-bottom: 1px solid var(--sa-border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sa-confirm-header h4 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--sa-text);
}

.sa-confirm-body {
    padding: 24px;
}

.sa-confirm-body p {
    margin: 0 0 16px 0;
    color: var(--sa-text);
}

.sa-confirm-preview {
    background: var(--sa-bg-light);
    border: 1px solid var(--sa-border);
    border-radius: 8px;
    padding: 12px;
    max-height: 300px;
    overflow: auto;
}

.sa-confirm-preview pre {
    margin: 0;
    font-size: 13px;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.sa-confirm-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--sa-border);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.sa-action-btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.sa-action-cancel {
    background: var(--sa-bg-light);
    color: var(--sa-text);
}

.sa-action-cancel:hover {
    background: var(--sa-border);
}

.sa-action-confirm {
    background: var(--sa-primary);
    color: white;
}

.sa-action-confirm:hover {
    background: var(--sa-primary-dark);
}

/* Widget Container */
.sa-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
}

/* Toggle Button */
.sa-toggle-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--sa-primary), var(--sa-secondary));
    border: none;
    color: white;
    cursor: pointer;
    box-shadow: var(--sa-shadow-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.sa-toggle-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: white;
    opacity: 0;
    transition: opacity 0.3s;
}

.sa-toggle-btn:hover {
    transform: translateY(-4px);
    box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.3);
}

.sa-toggle-btn:hover::before {
    opacity: 0.1;
}

.sa-toggle-btn.sa-open {
    transform: scale(0.9);
}

.sa-toggle-btn .sa-icon {
    width: 32px;
    height: 32px;
    position: relative;
    z-index: 1;
}

/* Badge */
.sa-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--sa-error);
    color: white;
    border-radius: 12px;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
}

/* Chat Panel */
.sa-panel {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 420px;
    max-width: calc(100vw - 48px);
    height: 650px;
    max-height: calc(100vh - 150px);
    background: var(--sa-bg);
    border-radius: 16px;
    box-shadow: var(--sa-shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: sa-slide-up 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes sa-slide-up {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Header */
.sa-header {
    background: linear-gradient(135deg, var(--sa-primary), var(--sa-secondary));
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sa-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sa-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
}

.sa-avatar svg {
    width: 24px;
    height: 24px;
}

.sa-header-text {
    flex: 1;
}

.sa-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.2;
}

.sa-subtitle {
    margin: 2px 0 0 0;
    font-size: 12px;
    opacity: 0.9;
    line-height: 1.2;
}

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

.sa-icon-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    backdrop-filter: blur(10px);
}

.sa-icon-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
}

.sa-icon-btn svg {
    width: 18px;
    height: 18px;
}

/* Messages Container */
.sa-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--sa-bg-light);
}

.sa-messages::-webkit-scrollbar {
    width: 6px;
}

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

.sa-messages::-webkit-scrollbar-thumb {
    background: var(--sa-border);
    border-radius: 3px;
}

.sa-messages::-webkit-scrollbar-thumb:hover {
    background: var(--sa-text-light);
}

/* Welcome Message */
.sa-welcome {
    text-align: center;
    padding: 40px 20px;
}

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

.sa-welcome h4 {
    margin: 0 0 12px 0;
    font-size: 20px;
    color: var(--sa-text);
}

.sa-welcome p {
    margin: 8px 0;
    color: var(--sa-text-light);
    font-size: 14px;
}

.sa-welcome ul {
    text-align: left;
    margin: 16px 0;
    padding-left: 0;
    list-style: none;
}

.sa-welcome li {
    padding: 8px 0;
    color: var(--sa-text);
    font-size: 14px;
}

.sa-welcome-hint {
    margin-top: 24px;
    padding: 12px 16px;
    background: var(--sa-bg);
    border-radius: 8px;
    font-size: 13px;
    color: var(--sa-text-light);
    border: 1px solid var(--sa-border);
}

.sa-welcome-hint kbd {
    background: var(--sa-bg-light);
    border: 1px solid var(--sa-border);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 11px;
    font-family: monospace;
    color: var(--sa-text);
}

.sa-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 20px 0;
    justify-content: center;
}

.sa-quick-btn {
    padding: 8px 14px;
    background: white;
    border: 1px solid var(--sa-border);
    border-radius: 8px;
    font-size: 13px;
    color: var(--sa-text);
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.sa-quick-btn:hover {
    background: linear-gradient(135deg, var(--sa-primary), var(--sa-secondary));
    color: white;
    border-color: transparent;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

.sa-toast {
    position: fixed;
    bottom: 100px;
    right: 24px;
    background: var(--sa-text);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: var(--sa-shadow-lg);
    z-index: 10002;
    display: none;
    font-size: 14px;
    max-width: 300px;
    animation: sa-slide-up 0.3s ease-out;
}

.sa-toast-success {
    background: var(--sa-success);
}

.sa-toast-error {
    background: var(--sa-error);
}

.sa-toast-warning {
    background: var(--sa-warning);
}

/* Message Bubbles */
.sa-message {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    animation: sa-fade-in 0.3s ease-out;
}

@keyframes sa-fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.sa-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--sa-primary), var(--sa-secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 18px;
}

.sa-message-content {
    flex: 1;
    max-width: 75%;
}

.sa-message-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    line-height: 1.5;
    font-size: 14px;
}

.sa-message-assistant .sa-message-bubble {
    background: white;
    color: var(--sa-text);
    border: 1px solid var(--sa-border);
    border-bottom-left-radius: 4px;
}

.sa-message-user .sa-message-bubble {
    background: linear-gradient(135deg, var(--sa-primary), var(--sa-secondary));
    color: white;
    border-bottom-right-radius: 4px;
    margin-left: auto;
}

.sa-message-bubble strong {
    font-weight: 600;
}

.sa-message-bubble em {
    font-style: italic;
}

.sa-message-bubble code {
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

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

.sa-message-bubble ul {
    margin: 8px 0;
    padding-left: 20px;
}

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

.sa-message-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 4px;
    padding: 0 4px;
    gap: 8px;
}

.sa-message-time {
    font-size: 11px;
    color: var(--sa-text-light);
}

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

.sa-message-copy {
    background: transparent;
    border: none;
    color: var(--sa-text-light);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    opacity: 0;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sa-message:hover .sa-message-copy {
    opacity: 1;
}

.sa-message-copy:hover {
    background: var(--sa-bg-light);
    color: var(--sa-primary);
}

.sa-message-copy svg {
    width: 14px;
    height: 14px;
}

/* Action Cards */
.sa-action-card {
    background: white;
    border: 2px solid var(--sa-primary);
    border-radius: 12px;
    margin: 16px 0;
    overflow: hidden;
    animation: sa-fade-in 0.3s ease-out;
}

.sa-action-header {
    background: linear-gradient(135deg, var(--sa-primary), var(--sa-secondary));
    color: white;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 14px;
}

.sa-action-icon {
    font-size: 18px;
}

.sa-action-body {
    padding: 16px;
}

.sa-action-message {
    margin: 0 0 12px 0;
    color: var(--sa-text);
    font-size: 14px;
}

.sa-action-preview {
    background: var(--sa-bg-light);
    border: 1px solid var(--sa-border);
    border-radius: 8px;
    padding: 12px;
    margin: 12px 0;
    max-height: 200px;
    overflow-y: auto;
}

.sa-action-preview pre {
    margin: 0;
    font-size: 12px;
    font-family: 'Courier New', monospace;
    color: var(--sa-text);
    white-space: pre-wrap;
    word-break: break-word;
}

.sa-action-buttons {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    background: var(--sa-bg-light);
    border-top: 1px solid var(--sa-border);
}

.sa-action-btn {
    flex: 1;
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s;
}

.sa-action-btn svg {
    width: 16px;
    height: 16px;
}

.sa-action-cancel {
    background: white;
    color: var(--sa-text);
    border: 1px solid var(--sa-border);
}

.sa-action-cancel:hover {
    background: var(--sa-bg-light);
}

.sa-action-confirm {
    background: var(--sa-success);
    color: white;
}

.sa-action-confirm:hover {
    background: #059669;
}

.sa-action-loading {
    opacity: 0.6;
    pointer-events: none;
}

.sa-action-success .sa-action-header {
    background: var(--sa-success);
}

.sa-action-error .sa-action-header {
    background: var(--sa-error);
}

.sa-action-cancelled .sa-action-header {
    background: var(--sa-text-light);
}

.sa-action-result {
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 600;
    color: var(--sa-text);
}

/* Link Buttons in Messages */
.sa-link-btn {
    display: inline-block;
    padding: 8px 16px;
    margin: 4px;
    background: linear-gradient(135deg, var(--sa-primary), var(--sa-secondary));
    color: white !important;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 13px;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(99, 102, 241, 0.2);
}

.sa-link-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(99, 102, 241, 0.3);
    text-decoration: none;
}

.sa-link-btn:active {
    transform: translateY(0);
}

.sa-link {
    color: var(--sa-primary);
    text-decoration: underline;
    font-weight: 500;
}

.sa-link:hover {
    color: var(--sa-secondary);
}

/* Separator in messages */
.sa-separator {
    border: none;
    border-top: 2px solid var(--sa-border);
    margin: 16px 0;
    opacity: 0.5;
}

/* Improved message bubble styling */
.sa-message-bubble ul {
    margin: 8px 0;
    padding-left: 24px;
    line-height: 1.7;
}

.sa-message-bubble li {
    margin: 6px 0;
}

/* Typing Indicator */
.sa-typing {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 12px 20px;
    background: var(--sa-bg-light);
}

.sa-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--sa-text-light);
    animation: sa-typing-bounce 1.4s infinite ease-in-out;
}

.sa-typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.sa-typing-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes sa-typing-bounce {
    0%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-8px);
    }
}

/* Input Area */
.sa-input-area {
    padding: 16px;
    background: white;
    border-top: 1px solid var(--sa-border);
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.sa-input {
    flex: 1;
    border: 1px solid var(--sa-border);
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    transition: border-color 0.2s;
    max-height: 120px;
    min-height: 42px;
}

.sa-input:focus {
    border-color: var(--sa-primary);
}

.sa-input::placeholder {
    color: var(--sa-text-light);
}

.sa-send-btn {
    width: 42px;
    height: 42px;
    border: none;
    background: linear-gradient(135deg, var(--sa-primary), var(--sa-secondary));
    color: white;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.sa-send-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.sa-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.sa-send-btn svg {
    width: 20px;
    height: 20px;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .sa-widget {
        bottom: 16px;
        right: 16px;
    }
    
    .sa-panel {
        right: 16px;
        bottom: 90px;
        width: calc(100vw - 32px);
        height: calc(100vh - 120px);
    }
    
    .sa-toggle-btn {
        width: 56px;
        height: 56px;
    }
    
    .sa-toggle-btn .sa-icon {
        width: 28px;
        height: 28px;
    }
}

