/* La Luz Kids Chatbot Styles */

/* Accessibility */
.screen-reader-text {
    border: 0;
    clip: rect(1px, 1px, 1px, 1px);
    clip-path: inset(50%);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
    word-wrap: normal !important;
}

/* Main Container */
#laluz-chatbot-container {
    position: fixed;
    z-index: 999999;
    font-family: 'Helvetica', Arial, sans-serif;
}

#laluz-chatbot-container.laluz-chatbot-bottom-right {
    bottom: 20px;
    right: 20px;
}

#laluz-chatbot-container.laluz-chatbot-bottom-left {
    bottom: 20px;
    left: 20px;
}

/* Toggle Button */
.laluz-chatbot-toggle {
    position: relative;
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #8e6448 0%, #ad8662 100%);
    border-radius: 50%;
    border: 3px solid #ffffff;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(142, 100, 72, 0.3);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: laluz-chatbot-bounce 2s infinite;
    padding: 0;
    outline: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.laluz-chatbot-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(142, 100, 72, 0.4);
}

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

.laluz-chatbot-toggle.active {
    animation: none;
}

.laluz-chatbot-mascot {
    width: 55px;
    height: 55px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

/* Notification Badge */
.laluz-chatbot-notification {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4444;
    color: white;
    border-radius: 50%;
    width: 25px;
    height: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    border: 2px solid white;
    animation: laluz-chatbot-pulse 1.5s infinite;
}

/* Chatbot Window */
.laluz-chatbot-window {
    position: absolute;
    bottom: 100px;
    right: 0;
    width: 350px;
    height: 500px;
    max-height: 500px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 2px solid #8e6448;
}

.laluz-chatbot-window.show {
    display: flex !important;
}

.laluz-chatbot-bottom-left .laluz-chatbot-window {
    right: auto;
    left: 0;
}

/* Header */
.laluz-chatbot-header {
    background: linear-gradient(135deg, #e4d7ce 0%, #e4d7ce 100%) !important;
    color: #000000 !important;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.laluz-chatbot-header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
    object-fit: cover;
}

.laluz-chatbot-header-info h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 500;
}

.laluz-chatbot-status {
    font-size: 12px;
    opacity: 0.8;
    display: flex;
    align-items: center;
    gap: 5px;
}

.laluz-chatbot-status::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #4CAF50;
    border-radius: 50%;
    display: inline-block;
}

.laluz-chatbot-close {
    background: none;
    border: none;
    color: #000000;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.3s ease;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.laluz-chatbot-close:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

/* Messages Container */
.laluz-chatbot-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto !important;
    overflow-x: hidden;
    background: #ffffff !important;
    display: flex;
    flex-direction: column;
    gap: 15px;
    height: auto;
    min-height: 0;
    position: relative;
}

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

.laluz-chatbot-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

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

.laluz-chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #553f2d;
}

/* Messages */
.laluz-chatbot-message {
    display: flex;
    flex-direction: column;
    max-width: 80%;
    animation: laluz-chatbot-message-in 0.3s ease;
}

.laluz-chatbot-bot-message {
    align-self: flex-start;
}

.laluz-chatbot-user-message {
    align-self: flex-end;
}

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

.laluz-chatbot-message-content a {
    color: #8e6448;
    font-weight: 600;
    text-decoration: none;
    border-bottom: 1px solid #8e6448;
    transition: all 0.2s ease;
    display: inline-block;
    margin-top: 8px;
}

.laluz-chatbot-message-content a:hover {
    color: #553f2d;
    border-bottom-color: #553f2d;
    transform: translateX(2px);
}

.laluz-chatbot-message-content a:focus {
    outline: 2px solid #8e6448;
    outline-offset: 2px;
    border-radius: 2px;
}

.laluz-chatbot-bot-message .laluz-chatbot-message-content {
    background: #e4d7ce !important;
    color: #000000 !important;
    border: 1px solid #8e6448;
    border-bottom-left-radius: 6px;
}

