/* WhatsApp Bot Frontend Styles - Enhanced UI */

:root {
    --wa-primary: #25D366;
    --wa-primary-dark: #128C7E;
    --wa-primary-light: #34E877;
    --wa-secondary: #075E54;
    --wa-accent: #00A884;
    --wa-text-dark: #111B21;
    --wa-text-light: #667781;
    --wa-bg-light: #F0F2F5;
    --wa-white: #FFFFFF;
    --wa-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --wa-shadow-md: 0 4px 16px rgba(0, 0, 0, 0.12);
    --wa-shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.16);
    --wa-shadow-xl: 0 12px 48px rgba(0, 0, 0, 0.24);
}

.wa-widget {
    position: fixed !important;
    bottom: 24px;
    z-index: 999999 !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.wa-widget-right { right: 24px; }
.wa-widget-left { left: 24px; }

/* Override any theme styles */
body .wa-widget,
html .wa-widget {
    position: fixed !important;
    z-index: 999999 !important;
}

.wa-widget-toggle {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    background: linear-gradient(135deg, var(--wa-primary) 0%, var(--wa-accent) 100%);
    box-shadow: var(--wa-shadow-lg), 0 0 0 0 rgba(37, 211, 102, 0.7);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    animation: pulse-ring 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.wa-widget-toggle:hover {
    transform: scale(1.08) translateY(-2px);
    box-shadow: var(--wa-shadow-xl), 0 0 0 8px rgba(37, 211, 102, 0.15);
    animation: none;
}

.wa-widget-toggle::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--wa-primary-light), var(--wa-primary));
    opacity: 0;
    transition: opacity 0.4s;
    z-index: -1;
}

.wa-widget-toggle:hover::before {
    opacity: 1;
}

@keyframes pulse-ring {
    0% {
        box-shadow: var(--wa-shadow-lg), 0 0 0 0 rgba(37, 211, 102, 0.7);
    }
    50% {
        box-shadow: var(--wa-shadow-lg), 0 0 0 10px rgba(37, 211, 102, 0);
    }
    100% {
        box-shadow: var(--wa-shadow-lg), 0 0 0 0 rgba(37, 211, 102, 0);
    }
}

.wa-widget-status {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background-color: #ff4444;
    border: 3px solid var(--wa-white);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    animation: blink 2s ease-in-out infinite;
}

.wa-widget-status.online {
    background-color: #4CAF50;
    animation: none;
}

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

.wa-widget-chat {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 380px;
    height: 580px;
    max-height: calc(100vh - 140px);
    background: var(--wa-white);
    border-radius: 20px;
    box-shadow: var(--wa-shadow-xl);
    display: none;
    flex-direction: column;
    overflow: hidden;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 0, 0, 0.08);
    z-index: 999998;
}

.wa-widget-left .wa-widget-chat {
    left: 24px;
    right: auto;
}

.wa-widget-header {
    background: linear-gradient(135deg, var(--wa-primary) 0%, var(--wa-accent) 100%);
    color: white;
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    position: relative;
}

.wa-widget-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100%;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.1) 0%, transparent 100%);
    pointer-events: none;
}

.wa-widget-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.wa-widget-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.wa-widget-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.wa-widget-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: linear-gradient(to bottom, var(--wa-bg-light) 0%, #FFFFFF 100%);
    background-attachment: fixed;
}

.wa-widget-body::-webkit-scrollbar {
    width: 6px;
}

.wa-widget-body::-webkit-scrollbar-track {
    background: transparent;
}

.wa-widget-body::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
}

.wa-widget-body::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

.wa-chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    scroll-behavior: smooth;
    display: flex;
    flex-direction: column;
}

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

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

.wa-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
}

.wa-chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

.wa-message {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    animation: slideIn 0.3s ease-out;
}

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

