/**
 * Frontend CSS for Modern Chat Widget
 *
 * @package Saan_AI_Chat
 */

/* Chat Widget Container */
.saan-chat-widget {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Floating Chat Button */
.chat-toggle {
    position: relative;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Hide chat toggle when chat is open */
.saan-chat-widget .chat-container.active ~ .chat-toggle,
.saan-chat-widget .chat-container.active + .chat-toggle,
.chat-toggle.hidden {
    opacity: 0 !important;
    pointer-events: none !important;
    transform: scale(0.8) !important;
    visibility: hidden !important;
    display: none !important;
}

.chat-button {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
    position: relative;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 3px solid white;
}

.chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 35px rgba(102, 126, 234, 0.4);
}

.chat-icon {
    font-size: 24px;
    color: white;
    z-index: 2;
    position: relative;
}

/* Pulse Animation */
.chat-pulse {
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    opacity: 0.6;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 0.6;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.3;
    }
    100% {
        transform: scale(1);
        opacity: 0.6;
    }
}

/* Tooltip */
.chat-tooltip {
    position: absolute;
    right: 70px;
    top: 50%;
    transform: translateY(-50%);
    background: #333;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.chat-tooltip::after {
    content: '';
    position: absolute;
    right: -4px;
    top: 50%;
    transform: translateY(-50%);
    border-left: 4px solid #333;
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
}

.chat-toggle:hover .chat-tooltip {
    opacity: 1;
}

/* Chat Container */
.chat-container {
    position: absolute;
    bottom: 10px;
    right: 0;
    width: 380px;
    height: 500px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    visibility: hidden;
}

.chat-container.active {
    opacity: 1;
    transform: translateY(0) scale(1);
    visibility: visible;
}

/* Chat Header */
.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: left;
    position: relative;
}

.chat-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

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

.bot-info {
    display: flex;
    flex-direction: column;
}

.bot-name {
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 2px;
}

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

.bot-status::before {
    content: '';
    width: 6px;
    height: 6px;
    background: #4ade80;
    border-radius: 50%;
    animation: statusPulse 2s infinite;
}

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

.close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
    margin-left: auto;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* Back Button */
.back-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    margin-right: 8px;
}

.back-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    padding: 10px 20px;
    overflow-y: auto;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message {
    display: flex;
    animation: messageSlideIn 0.3s ease-out;
}

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

.message.user-message {
    justify-content: flex-end;
}

.message.bot-message {
    justify-content: flex-start;
}

.message-content {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

.user-message .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 6px;
}

.bot-message .message-content {
    background: white;
    color: #1f2937;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.admin-message .message-content {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
    border-bottom-left-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}



.message-text {
    margin: 0;
}

.message-text a {
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
}

.message-text a:hover {
    text-decoration: underline;
}

.bot-message .message-text a {
    color: #667eea;
}

.bot-message .message-text a:hover {
    color: #5a67d8;
}

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

.user-message .message-time {
    text-align: right;
}

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

/* User Information Form Styles */
.user-form-header {
    margin-bottom: 10px;
    text-align: center;
}

.user-form-header h4 {
    margin: 0 0 8px 0;
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
}

.user-form-header p {
    margin: 0;
    font-size: 13px;
    color: #6b7280;
    line-height: 1.4;
}

.user-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

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

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

.form-group input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

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

.user-form-submit-btn {
    width: 100%;
    padding: 12px 20px;
    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;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 4px;
}

.user-form-submit-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.user-form-submit-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.loading-spinner {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.form-error {
    background: #fef2f2;
    color: #dc2626;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 12px;
    border: 1px solid #fecaca;
    animation: errorSlideIn 0.3s ease-out;
}

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

/* Chat Input */
.chat-input {
    padding: 20px;
    background: white;
    border-top: 1px solid #e5e7eb;
}

.input-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f9fafb;
    border: 2px solid #e5e7eb;
    border-radius: 24px;
    padding: 4px;
    transition: all 0.2s ease;
}

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

#user-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 12px 16px;
    font-size: 14px;
    outline: none;
    color: #1f2937;
}

#user-input::placeholder {
    color: #9ca3af;
}

#send-btn {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

#send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

#send-btn:active {
    transform: scale(0.95);
}

/* Responsive Design */
@media (max-width: 480px) {
    .saan-chat-widget {
        bottom: 20px;
        right: 20px;
    }
    
    .chat-container {
        width: calc(100vw - 40px);
        height: calc(100vh - 120px);
        bottom: 80px !important;
        right: 0;
        border-radius: 12px;
    }
    
    .chat-button {
        width: 50px;
        height: 50px;
    }
    
    .chat-icon {
        font-size: 20px;
    }
    
    .chat-tooltip {
        display: none;
    }
}

/* Scrollbar Styling */
.chat-messages::-webkit-scrollbar {
    width: 4px;
}

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

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

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

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 18px;
    border-bottom-left-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    max-width: 80px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: #9ca3af;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

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

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

/* Chat Footer */
.chat-footer {
    padding: 12px 20px;
    background: #f8fafc;
    border-top: 1px solid #e5e7eb;
    text-align: center;
}

.synctech-branding {
    font-size: 11px;
    color: #6b7280;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.synctech-branding span {
    opacity: 0.7;
}

.synctech-branding a {
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
}

.synctech-branding a:hover {
    text-decoration: underline;
}

.info-form {
    width: 150% !important; 
}

.entry-opt-main {
    width: 100% !important;
    margin: auto !important;
}

.leave-a-msg-form {
    gap: 0px !important;
}

.order-tracking-result {
    width: 100% !important;
    margin: auto !important;
}

.order-id-form {
    width: 100% !important;
    margin: auto !important;
}

.info-form {
    width: 100% !important;
    margin: auto !important;
}