.laluz-chatbot-user-message .laluz-chatbot-message-content {
    background: linear-gradient(135deg, #8e6448 0%, #ad8662 100%);
    color: white;
    border-bottom-right-radius: 6px;
}

.laluz-chatbot-timestamp {
    font-size: 11px;
    opacity: 0.6;
    margin-top: 4px;
    margin-left: 16px;
    color: #553f2d;
}

.laluz-chatbot-user-message .laluz-chatbot-timestamp {
    text-align: right;
    margin-left: 0;
    margin-right: 16px;
    color: #553f2d;
}

/* Suggestions */
.laluz-chatbot-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.laluz-chatbot-suggestion {
    background: linear-gradient(135deg, #e6c8a4 0%, #ccab8a 100%);
    color: #553f2d;
    border: none;
    border-radius: 20px;
    padding: 8px 12px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid #ccab8a;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.laluz-chatbot-suggestion:hover {
    background: linear-gradient(135deg, #8e6448 0%, #ad8662 100%);
    color: white;
    transform: translateY(-1px);
}

/* Input Area */
.laluz-chatbot-input-area {
    padding: 20px;
    background: white !important;
    border-top: 1px solid #e6c8a4;
    flex-shrink: 0;
    position: relative;
    z-index: 10;
}

.laluz-chatbot-input-container {
    display: flex;
    gap: 10px;
    align-items: center;
}

#laluz-chatbot-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e6c8a4;
    border-radius: 25px;
    font-size: 14px;
    outline: none;
    background: #f9f8f7;
    color: #553f2d;
    transition: border-color 0.3s ease;
}

#laluz-chatbot-input:focus {
    border-color: #8e6448;
    background: white;
}

#laluz-chatbot-input::placeholder {
    color: #a29f95;
}

.laluz-chatbot-send-btn {
    width: 45px;
    height: 45px;
    background: linear-gradient(135deg, #8e6448 0%, #ad8662 100%);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(142, 100, 72, 0.3);
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.laluz-chatbot-send-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(142, 100, 72, 0.4);
}

.laluz-chatbot-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Typing Indicator */
.laluz-chatbot-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    color: #a29f95;
    font-size: 12px;
}

.laluz-chatbot-typing span {
    width: 6px;
    height: 6px;
    background: #8e6448;
    border-radius: 50%;
    animation: laluz-chatbot-typing-dot 1.4s infinite;
}

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

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

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

@keyframes laluz-chatbot-pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

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

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

/* Tablet Responsiveness (Portrait) */
@media (max-width: 1024px) and (min-width: 769px) {
    .laluz-chatbot-window {
        width: 400px;
        height: 550px;
        max-height: calc(100vh - 150px);
    }
    
    .laluz-chatbot-toggle {
        width: 75px;
        height: 75px;
    }
    
    .laluz-chatbot-mascot {
        width: 50px;
        height: 50px;
    }
    
    #laluz-chatbot-input {
        font-size: 15px;
        padding: 13px 18px;
    }
    
    .laluz-chatbot-send-btn {
        width: 48px;
        height: 48px;
    }
    
    .laluz-chatbot-message-content {
        font-size: 15px;
    }
}

/* Mobile Landscape */
@media (max-width: 915px) and (max-height: 430px) and (orientation: landscape) {
    .laluz-chatbot-window {
        width: 380px;
        height: calc(100vh - 90px);
        max-height: calc(100vh - 90px);
        bottom: 80px;
    }
    
    .laluz-chatbot-toggle {
        width: 60px;
        height: 60px;
    }
    
    .laluz-chatbot-mascot {
        width: 40px;
        height: 40px;
    }
    
    .laluz-chatbot-header {
        padding: 10px 15px;
    }
    
    .laluz-chatbot-messages {
        padding: 12px;
    }
    
    .laluz-chatbot-input-area {
        padding: 12px;
    }
}