.wa-message-bot .wa-message-content {
    background: linear-gradient(135deg, #FFFFFF 0%, #F8F9FA 100%);
    padding: 14px 18px;
    border-radius: 18px 18px 18px 4px;
    align-self: flex-start;
    max-width: 80%;
    box-shadow: var(--wa-shadow-sm);
    border: 1px solid rgba(0, 0, 0, 0.05);
    color: var(--wa-text-dark);
    line-height: 1.5;
    position: relative;
}

.wa-message-bot .wa-message-content::before {
    content: '';
    position: absolute;
    left: -6px;
    bottom: 4px;
    width: 12px;
    height: 12px;
    background: linear-gradient(135deg, #FFFFFF 0%, #F8F9FA 100%);
    border-radius: 0 0 0 2px;
    transform: rotate(0deg) skewX(-10deg);
}

.wa-message-user .wa-message-content {
    background: linear-gradient(135deg, var(--wa-primary) 0%, var(--wa-accent) 100%);
    color: white;
    padding: 14px 18px;
    border-radius: 18px 18px 4px 18px;
    align-self: flex-end;
    max-width: 80%;
    box-shadow: var(--wa-shadow-md);
    line-height: 1.5;
    position: relative;
}

.wa-message-user .wa-message-content::before {
    content: '';
    position: absolute;
    right: -6px;
    bottom: 4px;
    width: 12px;
    height: 12px;
    background: linear-gradient(135deg, var(--wa-primary) 0%, var(--wa-accent) 100%);
    border-radius: 0 0 2px 0;
    transform: rotate(0deg) skewX(10deg);
}

.wa-message-time {
    font-size: 11px;
    color: var(--wa-text-light);
    margin-top: 6px;
    text-align: right;
    font-weight: 500;
    opacity: 0.7;
}

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

.wa-offline-message {
    text-align: center;
    color: var(--wa-text-light);
    font-style: italic;
    padding: 16px;
    background: rgba(255, 193, 7, 0.1);
    border-radius: 12px;
    border: 1px dashed rgba(255, 193, 7, 0.3);
}

.wa-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 0 20px 10px 20px;
    flex-shrink: 0;
}

.wa-quick-reply-btn {
    background: linear-gradient(135deg, #FFFFFF 0%, var(--wa-bg-light) 100%);
    border: 1px solid rgba(37, 211, 102, 0.3);
    padding: 10px 16px;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--wa-primary);
    font-weight: 500;
    box-shadow: var(--wa-shadow-sm);
}

.wa-quick-reply-btn:hover {
    background: linear-gradient(135deg, var(--wa-primary) 0%, var(--wa-accent) 100%);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--wa-shadow-md);
    border-color: transparent;
}

.wa-message-input-container {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 16px 20px;
    background: var(--wa-white);
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    flex-shrink: 0;
}

#wa-message-input {
    flex: 1;
    padding: 14px 20px;
    border: 2px solid rgba(0, 0, 0, 0.08);
    border-radius: 25px;
    outline: none;
    font-size: 15px;
    transition: all 0.3s ease;
    background: var(--wa-white);
}

#wa-message-input:focus {
    border-color: var(--wa-primary);
    box-shadow: 0 0 0 4px rgba(37, 211, 102, 0.1);
}

#wa-send-message {
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--wa-primary) 0%, var(--wa-accent) 100%);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--wa-shadow-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

#wa-send-message:hover {
    transform: scale(1.08);
    box-shadow: var(--wa-shadow-lg);
}

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

.wa-widget-footer {
    padding: 18px 24px;
    background: linear-gradient(to top, rgba(240, 242, 245, 0.8) 0%, transparent 100%);
    text-align: center;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    flex-shrink: 0;
}

.wa-start-whatsapp {
    color: var(--wa-primary);
    text-decoration: none;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    padding: 8px 16px;
    border-radius: 8px;
}

.wa-start-whatsapp:hover {
    background: rgba(37, 211, 102, 0.1);
    transform: translateY(-1px);
}

/* Responsive Design for All Devices */

/* Large Desktop (1920px+) */
@media (min-width: 1920px) {
    .wa-widget-chat {
        width: 420px;
        height: 640px;
    }
}

/* Desktop (1200px - 1919px) */
@media (min-width: 1200px) and (max-width: 1919px) {
    .wa-widget-chat {
        width: 400px;
        height: 600px;
    }
}

/* Laptop/Tablet Landscape (992px - 1199px) */
@media (min-width: 992px) and (max-width: 1199px) {
    .wa-widget-chat {
        width: 380px;
        height: 560px;
    }
}

/* Tablet Portrait (768px - 991px) */
@media (min-width: 768px) and (max-width: 991px) {
    .wa-widget {
        bottom: 20px;
    }
    
    .wa-widget-right { right: 20px; }
    .wa-widget-left { left: 20px; }
    
    .wa-widget-chat {
        width: 360px;
        height: 520px;
        bottom: 90px;
        right: 20px;
    }
    
    .wa-widget-left .wa-widget-chat {
        left: 20px;
        right: auto;
    }
    
    .wa-widget-toggle {
        width: 60px;
        height: 60px;
    }
    
    .wa-widget-header h3 {
        font-size: 17px;
    }
    
    .wa-message-content {
        font-size: 14px;
    }
}

