/**
 * Scramble Technology Chatbot Widget Styles
 *
 * CSP-compliant styles with TailwindCSS compatibility.
 * Responsive design with accessibility focus.
 */

/* Widget Container */
.chatbot-widget {
    position: fixed;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.chatbot-bottom-right {
    bottom: 20px;
    right: 20px;
}

.chatbot-bottom-left {
    bottom: 20px;
    left: 20px;
}

/* Toggle Button */
.chatbot-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6 0%, #10b981 100%);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
}

.chatbot-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.5), 0 6px 16px rgba(16, 185, 129, 0.3);
}

.chatbot-toggle:active {
    transform: scale(0.95);
}

.chatbot-toggle:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.chatbot-icon,
.chatbot-close-icon {
    transition: opacity 0.2s ease;
}

/* Notification Badge */
.chatbot-notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Chat Window */
.chatbot-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 600px;
    max-height: calc(100vh - 120px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

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

@keyframes slideUpCentered {
    from {
        opacity: 0;
        transform: translate(-50%, -45%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

.chatbot-window.hidden {
    display: none;
}

/* Header */
.chatbot-header {
    background: linear-gradient(135deg, #3b82f6 0%, #10b981 100%);
    color: white;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.chatbot-avatar {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

.chatbot-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.chatbot-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    margin: 4px 0 0 0;
    opacity: 0.9;
}

.chatbot-status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    animation: pulse 2s infinite;
}

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

.chatbot-status-text {
    font-size: 12px;
}

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

.chatbot-header-button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.chatbot-header-button:hover {
    background: rgba(255, 255, 255, 0.3);
}

.chatbot-header-button:focus {
    outline: 2px solid white;
    outline-offset: 2px;
}

/* Messages Container */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f9fafb;
    scroll-behavior: smooth;
}

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

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

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

.chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Messages */
.chatbot-message {
    margin-bottom: 16px;
    animation: fadeIn 0.3s ease;
}

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

.chatbot-message-content {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 12px;
    word-wrap: break-word;
}

.chatbot-message-user .chatbot-message-content {
    background: linear-gradient(135deg, #3b82f6 0%, #10b981 100%);
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.chatbot-message-assistant .chatbot-message-content {
    background: white;
    color: #1f2937;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.chatbot-message-content p {
    margin: 0;
    line-height: 1.5;
    font-size: 14px;
}

.chatbot-message-text {
    line-height: 1.6;
    font-size: 14px;
}

.chatbot-message-text strong {
    font-weight: 600;
    color: inherit;
}

.chatbot-message-text em {
    font-style: italic;
    color: inherit;
}

.chatbot-message-text ul {
    margin: 8px 0;
    padding-left: 20px;
    list-style-type: disc;
}

.chatbot-message-text ol {
    margin: 8px 0;
    padding-left: 20px;
    list-style-type: decimal;
}

.chatbot-message-text li {
    margin: 4px 0;
    line-height: 1.5;
}

.chatbot-message-text br {
    display: block;
    content: "";
    margin: 4px 0;
}

.chatbot-message-time {
    display: block;
    font-size: 11px;
    margin-top: 4px;
    opacity: 0.7;
}

/* Typing Indicator */
.chatbot-typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border-radius: 12px;
    width: fit-content;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.chatbot-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #9ca3af;
    animation: typing 1.4s infinite;
}

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

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

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

/* Input Area */
.chatbot-input-area {
    padding: 16px;
    background: white;
    border-top: 1px solid #e5e7eb;
}

.chatbot-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
}

.chatbot-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #d1d5db;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease;
}

.chatbot-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.chatbot-send-button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6 0%, #10b981 100%);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chatbot-send-button:hover:not(:disabled) {
    background: linear-gradient(135deg, #2563eb 0%, #059669 100%);
    transform: scale(1.05);
}

.chatbot-send-button:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

.chatbot-send-button:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.chatbot-input-hint {
    margin-top: 8px;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 12px;
    line-height: 1.4;
}

.chatbot-hint-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.chatbot-hint-warning {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
}

.chatbot-hint-success {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

/* Footer */
.chatbot-footer {
    padding: 12px 16px;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 12px;
    color: #6b7280;
}

.chatbot-footer-link {
    background: none;
    border: none;
    color: #3b82f6;
    cursor: pointer;
    text-decoration: none;
    transition: color 0.2s ease;
    padding: 0;
    font-size: 12px;
}

.chatbot-footer-link:hover {
    color: #10b981;
    text-decoration: underline;
}

.chatbot-footer-link:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
    border-radius: 2px;
}

.chatbot-footer-divider {
    color: #d1d5db;
}

/* Feedback Modal */
.chatbot-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.2s ease;
}

.chatbot-modal.hidden {
    display: none;
}

.chatbot-modal-content {
    background: white;
    border-radius: 16px;
    padding: 24px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

.chatbot-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.chatbot-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #1f2937;
}

.chatbot-modal-close {
    background: none;
    border: none;
    color: #6b7280;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.chatbot-modal-close:hover {
    background: #f3f4f6;
}

.chatbot-modal-close:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Feedback Rating */
.chatbot-feedback-rating {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 20px;
}

.chatbot-rating-button {
    background: none;
    border: none;
    font-size: 32px;
    cursor: pointer;
    opacity: 0.3;
    transition: all 0.2s ease;
    padding: 4px;
}

.chatbot-rating-button:hover,
.chatbot-rating-button.active {
    opacity: 1;
    transform: scale(1.1);
}

.chatbot-rating-button:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
    border-radius: 4px;
}

/* Feedback Helpful */
.chatbot-feedback-helpful {
    margin-bottom: 16px;
}

.chatbot-feedback-helpful label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    margin-bottom: 8px;
}

