/* Unique Chat Assistant Styles */
#plant-chat-widget {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 9999;
    font-family: 'Poppins', sans-serif;
}

.chat-toggle-btn {
    width: auto;
    height: 64px;
    padding: 0 20px;
    border-radius: 20px;
    background: linear-gradient(135deg, #00b09b, #96c93d);
    color: white;
    border: none;
    box-shadow: 0 8px 24px rgba(0, 176, 155, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.chat-toggle-btn:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 12px 30px rgba(0, 176, 155, 0.5);
}

.chat-window {
    position: absolute;
    bottom: 90px;
    right: 0;
    width: 360px;
    height: 550px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 24px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.5);
    transform-origin: bottom right;
    transition: all 0.4s cubic-bezier(0.19, 1, 0.22, 1);
}

.chat-window.active {
    display: flex;
    animation: bounceIn 0.5s;
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.5);
    }

    80% {
        transform: scale(1.05);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.chat-header {
    background: linear-gradient(135deg, #11998e, #38ef7d);
    color: white;
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-header h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-close-chat {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0;
}

.btn-close-chat:hover {
    color: white;
}

.chat-messages {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

.message {
    max-width: 85%;
    padding: 12px 18px;
    border-radius: 18px;
    font-size: 0.95rem;
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.message.bot {
    align-self: flex-start;
    background: white;
    color: #333;
    border-bottom-left-radius: 4px;
}

.message.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #11998e, #38ef7d);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.bot.typing::after {
    content: '...';
    animation: typing 1.5s infinite;
}

@keyframes typing {
    0% {
        content: '.';
    }

    33% {
        content: '..';
    }

    66% {
        content: '...';
    }
}

.chat-input-area {
    padding: 15px;
    background: white;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
}

.chat-input-area input {
    flex: 1;
    border: 1px solid #e0e0e0;
    border-radius: 25px;
    padding: 10px 15px;
    outline: none;
    font-family: inherit;
    font-size: 0.9rem;
    transition: border-color 0.2s;
}

.chat-input-area input:focus {
    border-color: #2e7d32;
}

.chat-send-btn {
    background: #2e7d32;
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.chat-send-btn:hover {
    background: #1b5e20;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .chat-window {
        width: 100%;
        height: 100%;
        height: 100dvh;
        /* Dynamic viewport height for modern browsers */
        bottom: 0;
        right: 0;
        border-radius: 0;
        position: fixed;
        z-index: 10000;
        display: none;
        /* Keep hidden by default */
        flex-direction: column;
    }

    .chat-window.active {
        display: flex;
    }

    .chat-messages {
        flex: 1;
        height: auto;
    }

    .chat-input-area {
        padding-bottom: max(15px, env(safe-area-inset-bottom));
    }

    #plant-chat-widget {
        bottom: 20px;
        right: 20px;
    }
}

/* AR Overlay Styles */
.ar-overlay {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.chat-toggle-btn:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 12px 30px rgba(0, 176, 155, 0.5);
}

.chat-window {
    position: absolute;
    bottom: 90px;
    right: 0;
    width: 360px;
    height: 550px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 24px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.5);
    transform-origin: bottom right;
    transition: all 0.4s cubic-bezier(0.19, 1, 0.22, 1);
}

.chat-window.active {
    display: flex;
    animation: bounceIn 0.5s;
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.5);
    }

    80% {
        transform: scale(1.05);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.chat-header {
    background: linear-gradient(135deg, #11998e, #38ef7d);
    color: white;
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-header h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-close-chat {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0;
}

.btn-close-chat:hover {
    color: white;
}

.chat-messages {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

.message {
    max-width: 85%;
    padding: 12px 18px;
    border-radius: 18px;
    font-size: 0.95rem;
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.message.bot {
    align-self: flex-start;
    background: white;
    color: #333;
    border-bottom-left-radius: 4px;
}

.message.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #11998e, #38ef7d);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.bot.typing::after {
    content: '...';
    animation: typing 1.5s infinite;
}

@keyframes typing {
    0% {
        content: '.';
    }

    33% {
        content: '..';
    }

    66% {
        content: '...';
    }
}

.chat-input-area {
    padding: 15px;
    background: white;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
}

.chat-input-area input {
    flex: 1;
    border: 1px solid #e0e0e0;
    border-radius: 25px;
    padding: 10px 15px;
    outline: none;
    font-family: inherit;
    font-size: 0.9rem;
    transition: border-color 0.2s;
}

.chat-input-area input:focus {
    border-color: #2e7d32;
}

.chat-send-btn {
    background: #2e7d32;
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.chat-send-btn:hover {
    background: #1b5e20;
}

/* Mobile responsive */
@media (max-width: 480px) {
    .chat-window {
        width: 100%;
        height: 100%;
        bottom: 0;
        right: 0;
        border-radius: 0;
        position: fixed;
        z-index: 10000;
    }
}

/* AR Overlay Styles */
.ar-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    text-align: center;
    display: none;
    /* Hidden by default */
    z-index: 10;
    width: 100%;
    height: 100%;
}

.ar-label {
    position: absolute;
    top: 60%;
    /* Position slightly below center */
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    padding: 12px 24px;
    border-radius: 16px;
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    font-size: 1.4rem;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    animation: fadeInUp 0.5s ease-out;
}

.ar-reticle {
    width: 250px;
    height: 250px;
    border: 2px solid rgba(255, 255, 255, 0.8);
    border-radius: 20px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.3);
    /* Dim background */
}

.ar-reticle::after {
    content: '';
    position: absolute;
    top: -10px;
    left: -10px;
    right: -10px;
    bottom: -10px;
    border: 2px dashed rgba(255, 255, 255, 0.4);
    border-radius: 24px;
    animation: spin 10s linear infinite;
}

@keyframes spin {
    100% {
        transform: rotate(360deg);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translate(-50%, 20px);
    }

    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}