/**
 * AI Website Chatbot - Frontend Styles
 * 
 * @package AI_Website_Chatbot
 * @since 1.0.0
 */

/* AI Chatbot Frontend Styles */
:root {
    --ai-chatbot-primary: #ed3833;
    --ai-chatbot-primary-hover: #5855eb;
    --ai-chatbot-secondary: #f8fafc;
    --ai-chatbot-text: #1e293b;
    --ai-chatbot-text-light: #64748b;
    --ai-chatbot-border: #e2e8f0;
    --ai-chatbot-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --ai-chatbot-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --ai-chatbot-radius: 8px;
    --ai-chatbot-radius-lg: 12px;
}

/* Widget Container */
.ai-chatbot-widget {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--ai-chatbot-text);
}

/* Position Variants */
.ai-chatbot-widget.ai-chatbot-position-bottom-right {
    bottom: 20px;
    right: 20px;
}

.ai-chatbot-widget.ai-chatbot-position-bottom-left {
    bottom: 20px;
    left: 20px;
}

.ai-chatbot-widget.ai-chatbot-position-top-right {
    top: 20px;
    right: 20px;
}

.ai-chatbot-widget.ai-chatbot-position-top-left {
    top: 20px;
    left: 20px;
}

/* Toggle Button */
.ai-chatbot-toggle {
    background: var(--ai-chatbot-primary);
    border-radius: 50px;
    padding: 12px 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--ai-chatbot-shadow-lg);
    transition: all 0.3s ease;
    border: none;
    color: white;
}

.ai-chatbot-toggle:hover {
    background: var(--ai-chatbot-primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.ai-chatbot-toggle-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    position: relative;
}

.ai-chatbot-toggle-icon svg {
    transition: all 0.3s ease;
}

.ai-chatbot-icon-close {
    position: absolute;
    opacity: 0;
    transform: rotate(90deg);
}

.ai-chatbot-open .ai-chatbot-icon-chat {
    opacity: 0;
    transform: rotate(-90deg);
}

.ai-chatbot-open .ai-chatbot-icon-close {
    opacity: 1;
    transform: rotate(0deg);
}

.ai-chatbot-toggle-text {
    font-weight: 500;
    white-space: nowrap;
}

.ai-chatbot-toggle-close-text {
    display: none;
}

.ai-chatbot-open .ai-chatbot-toggle-open-text {
    display: none;
}

.ai-chatbot-open .ai-chatbot-toggle-close-text {
    display: block;
}

/* Main Container */
.ai-chatbot-container {
    display: none;
    flex-direction: column;
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 415px;
    max-width: calc(100vw - 40px);
    height: 525px;
    max-height: calc(100vh - 140px);
    background: white;
    border-radius: var(--ai-chatbot-radius-lg);
    box-shadow: var(--ai-chatbot-shadow-lg);
    overflow: hidden;
    border: 1px solid var(--ai-chatbot-border);
}

.ai-chatbot-widget.ai-chatbot-open .ai-chatbot-container{
    display: flex;
}

/* Minimized State */
.ai-chatbot-minimized .ai-chatbot-container {
    display: none !important;
}

/* Header */
.ai-chatbot-header {
    background: var(--ai-chatbot-primary);
    color: white;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0; /* Prevent header from shrinking */
    position: sticky;
    top: 0;
    z-index: 10;
}

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

.ai-chatbot-avatar {
    flex-shrink: 0;
}

.ai-chatbot-header-info {
    flex: 1;
    min-width: 0;
}

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

.ai-chatbot-subtitle {
    font-size: 12px;
    margin: 0;
    opacity: 0.8;
    color: rgb(255 255 255);
    font-weight: 600;
}

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

.ai-chatbot-minimize,
.ai-chatbot-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
}

.ai-chatbot-minimize:hover,
.ai-chatbot-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

/* Messages Area */
.ai-chatbot-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    scroll-behavior: smooth;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

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

.ai-chatbot-messages::-webkit-scrollbar-track {
    background: var(--ai-chatbot-secondary);
}

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

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