/* Mobile Portrait (768px and below) */
@media (max-width: 768px) {
    #laluz-chatbot-container.laluz-chatbot-bottom-right,
    #laluz-chatbot-container.laluz-chatbot-bottom-left {
        bottom: 15px;
        right: 15px;
        left: auto;
    }
    
    .laluz-chatbot-window {
        width: calc(100vw - 30px);
        height: calc(100vh - 120px);
        height: calc(100dvh - 120px); /* Dynamic viewport height for mobile browsers */
        max-height: 550px;
        bottom: 95px;
        right: 0;
        left: auto;
    }
    
    .laluz-chatbot-toggle {
        width: 70px;
        height: 70px;
        /* Better tap target */
    }
    
    .laluz-chatbot-mascot {
        width: 45px;
        height: 45px;
    }
    
    /* Larger close button for easier tapping */
    .laluz-chatbot-close {
        width: 40px;
        height: 40px;
        font-size: 28px;
    }
    
    /* Better touch targets for suggestions */
    .laluz-chatbot-suggestion {
        padding: 12px 16px;
        font-size: 14px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        text-align: center;
    }
    
    .laluz-chatbot-suggestions {
        flex-direction: column;
        gap: 10px;
    }
    
    /* Larger send button for touch */
    .laluz-chatbot-send-btn {
        width: 50px;
        height: 50px;
        flex-shrink: 0;
    }
    
    /* Better input sizing */
    #laluz-chatbot-input {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 14px 18px;
        min-height: 50px;
    }
    
    /* Larger message text */
    .laluz-chatbot-message-content {
        font-size: 15px;
        line-height: 1.5;
        padding: 14px 18px;
    }
    
    /* Better link tap targets */
    .laluz-chatbot-message-content a {
        padding: 4px 0;
        margin-top: 10px;
        display: block;
        font-size: 15px;
    }
    
    .laluz-chatbot-message {
        max-width: 85%;
    }
    
    /* Improved header for mobile */
    .laluz-chatbot-header-info h4 {
        font-size: 17px;
    }
    
    .laluz-chatbot-status {
        font-size: 13px;
    }
    
    /* Better timestamp visibility */
    .laluz-chatbot-timestamp {
        font-size: 12px;
    }
}

/* Small Mobile (480px and below) */
@media (max-width: 480px) {
    #laluz-chatbot-container.laluz-chatbot-bottom-right,
    #laluz-chatbot-container.laluz-chatbot-bottom-left {
        bottom: 10px;
        right: 10px;
        left: 10px;
    }
    
    .laluz-chatbot-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        height: calc(100dvh - 100px);
        max-height: calc(100vh - 100px);
        max-height: calc(100dvh - 100px);
        bottom: 85px;
        right: 10px;
        left: 10px;
        margin: 0 auto;
        border-radius: 12px;
    }
    
    .laluz-chatbot-toggle {
        width: 65px;
        height: 65px;
    }
    
    .laluz-chatbot-mascot {
        width: 42px;
        height: 42px;
    }
    
    .laluz-chatbot-messages {
        padding: 12px;
    }
    
    .laluz-chatbot-input-area {
        padding: 12px;
    }
    
    .laluz-chatbot-header {
        padding: 12px 15px;
    }
    
    .laluz-chatbot-header-avatar {
        width: 36px;
        height: 36px;
    }
    
    .laluz-chatbot-header-info h4 {
        font-size: 16px;
    }
    
    .laluz-chatbot-status {
        font-size: 12px;
    }
    
    /* Even larger input on small screens */
    #laluz-chatbot-input {
        font-size: 16px;
        padding: 15px 18px;
        border-width: 2px;
    }
    
    .laluz-chatbot-message {
        max-width: 90%;
    }
    
    .laluz-chatbot-message-content {
        font-size: 14px;
        padding: 12px 16px;
    }
}