/* Mobile Landscape (576px - 767px) */
@media (min-width: 576px) and (max-width: 767px) {
    .wa-widget {
        bottom: 16px;
    }
    
    .wa-widget-right { right: 16px; }
    .wa-widget-left { left: 16px; }
    
    .wa-widget-chat {
        width: 100vw !important;
        height: 100vh !important;
        max-height: 100vh !important;
        bottom: 0 !important;
        right: 0 !important;
        left: 0 !important;
        top: 0 !important;
        border-radius: 0 !important;
        position: fixed !important;
        transform: none !important;
    }
    
    .wa-widget-left .wa-widget-chat,
    .wa-widget-right .wa-widget-chat {
        width: 100vw !important;
        height: 100vh !important;
        bottom: 0 !important;
        right: 0 !important;
        left: 0 !important;
        top: 0 !important;
    }
    
    .wa-chat-messages {
        padding: 16px;
    }
    
    .wa-widget-toggle {
        width: 56px;
        height: 56px;
    }
    
    .wa-widget-header {
        padding: 16px 20px;
    }
    
    .wa-widget-header h3 {
        font-size: 16px;
    }
    
    .wa-widget-body {
        padding: 16px;
    }
    
    .wa-message-bot .wa-message-content,
    .wa-message-user .wa-message-content {
        max-width: 85%;
        padding: 12px 16px;
        font-size: 14px;
    }
    
    #wa-message-input {
        padding: 12px 16px;
        font-size: 14px;
    }
    
    #wa-send-message {
        width: 44px;
        height: 44px;
        font-size: 18px;
    }
}

/* Mobile Portrait (up to 575px) */
@media (max-width: 575px) {
    .wa-widget {
        bottom: 12px;
    }
    
    .wa-widget-right { right: 12px; }
    .wa-widget-left { left: 12px; }
    
    .wa-widget-chat {
        width: 100vw !important;
        height: 100vh !important;
        max-height: 100vh !important;
        bottom: 0 !important;
        right: 0 !important;
        left: 0 !important;
        top: 0 !important;
        border-radius: 0 !important;
        position: fixed !important;
        transform: none !important;
    }
    
    .wa-chat-messages {
        padding: 12px;
    }
    
    .wa-widget-toggle {
        width: 54px;
        height: 54px;
    }
    
    .wa-widget-header {
        padding: 14px 16px;
        border-radius: 0;
    }
    
    .wa-widget-header h3 {
        font-size: 16px;
        gap: 8px;
    }
    
    .wa-widget-close {
        width: 32px;
        height: 32px;
        font-size: 20px;
    }
    
    .wa-widget-body {
        padding: 12px;
    }
    
    .wa-message {
        margin-bottom: 12px;
    }
    
    .wa-message-bot .wa-message-content,
    .wa-message-user .wa-message-content {
        max-width: 90%;
        padding: 10px 14px;
        font-size: 14px;
        border-radius: 16px 16px 16px 4px;
    }
    
    .wa-message-user .wa-message-content {
        border-radius: 16px 16px 4px 16px;
    }
    
    .wa-message-time {
        font-size: 10px;
        margin-top: 4px;
    }
    
    .wa-quick-replies {
        gap: 8px;
        margin-bottom: 16px;
    }
    
    .wa-quick-reply-btn {
        padding: 8px 14px;
        font-size: 13px;
        border-radius: 16px;
    }
    
    .wa-message-input-container {
        gap: 8px;
    }
    
    #wa-message-input {
        padding: 10px 14px;
        font-size: 14px;
        border-radius: 20px;
    }
    
    #wa-send-message {
        width: 42px;
        height: 42px;
        font-size: 16px;
    }
    
    .wa-widget-footer {
        padding: 12px 16px;
    }
    
    .wa-start-whatsapp {
        font-size: 13px;
        padding: 6px 12px;
    }
    
    /* Phone Registration on Mobile */
    .wa-phone-registration {
        padding: 24px 16px;
    }
    
    .wa-phone-registration::before {
        font-size: 48px;
        margin-bottom: 16px;
    }
    
    .wa-registration-message {
        font-size: 15px;
        margin-bottom: 20px;
    }
    
    .wa-phone-input,
    .wa-phone-submit {
        padding: 12px 16px;
        font-size: 15px;
    }
}