/* Message Bubbles */
.ai-chatbot-message {
    display: flex;
    margin-bottom: 0; /* Remove margin, use gap instead */
    animation: ai-chatbot-message-appear 0.3s ease;
}

@keyframes ai-chatbot-message-appear {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-chatbot-message-content {
    max-width: 80%;
    display: flex;
    flex-direction: column;
}

.ai-chatbot-message-bot .ai-chatbot-message-content {
    align-items: flex-start;
}

.ai-chatbot-message-user .ai-chatbot-message-content {
    align-items: flex-end;
}

.ai-chatbot-message-text {
    padding: 12px 16px;
    border-radius: var(--ai-chatbot-radius);
    word-wrap: break-word;
    line-height: 1.4;
}

.ai-chatbot-message-bot .ai-chatbot-message-text {
    background: var(--ai-chatbot-secondary);
    color: var(--ai-chatbot-text);
}

.ai-chatbot-message-user .ai-chatbot-message-text {
    background: var(--ai-chatbot-primary);
    color: white;
}

.ai-chatbot-message-error .ai-chatbot-message-text {
    background: #fee2e2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.ai-chatbot-message-time {
    font-size: 11px;
    color: var(--ai-chatbot-text-light);
    margin-top: 4px;
    text-align: right;
}

.ai-chatbot-message-bot {
    justify-content: flex-start; /* Bot messages on left */
}

.ai-chatbot-message-user {
    justify-content: flex-end; /* User messages on right */
}

.ai-chatbot-message-bot .ai-chatbot-message-time {
    text-align: left;
}

/* Typing Indicator */
.ai-chatbot-typing {
    padding: 0 16px 16px;
    animation: ai-chatbot-fade-in 0.3s ease;
}

.ai-chatbot-shortcode .ai-chatbot-typing {
    background: #fff;
    padding: 0 20px 10px;
    border-right: 6px solid var(--ai-chatbot-secondary);
}

@keyframes ai-chatbot-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.ai-chatbot-typing-content {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--ai-chatbot-text-light);
    font-size: 13px;
}

.ai-chatbot-typing-dots {
    display: flex;
    gap: 4px;
}

.ai-chatbot-typing-dots span {
    width: 6px;
    height: 6px;
    background: var(--ai-chatbot-text-light);
    border-radius: 50%;
    animation: ai-chatbot-typing-bounce 1.4s infinite ease-in-out;
}

.ai-chatbot-typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.ai-chatbot-typing-dots span:nth-child(2) { animation-delay: -0.16s; }
.ai-chatbot-typing-dots span:nth-child(3) { animation-delay: 0s; }