.chatbot-feedback-buttons {
    display: flex;
    gap: 8px;
}

.chatbot-feedback-yes,
.chatbot-feedback-no {
    flex: 1;
    padding: 10px 16px;
    border: 2px solid #e5e7eb;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    transition: all 0.2s ease;
}

.chatbot-feedback-yes:hover,
.chatbot-feedback-no:hover {
    border-color: #3b82f6;
    background: #eff6ff;
}

.chatbot-feedback-yes.active,
.chatbot-feedback-no.active {
    border-color: #3b82f6;
    background: linear-gradient(135deg, #3b82f6 0%, #10b981 100%);
    color: white;
}

.chatbot-feedback-yes:focus,
.chatbot-feedback-no:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Feedback Textarea */
.chatbot-feedback-textarea {
    width: 100%;
    min-height: 80px;
    padding: 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    margin-bottom: 16px;
}

.chatbot-feedback-textarea:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Feedback Submit */
.chatbot-feedback-submit {
    width: 100%;
    padding: 12px 24px;
    background: linear-gradient(135deg, #3b82f6 0%, #10b981 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chatbot-feedback-submit:hover {
    background: linear-gradient(135deg, #2563eb 0%, #059669 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.chatbot-feedback-submit:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Dark Theme */
.chatbot-dark .chatbot-window {
    background: #1f2937;
}

.chatbot-dark .chatbot-messages {
    background: #111827;
}

.chatbot-dark .chatbot-message-assistant .chatbot-message-content {
    background: #374151;
    color: #f9fafb;
}

.chatbot-dark .chatbot-input-area {
    background: #1f2937;
    border-top-color: #374151;
}

.chatbot-dark .chatbot-input {
    background: #374151;
    border-color: #4b5563;
    color: #f9fafb;
}

.chatbot-dark .chatbot-footer {
    background: #111827;
    border-top-color: #374151;
}

/* Responsive */
@media (max-width: 480px) {
    .chatbot-window {
        position: fixed !important;
        width: calc(100vw - 32px);
        height: calc(100vh - 140px);
        max-height: calc(100vh - 140px);
        top: 50% !important;
        left: 50% !important;
        right: auto !important;
        bottom: auto !important;
        transform: translate(-50%, -50%) !important;
        margin: 0;
        animation: slideUpCentered 0.3s ease !important;
        z-index: 10000;
    }

    .chatbot-bottom-left .chatbot-window,
    .chatbot-bottom-right .chatbot-window {
        position: fixed !important;
        top: 50% !important;
        left: 50% !important;
        right: auto !important;
        bottom: auto !important;
        transform: translate(-50%, -50%) !important;
        margin: 0;
        animation: slideUpCentered 0.3s ease !important;
    }

    .chatbot-toggle {
        width: 56px;
        height: 56px;
    }
}

/* Accessibility */
.chatbot-widget *:focus {
    outline-color: #3b82f6;
}

/* Hidden utility */
.hidden {
    display: none !important;
}

/* Screen reader only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}