/* Extra Small Mobile (up to 374px) */
@media (max-width: 374px) {
    .wa-widget-toggle {
        width: 50px;
        height: 50px;
    }
    
    .wa-widget-header h3 {
        font-size: 15px;
    }
    
    .wa-message-bot .wa-message-content,
    .wa-message-user .wa-message-content {
        font-size: 13px;
        padding: 9px 12px;
    }
    
    .wa-quick-reply-btn {
        padding: 7px 12px;
        font-size: 12px;
    }
    
    #wa-message-input {
        padding: 9px 12px;
        font-size: 13px;
    }
    
    #wa-send-message {
        width: 38px;
        height: 38px;
        font-size: 15px;
    }
}

/* Landscape Orientation Adjustments */
@media (max-height: 500px) and (orientation: landscape) {
    .wa-widget-chat {
        height: calc(100vh - 60px);
        bottom: 50px;
    }
    
    .wa-widget-header {
        padding: 10px 16px;
    }
    
    .wa-widget-header h3 {
        font-size: 15px;
    }
    
    .wa-widget-body {
        padding: 10px;
    }
    
    .wa-message {
        margin-bottom: 8px;
    }
    
    .wa-widget-footer {
        padding: 10px 16px;
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    .wa-widget-toggle,
    .wa-quick-reply-btn,
    #wa-send-message,
    .wa-widget-close {
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }
    
    /* Larger touch targets */
    .wa-widget-toggle {
        min-width: 54px;
        min-height: 54px;
    }
    
    .wa-widget-close {
        min-width: 36px;
        min-height: 36px;
    }
    
    #wa-send-message {
        min-width: 42px;
        min-height: 42px;
    }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .wa-widget-toggle,
    .wa-message-content {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

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

/* Animation for widget appearance */
@keyframes wa-fadeIn {
    from { 
        opacity: 0; 
        transform: translateY(20px) scale(0.95);
    }
    to { 
        opacity: 1; 
        transform: translateY(0) scale(1);
    }
}

.wa-widget-chat.show {
    display: flex;
    animation: wa-fadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Phone Registration */
.wa-phone-registration {
    padding: 40px 24px;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
}

.wa-phone-registration::before {
    content: '💬';
    font-size: 64px;
    display: block;
    margin-bottom: 20px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.wa-registration-message {
    font-size: 17px;
    color: var(--wa-text-dark);
    margin-bottom: 28px;
    line-height: 1.6;
    font-weight: 500;
}

.wa-registration-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.wa-phone-input {
    width: 100%;
    padding: 16px 20px;
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    font-size: 16px;
    transition: all 0.3s ease;
    box-shadow: var(--wa-shadow-sm);
    background: var(--wa-white);
}

.wa-phone-input:focus {
    outline: none;
    border-color: var(--wa-primary);
    box-shadow: 0 0 0 4px rgba(37, 211, 102, 0.1), var(--wa-shadow-md);
    transform: translateY(-2px);
}

.wa-phone-submit {
    width: 100%;
    padding: 16px 24px;
    background: linear-gradient(135deg, var(--wa-primary) 0%, var(--wa-accent) 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--wa-shadow-md);
    position: relative;
    overflow: hidden;
}

.wa-phone-submit::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.wa-phone-submit:hover::before {
    width: 300px;
    height: 300px;
}

.wa-phone-submit:hover {
    transform: translateY(-2px);
    box-shadow: var(--wa-shadow-lg);
}

.wa-phone-submit:active {
    transform: translateY(0);
}

.wa-registration-error {
    color: #d32f2f;
    font-size: 14px;
    margin-top: 12px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #ffebee 0%, #ffcdd2 100%);
    border-radius: 10px;
    border: 1px solid rgba(211, 47, 47, 0.2);
    animation: shake 0.5s ease-in-out;
}

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

/* Typing indicator */
.wa-typing-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 14px 18px;
    background: linear-gradient(135deg, #FFFFFF 0%, #F8F9FA 100%);
    border-radius: 18px 18px 18px 4px;
    align-self: flex-start;
    max-width: 80px;
    margin-bottom: 16px;
    box-shadow: var(--wa-shadow-sm);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.wa-typing-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--wa-primary) 0%, var(--wa-accent) 100%);
    animation: wa-typing 1.4s infinite ease-in-out;
}

.wa-typing-dot:nth-child(1) { animation-delay: 0s; }
.wa-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.wa-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes wa-typing {
    0%, 60%, 100% { 
        transform: scale(0.8) translateY(0); 
        opacity: 0.5; 
    }
    30% { 
        transform: scale(1.1) translateY(-5px); 
        opacity: 1; 
    }
}