@keyframes ai-chatbot-typing-bounce {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Input Area */
.ai-chatbot-input-area {
    border-top: 1px solid var(--ai-chatbot-border);
    background: white;
    flex-shrink: 0; /* Prevent input area from shrinking */
    position: sticky;
    bottom: 0;
    z-index: 10;
}

.ai-chatbot-shortcode .ai-chatbot-input-area {
    border-top: none;
}

.ai-chatbot-input-form {
    padding: 16px;
}

.ai-chatbot-input-container {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.ai-chatbot-input {
    flex: 1;
    border: 1px solid var(--ai-chatbot-border);
    border-radius: var(--ai-chatbot-radius);
    padding: 12px 16px;
    resize: none;
    outline: none;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.4;
    max-height: 100px;
    min-height: 44px;
    transition: all 0.2s ease;
}

.ai-chatbot-input:focus {
    border-color: var(--ai-chatbot-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

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

.ai-chatbot-send-button {
    background: var(--ai-chatbot-primary);
    color: white;
    border: none;
    border-radius: var(--ai-chatbot-radius);
    width: 44px;
    height: 44px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.ai-chatbot-send-button:hover:not(:disabled) {
    background: var(--ai-chatbot-primary-hover);
}

.ai-chatbot-send-button:disabled {
    background: var(--ai-chatbot-text-light);
    cursor: not-allowed;
    opacity: 0.5;
}

.ai-chatbot-footer {
    padding: 8px 16px;
    text-align: center;
    border-top: 1px solid var(--ai-chatbot-border);
    background: var(--ai-chatbot-secondary);
}

.ai-chatbot-powered-by {
    font-size: 11px;
    color: var(--ai-chatbot-text-light);
}

/* Inline Chatbot Styles */
.ai-chatbot-inline {
    border: 1px solid var(--ai-chatbot-border);
    border-radius: var(--ai-chatbot-radius-lg);
    overflow: hidden;
    background: white;
    box-shadow: var(--ai-chatbot-shadow);
    display:flex;
    flex-direction: column;
}

.ai-chatbot-inline-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    border-radius: var(--ai-chatbot-radius-lg);
    box-shadow: var(--ai-chatbot-shadow-lg);
    overflow: hidden;
    border: 1px solid var(--ai-chatbot-border);
}

.ai-chatbot-container.has-prechat-form,
.ai-chatbot-container.has-feedback-form {
    height: 600px !important; /* Increased height for forms */
    max-height: calc(100vh - 100px) !important;
}


/* Mobile Responsive */

@media (max-width: 480px) {
    .ai-chatbot-container {
        position: fixed;
        bottom: 60px;
        left: 0;
        right: 0;
        top: 20px;
        width: 100%;
        max-width: none;
        height: auto;
        border-radius: 12px 12px 0 0;
        max-height: calc(100vh - 80px);
        display: flex;
        flex-direction: column;
    }
    
    .ai-chatbot-header {
        position: sticky;
        top: 0;
        z-index: 100;
        flex-shrink: 0;
    }
    
    .ai-chatbot-messages {
        flex: 1;
        padding: 12px;
        overflow-y: auto;
    }
    
    .ai-chatbot-input-area {
        position: sticky;
        bottom: 0;
        background: white;
        border-top: 2px solid var(--ai-chatbot-border);
        flex-shrink: 0;
        z-index: 100;
    }
}

@media (max-width: 480px) {
    
    .ai-chatbot-widget.ai-chatbot-position-bottom-left {
        left: 10px;
    }
    
    .ai-chatbot-toggle {
        padding: 10px 16px;
        font-size: 13px;
    }
    
    .ai-chatbot-toggle-text {
        display: none;
    }
    
    .ai-chatbot-messages {
        padding: 12px;
    }
    
    .ai-chatbot-input-form {
        padding: 12px;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    :root {
        --ai-chatbot-secondary: #1e293b;
        --ai-chatbot-text: #f1f5f9;
        --ai-chatbot-text-light: #94a3b8;
        --ai-chatbot-border: #334155;
    }
    
    .ai-chatbot-container {
        background: #0f172a;
        border-color: var(--ai-chatbot-border);
    }
    
    .ai-chatbot-input-area {
        background: #0f172a;
    }
    
    .ai-chatbot-input {
        background: #1e293b;
        color: var(--ai-chatbot-text);
        border-color: var(--ai-chatbot-border);
    }
    
    .ai-chatbot-message-bot .ai-chatbot-message-text {
        background: #1e293b;
        color: var(--ai-chatbot-text);
    }
}

/* Print Styles */
@media print {
    .ai-chatbot-widget {
        display: none !important;
    }
}

/* Accessibility */
.ai-chatbot-widget button:focus,
.ai-chatbot-widget input:focus,
.ai-chatbot-widget textarea:focus {
    outline: 2px solid var(--ai-chatbot-primary);
    outline-offset: 2px;
}

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

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .ai-chatbot-toggle {
        border: 2px solid currentColor;
    }
    
    .ai-chatbot-container {
        border: 2px solid currentColor;
    }
    
    .ai-chatbot-input {
        border: 2px solid currentColor;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .ai-chatbot-widget *,
    .ai-chatbot-widget *::before,
    .ai-chatbot-widget *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideInScale {
    from {
        opacity: 0;
        transform: scale(0.7) translateY(50px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

@keyframes successPulse {
    0% { transform: scale(0.8); opacity: 0; }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); opacity: 1; }
}

/* Form error state */
.ai-chatbot-form-input.error {
    border-color: #ef4444 !important;
    background: #fef2f2 !important;
    animation: inputShake 0.4s ease;
}

@keyframes inputShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

/* Loading button state */
.ai-chatbot-form-submit.loading {
    background: #9ca3af !important;
    cursor: not-allowed !important;
    transform: none !important;
}

/* Mobile responsiveness */
@media (max-width: 480px) {
    #ai-chatbot-pre-chat-modal {
        width: 95% !important;
        margin: 10px !important;
        max-height: 85vh !important;
    }
    
    #ai-chatbot-prechat-overlay {
        padding: 10px !important;
    }
}

/* Hide chat widget/popup behind overlay */
#ai-chatbot-prechat-overlay ~ * {
    pointer-events: none;
}

/* Dark theme support */
@media (prefers-color-scheme: dark) {
    #ai-chatbot-pre-chat-modal {
        background: #1f2937 !important;
        color: white !important;
    }
    
    .ai-chatbot-form-input {
        background: #374151 !important;
        border-color: #4b5563 !important;
        color: white !important;
    }
    
    .ai-chatbot-form-input::placeholder {
        color: #9ca3af !important;
    }
}

/* ========================================
   RATING SYSTEM STYLES
   ======================================== */

/* Individual Message Rating (Quick Rating) */
.message-rating {
    margin-top: 8px;
    padding: 8px 0;
    border-top: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.message-rating:hover {
    opacity: 1;
}

.rating-label {
    font-size: 11px;
    color: #6b7280;
    margin-right: 4px;
}

.quick-rating {
    display: flex;
    gap: 6px;
}

.quick-rating-btn {
    background: none;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s ease;
    opacity: 0.7;
    min-width: 32px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.quick-rating-btn:hover {
    opacity: 1;
    transform: scale(1.1);
    background: #f8fafc;
}

.quick-rating-btn.positive:hover {
    background: #ecfdf5;
    border-color: #86efac;
}

.quick-rating-btn.negative:hover {
    background: #fef2f2;
    border-color: #fca5a5;
}

/* Thank you state for quick rating */
.rating-thanks {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #059669;
    font-weight: 500;
    animation: fadeInRating 0.3s ease;
}

.thank-emoji {
    font-size: 14px;
}

.thank-text {
    font-style: italic;
}

/* End of Conversation Rating */
.end-conversation-rating {
    border: 2px solid #e5e7eb !important;
    border-radius: 16px !important;
    margin: 20px 0 !important;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%) !important;
    animation: slideInRating 0.5s ease-out;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    justify-content: center
}

.rating-bubble {
    background: transparent !important;
    border: none !important;
    padding: 20px !important;
}

.rating-bubble h4 {
    text-align: center;
    margin: 0 0 20px 0;
    color: #374151;
    font-size: 18px;
    font-weight: 600;
}

/* Smiley rating buttons */
.rating-smilies {
    display: flex;
    justify-content: space-between;
    gap: 8px; /* Reduced gap */
    margin: 15px 0; /* Reduced margin */
    flex-wrap: nowrap; /* Force single row */
}

.smiley-btn {
    background: #ffffff;
    border: 2px solid #e5e7eb;
    border-radius: 8px; /* Smaller radius */
    padding: 8px 4px; /* Reduced padding */
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px; /* Reduced gap */
    flex: 1;
    min-width: 60px; /* Smaller minimum width */
    max-width: 65px; /* Maximum width to keep them small */
    position: relative;
    overflow: hidden;
}

.smiley-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    border-color: #6366f1;
}

.smiley-btn.selected {
    background: #6366f1;
    border-color: #6366f1;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.4);
}

.smiley-btn.bounce {
    animation: smileyBounce 0.6s ease;
}

.smiley {
    font-size: 32px;
    line-height: 1;
    transition: transform 0.3s ease;
}

.smiley-btn:hover .smiley {
    transform: scale(1.2);
}

.smiley-btn.selected .smiley {
    transform: scale(1.1);
    filter: brightness(1.2);
}

.smiley-label {
    font-size: 10px; /* Smaller label text */
    font-weight: 500;
    text-align: center;
    transition: color 0.3s ease;
    color: #6b7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

.smiley-btn:hover .smiley-label,
.smiley-btn.selected .smiley-label {
    color: inherit;
}

/* Feedback section */
.rating-feedback {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e5e7eb;
}

.feedback-text {
    width: 100%;
    padding: 12px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    resize: vertical;
    min-height: 80px;
    font-family: inherit;
    font-size: 14px;
    transition: border-color 0.3s ease;
    background: #ffffff;
}

.feedback-text:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.feedback-text::placeholder {
    color: #9ca3af;
}

.rating-actions {
    display: flex;
    gap: 12px;
    margin-top: 15px;
    justify-content: center;
}

.submit-rating-btn,
.skip-rating-btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    font-size: 14px;
}

.submit-rating-btn {
    background: #6366f1;
    color: white;
}

.submit-rating-btn:hover {
    background: #5855eb;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.skip-rating-btn {
    background: #f3f4f6;
    color: #6b7280;
}

.skip-rating-btn:hover {
    background: #e5e7eb;
    color: #374151;
}

/* Thank you message */
.rating-thank-you {
    text-align: center;
    padding: 30px 20px;
}

.thank-you-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.thank-you-emoji {
    font-size: 48px;
    animation: thankYouPulse 1s ease;
}

.thank-you-message p {
    margin: 0;
    font-size: 16px;
    font-weight: 500;
    color: #374151;
}

/* ========================================
   ANIMATIONS
   ======================================== */

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

@keyframes smileyBounce {
    0%, 100% { transform: scale(1); }
    25% { transform: scale(1.2) rotate(-5deg); }
    50% { transform: scale(1.1) rotate(5deg); }
    75% { transform: scale(1.15) rotate(-2deg); }
}

@keyframes thankYouPulse {
    0% { transform: scale(0.8); opacity: 0; }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes fadeInRating {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

/* Mobile responsiveness */
@media (max-width: 480px) {
    .rating-smilies {
        gap: 6px;
    }
    
    .smiley-btn {
        min-width: 50px;
        max-width: 55px;
        padding: 6px 2px;
    }
    
    .smiley {
        font-size: 18px;
    }
    
    .smiley-label {
        font-size: 9px;
    }
    
    .rating-actions {
        flex-direction: column;
    }
    
    .submit-rating-btn,
    .skip-rating-btn {
        width: 100%;
    }
    
    .end-conversation-rating {
        margin: 15px 0 !important;
    }
    
    .rating-bubble {
        padding: 15px !important;
    }
    
    .rating-bubble h4 {
        font-size: 16px;
    }
}

@media (max-width: 320px) {
    .smiley-btn {
        min-width: 50px;
        padding: 10px 4px;
    }
    
    .smiley {
        font-size: 20px;
    }
    
    .smiley-label {
        font-size: 9px;
    }
}

/* Tablet responsiveness */
@media (min-width: 481px) and (max-width: 768px) {
    .rating-smilies {
        gap: 12px;
    }
    
    .smiley-btn {
        min-width: 70px;
        padding: 14px 10px;
    }
    
    .smiley {
        font-size: 28px;
    }
}

/* ========================================
   DARK THEME SUPPORT
   ======================================== */

@media (prefers-color-scheme: dark) {
    .end-conversation-rating {
        background: linear-gradient(135deg, #1f2937 0%, #111827 100%) !important;
        border-color: #374151 !important;
    }
    
    .rating-bubble h4 {
        color: #f9fafb;
    }
    
    .smiley-btn {
        background: #374151;
        border-color: #4b5563;
        color: #f9fafb;
    }
    
    .smiley-btn:hover {
        border-color: #6366f1;
    }
    
    .smiley-label {
        color: #d1d5db;
    }
    
    .feedback-text {
        background: #374151;
        border-color: #4b5563;
        color: #f9fafb;
    }
    
    .feedback-text::placeholder {
        color: #6b7280;
    }
    
    .skip-rating-btn {
        background: #374151;
        color: #d1d5db;
    }
    
    .skip-rating-btn:hover {
        background: #4b5563;
        color: #f9fafb;
    }
    
    .thank-you-message p {
        color: #f9fafb;
    }
    
    .message-rating {
        border-top-color: #374151;
    }
    
    .quick-rating-btn {
        border-color: #4b5563;
        color: #d1d5db;
    }
    
    .quick-rating-btn:hover {
        background: #374151;
    }
    
    .rating-thanks {
        color: #34d399;
    }
}

/* ========================================
   HIGH CONTRAST MODE
   ======================================== */

@media (prefers-contrast: high) {
    .smiley-btn {
        border-width: 3px;
    }
    
    .smiley-btn.selected {
        border-width: 4px;
    }
    
    .quick-rating-btn {
        border-width: 2px;
    }
    
    .feedback-text {
        border-width: 3px;
    }
}

/* ========================================
   REDUCED MOTION SUPPORT
   ======================================== */

@media (prefers-reduced-motion: reduce) {
    .smiley-btn,
    .quick-rating-btn,
    .submit-rating-btn,
    .skip-rating-btn {
        transition: none;
    }
    
    .smiley-btn:hover {
        transform: none;
    }
    
    .submit-rating-btn:hover {
        transform: none;
    }
    
    .smiley-btn.bounce,
    .thank-you-emoji {
        animation: none;
    }
    
    .end-conversation-rating {
        animation: none;
    }
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
    .message-rating,
    .end-conversation-rating {
        display: none;
    }
}

/* ========================================
   ADDITIONAL UTILITY CLASSES
   ======================================== */

.rating-disabled .smiley-btn,
.rating-disabled .quick-rating-btn {
    pointer-events: none;
    opacity: 0.5;
}

.rating-loading .submit-rating-btn {
    background: #9ca3af;
    cursor: not-allowed;
    pointer-events: none;
}

.rating-loading .submit-rating-btn::after {
    content: " ⏳";
}

/* Focus styles for accessibility */
.smiley-btn:focus,
.quick-rating-btn:focus,
.submit-rating-btn:focus,
.skip-rating-btn:focus {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
}

.feedback-text:focus {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
}

.ai-chatbot-prechat-form {
    padding: 25px 20px;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border-radius: 16px;
    margin: 10px;
    text-align: center;
    animation: slideInUp 0.4s ease;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.prechat-header {
    margin-bottom: 25px;
}

.prechat-avatar {
    font-size: 32px;
    margin-bottom: 10px;
    animation: bounce 2s infinite;
}

.prechat-header h3 {
    margin: 0 0 8px 0;
    font-size: 20px;
    font-weight: 600;
    color: #1e293b;
}

.prechat-header p {
    margin: 0;
    font-size: 14px;
    color: #64748b;
    line-height: 1.5;
}

.prechat-form {
    text-align: left;
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 13px;
    color: #374151;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s ease;
    background: white;
    box-sizing: border-box;
}

.form-group input:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-group input::placeholder {
    color: #9ca3af;
}

.form-actions {
    margin: 25px 0 15px 0;
    text-align: center;
}

.start-chat-btn {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    border: none;
    padding: 14px 24px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 160px;
    justify-content: center;
}

.start-chat-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.4);
}

.start-chat-btn:disabled,
.start-chat-btn.loading {
    background: #9ca3af;
    cursor: not-allowed;
    transform: none;
}

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

.form-footer {
    text-align: center;
    margin-top: 15px;
}

.form-footer small {
    font-size: 12px;
    color: #6b7280;
}

/* Error message styling */
.prechat-error {
    background: #fee2e2;
    border: 1px solid #fecaca;
    color: #dc2626;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 15px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: slideInDown 0.3s ease;
}

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

/* Animations */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

/* Mobile responsiveness */
@media (max-width: 480px) {
    .ai-chatbot-prechat-form {
        padding: 20px 15px;
        margin: 5px;
    }
    
    .prechat-header h3 {
        font-size: 18px;
    }
    
    .form-group input {
        padding: 10px;
    }
    
    .start-chat-btn {
        padding: 12px 20px;
        font-size: 14px;
        width: 100%;
    }
}

/* Dark theme support */
@media (prefers-color-scheme: dark) {
    .ai-chatbot-prechat-form {
        background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
    }
    
    .prechat-header h3 {
        color: #f9fafb;
    }
    
    .prechat-header p {
        color: #d1d5db;
    }
    
    .form-group label {
        color: #f3f4f6;
    }
    
    .form-group input {
        background: #374151;
        border-color: #4b5563;
        color: #f9fafb;
    }
    
    .form-group input::placeholder {
        color: #6b7280;
    }
    
    .form-footer small {
        color: #9ca3af;
    }
}

/* ========================================
   SUBMITTED RATING DISPLAY
   ======================================== */

.rating-submitted {
    text-align: center;
    padding: 20px;
    animation: slideInRating 0.5s ease-out;
}

.submitted-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e5e7eb;
}

.check-icon {
    font-size: 18px;
    animation: checkBounce 0.6s ease;
}

.submitted-text {
    font-weight: 600;
    color: #059669;
    font-size: 16px;
}

.submitted-rating {
    margin-bottom: 20px;
}

.rating-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 15px;
    padding: 15px;
    background: #f8fafc;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

.submitted-emoji {
    font-size: 36px;
    animation: emojiPulse 0.8s ease;
}

.rating-info {
    text-align: left;
}

.rating-label {
    font-weight: 600;
    font-size: 16px;
    color: #374151;
    margin-bottom: 5px;
}

.rating-stars {
    display: flex;
    gap: 2px;
}

.star {
    font-size: 14px;
    transition: all 0.2s ease;
}

.star.filled {
    color: #fbbf24;
    text-shadow: 0 0 2px rgba(251, 191, 36, 0.5);
}

.star.empty {
    color: #d1d5db;
}

.submitted-feedback {
    margin-top: 15px;
    padding: 15px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    text-align: left;
}

.feedback-label {
    font-size: 12px;
    font-weight: 500;
    color: #6b7280;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.feedback-text-display {
    font-size: 14px;
    color: #374151;
    line-height: 1.5;
    font-style: italic;
    position: relative;
    padding-left: 10px;
    border-left: 3px solid #6366f1;
}

.thank-you-note {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
    color: #6b7280;
    font-weight: 500;
    padding: 12px;
    background: #f9fafb;
    border-radius: 8px;
    margin-top: 15px;
}

.thank-icon {
    font-size: 16px;
    animation: heartbeat 2s infinite;
}

/* Enhanced message rating thanks */
.rating-thanks-enhanced {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 12px;
    color: #059669;
    font-weight: 500;
    animation: fadeInRating 0.3s ease;
    padding: 8px 12px;
    background: #ecfdf5;
    border-radius: 20px;
    border: 1px solid #bbf7d0;
    margin-top: 8px;
}

.rating-emoji {
    font-size: 16px;
    animation: ratingBounce 0.5s ease;
}

.rating-text {
    flex: 1;
    text-align: center;
}

/* Completed rating states */
.rating-completed {
    opacity: 1 !important;
    pointer-events: none;
}

.end-conversation-rating.rating-completed {
    border-color: #059669 !important;
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%) !important;
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.15);
}

.end-conversation-rating.rating-completed .rating-bubble {
    background: transparent !important;
}

/* Animations */
@keyframes checkBounce {
    0% { transform: scale(0.8); opacity: 0; }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes emojiPulse {
    0% { transform: scale(0.9); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

@keyframes ratingBounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    25% { transform: scale(1.1); }
    50% { transform: scale(1); }
    75% { transform: scale(1.05); }
}

/* Mobile responsiveness */
@media (max-width: 480px) {
    .rating-display {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    .rating-info {
        text-align: center;
    }
    
    .submitted-emoji {
        font-size: 32px;
    }
    
    .rating-thanks-enhanced {
        font-size: 11px;
        gap: 6px;
        padding: 6px 10px;
    }
}

/* Restored rating display */
.restored-note {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 12px;
    color: #6b7280;
    font-weight: 500;
    padding: 8px;
    background: #f9fafb;
    border-radius: 6px;
    margin-top: 10px;
    border: 1px solid #e5e7eb;
}

.history-icon {
    font-size: 14px;
    opacity: 0.8;
}

.submitted-header .submitted-text {
    color: #6b7280;
}

.end-conversation-rating.rating-completed .submitted-header .submitted-text {
    color: #6b7280;
}

/* Different styling for restored vs newly submitted ratings */
.end-conversation-rating.rating-completed.restored {
    border-color: #6b7280 !important;
    background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%) !important;
    box-shadow: 0 2px 8px rgba(107, 114, 128, 0.1);
}

/* Dark theme support for restored ratings */
@media (prefers-color-scheme: dark) {
    .restored-note {
        background: #374151;
        color: #d1d5db;
        border-color: #4b5563;
    }
    
    .end-conversation-rating.rating-completed.restored {
        background: linear-gradient(135deg, #374151 0%, #1f2937 100%) !important;
        border-color: #4b5563 !important;
    }
}

/* Conversation End and New Conversation Messages */
.conversation-ended,
.new-conversation {
    margin: 20px 0 !important;
    text-align: center;
}

.system-bubble {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%) !important;
    border: 2px solid #0ea5e9 !important;
    border-radius: 16px !important;
    padding: 20px !important;
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.15);
}

.conversation-end-notice,
.new-conversation-notice {
    display: flex;
    align-items: center;
    gap: 15px;
    text-align: left;
}

.end-icon,
.start-icon {
    font-size: 32px;
    flex-shrink: 0;
}

.end-text,
.start-text {
    flex: 1;
}

.end-text strong,
.start-text strong {
    display: block;
    font-size: 16px;
    color: #0369a1;
    margin-bottom: 5px;
}

.end-text p,
.start-text p {
    margin: 0;
    font-size: 14px;
    color: #0284c7;
    line-height: 1.4;
}

/* Animation for conversation end */
.conversation-ended {
    animation: slideInEnd 0.6s ease-out;
}

.new-conversation {
    animation: slideInStart 0.6s ease-out;
}

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

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

/* Dark theme support */
@media (prefers-color-scheme: dark) {
    .system-bubble {
        background: linear-gradient(135deg, #0c4a6e 0%, #075985 100%) !important;
        border-color: #0ea5e9 !important;
    }
    
    .end-text strong,
    .start-text strong {
        color: #7dd3fc;
    }
    
    .end-text p,
    .start-text p {
        color: #38bdf8;
    }
}

/* Mobile responsiveness */
@media (max-width: 480px) {
    .conversation-end-notice,
    .new-conversation-notice {
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }
    
    .end-icon,
    .start-icon {
        font-size: 28px;
    }
    
    .system-bubble {
        padding: 15px !important;
    }
}

/* Inline Rating Display */
.rating-submitted-inline {
    text-align: center;
    padding: 15px;
}

.rating-completed-inline {
    border-color: #059669 !important;
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%) !important;
    opacity: 0.9;
}

.rating-display-inline {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 10px 0;
    padding: 12px;
    background: #ffffff;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.rating-display-inline .submitted-emoji {
    font-size: 28px;
}

.rating-display-inline .rating-info {
    text-align: left;
}

.rating-display-inline .rating-label {
    font-weight: 600;
    font-size: 14px;
    color: #374151;
    margin-bottom: 4px;
}

.rating-display-inline .rating-stars {
    display: flex;
    gap: 2px;
}

.rating-display-inline .star {
    font-size: 12px;
}

.rating-display-inline .star.filled {
    color: #fbbf24;
}

.rating-display-inline .star.empty {
    color: #d1d5db;
}

/* Previous rating indicator */
.submitted-header .check-icon {
    font-size: 16px;
}

/* Mobile responsiveness */
@media (max-width: 480px) {
    .rating-display-inline {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }
    
    .rating-display-inline .rating-info {
        text-align: center;
    }
    
    .rating-display-inline .submitted-emoji {
        font-size: 24px;
    }
}