/* Very Small Screens (360px and below) */
@media (max-width: 360px) {
    .laluz-chatbot-window {
        width: calc(100vw - 16px);
        border-radius: 10px;
    }
    
    .laluz-chatbot-toggle {
        width: 60px;
        height: 60px;
    }
    
    .laluz-chatbot-mascot {
        width: 38px;
        height: 38px;
    }
    
    .laluz-chatbot-messages {
        padding: 10px;
    }
    
    .laluz-chatbot-input-area {
        padding: 10px;
    }
    
    .laluz-chatbot-header {
        padding: 10px 12px;
    }
    
    .laluz-chatbot-message-content {
        font-size: 14px;
        padding: 11px 14px;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Disable hover effects on touch devices */
    .laluz-chatbot-toggle:hover {
        transform: none;
    }
    
    .laluz-chatbot-send-btn:hover {
        transform: none;
    }
    
    .laluz-chatbot-suggestion:hover {
        transform: none;
    }
    
    /* Add active states instead */
    .laluz-chatbot-toggle:active {
        transform: scale(0.95);
    }
    
    .laluz-chatbot-send-btn:active {
        transform: scale(0.95);
    }
    
    .laluz-chatbot-suggestion:active {
        transform: scale(0.98);
        background: linear-gradient(135deg, #8e6448 0%, #ad8662 100%);
        color: white;
    }
    
    .laluz-chatbot-close:active {
        background-color: rgba(0, 0, 0, 0.2);
    }
    
    /* Better tap targets */
    .laluz-chatbot-message-content a {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        padding: 8px 4px;
    }
}

/* Safe area insets for notched devices */
@supports (padding: max(0px)) {
    .laluz-chatbot-window {
        padding-bottom: max(0px, env(safe-area-inset-bottom));
    }
    
    #laluz-chatbot-container {
        bottom: max(15px, env(safe-area-inset-bottom));
    }
    
    @media (max-width: 480px) {
        #laluz-chatbot-container {
            bottom: max(10px, calc(env(safe-area-inset-bottom) + 10px));
        }
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .laluz-chatbot-window {
        background: #2a2a2a;
        border-color: #8e6448;
    }
    
    .laluz-chatbot-messages {
        background: #1a1a1a !important;
    }
    
    .laluz-chatbot-bot-message .laluz-chatbot-message-content {
        background: #3a3a3a !important;
        color: #e6c8a4 !important;
        border-color: #8e6448;
    }
    
    .laluz-chatbot-bot-message .laluz-chatbot-message-content a {
        color: #e6c8a4;
        border-bottom-color: #e6c8a4;
    }
    
    .laluz-chatbot-bot-message .laluz-chatbot-message-content a:hover {
        color: #fff;
        border-bottom-color: #fff;
    }
    
    .laluz-chatbot-timestamp {
        color: #a29f95 !important;
    }
    
    .laluz-chatbot-input-area {
        background: #2a2a2a !important;
        border-top-color: #8e6448;
    }
    
    #laluz-chatbot-input {
        background: #333;
        color: #e6c8a4;
        border-color: #8e6448;
    }
    
    #laluz-chatbot-input:focus {
        background: #404040;
    }
    
    #laluz-chatbot-input::placeholder {
        color: #666;
    }
}

/* Custom scrollbar for Firefox */
.laluz-chatbot-messages {
    scrollbar-width: thin;
    scrollbar-color: #8e6448 #f1f1f1;
}

/* Loading state */
.laluz-chatbot-loading .laluz-chatbot-send-btn {
    opacity: 0.5;
    cursor: not-allowed;
}

.laluz-chatbot-loading #laluz-chatbot-input {
    pointer-events: none;
    opacity: 0.7;
}

/* Accessibility improvements */
.laluz-chatbot-toggle:focus,
.laluz-chatbot-close:focus,
.laluz-chatbot-send-btn:focus,
#laluz-chatbot-input:focus,
.laluz-chatbot-suggestion:focus {
    outline: 2px solid #8e6448;
    outline-offset: 2px;
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .laluz-chatbot-toggle,
    .laluz-chatbot-header {
        background: #553f2d;
    }
    
    .laluz-chatbot-send-btn {
        background: #553f2d;
    }
    
    .laluz-chatbot-window {
        border-width: 3px;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .laluz-chatbot-toggle {
        animation: none;
    }
    
    .laluz-chatbot-notification {
        animation: none;
    }
    
    * {
        transition: none !important;
        animation: none !important;
    }
}