/**
 * PremiumJane AI Sales Assistant - Multi-Screen Design
 * Version: 2.1.0
 * Color: #ffdf8d (PremiumJane Yellow)
 */

/* === GLOBAL === */
* {
    box-sizing: border-box;
}

/* === FLOATING BUTTON === */
#wp-chatbot-ai-wrapper {
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
    z-index: 999999 !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

.wp-chatbot-ai-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #ffdf8d;
    color: #000;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

.wp-chatbot-ai-button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.wp-chatbot-ai-button svg {
    width: 28px;
    height: 28px;
}

.wp-chatbot-ai-hidden {
    display: none !important;
}

/* === MAIN CHAT WINDOW === */
#wp-chatbot-ai-chat-window {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    z-index: 999999;
}

/* === SCREENS === */
.pj-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    background: #fff;
}

.pj-screen.pj-active {
    display: flex;
}

/* === HOME SCREEN === */
#pj-home-screen {
    background: linear-gradient(180deg, #ffdf8d 0%, #fff 50%);
}

.pj-home-header {
    text-align: center;
    padding: 60px 30px 40px;
}

.pj-logo {
    font-size: 64px;
    margin-bottom: 20px;
}

.pj-home-header h2 {
    margin: 0 0 10px 0;
    font-size: 24px;
    font-weight: 600;
    color: #000;
}

.pj-home-header p {
    margin: 0;
    font-size: 15px;
    color: #666;
}

.pj-home-body {
    flex: 1;
    padding: 0 30px;
}

.pj-home-btn {
    width: 100%;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 18px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    color: #000;
    transition: all 0.2s;
}

.pj-home-btn:hover {
    background: #ffdf8d;
    border-color: #ffdf8d;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 223, 141, 0.3);
}

.pj-home-btn span {
    flex: 1;
    text-align: left;
}

.pj-home-footer {
    padding: 20px 30px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.pj-footer-btn {
    background: transparent;
    border: none;
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
    font-size: 15px;
    color: #666;
    transition: color 0.2s;
}

.pj-footer-btn:hover {
    color: #000;
}

.pj-powered {
    text-align: center;
    font-size: 11px;
    color: #999;
}

.pj-close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #ffdf8d;
    border: none;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
}

.pj-close-btn:hover {
    opacity: 0.8;
}

/* === CONVERSATIONS SCREEN === */
.pj-conv-header {
    background: #ffdf8d;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    border-bottom: 1px solid #e0e0e0;
}

.pj-conv-header h3 {
    flex: 1;
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #000;
}

.pj-back-btn {
    background: transparent;
    border: none;
    padding: 5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000;
}

.pj-conv-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.pj-no-conv {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 60px 30px;
}

.pj-no-conv p {
    color: #999;
    font-size: 16px;
    margin: 20px 0;
}

.pj-new-conv-btn {
    background: #ffdf8d;
    color: #000;
    border: none;
    border-radius: 8px;
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.pj-new-conv-btn:hover {
    opacity: 0.9;
}

.pj-conv-item {
    background: #f8f8f8;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 2px solid transparent;
}

.pj-conv-item:hover {
    background: #ffdf8d;
}

.pj-conv-item.pj-conv-active {
    background: #ffdf8d;
    border-color: #000;
}

.pj-conv-content {
    flex: 1;
}

.pj-conv-item strong {
    display: block;
    margin-bottom: 5px;
    color: #000;
    font-size: 14px;
}

.pj-conv-item p {
    margin: 0;
    font-size: 12px;
    color: #666;
}

.pj-conv-delete {
    background: transparent;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 5px;
    opacity: 0.6;
    transition: all 0.2s;
    flex-shrink: 0;
    border-radius: 4px;
}

.pj-conv-delete:hover {
    opacity: 1;
    background: rgba(255, 0, 0, 0.1);
}

.pj-conv-delete.pj-confirm-delete {
    background: #e74c3c;
    color: #fff;
    opacity: 1;
    animation: pulse 0.5s ease-in-out;
}

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

.pj-conv-footer {
    padding: 15px;
    border-top: 1px solid #e0e0e0;
    text-align: center;
}

/* === CHAT SCREEN === */
.pj-chat-header {
    background: #ffdf8d;
    color: #000;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.pj-chat-title {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;
    font-size: 15px;
}

.pj-avatar {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    min-height: 40px !important;
    max-width: 40px !important;
    max-height: 40px !important;
    border-radius: 50% !important;
    background: #fff;
    display: flex !important;
    align-items: center;
    justify-content: center;
    color: #000;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    overflow: hidden !important;
    flex-shrink: 0 !important;
}

.pj-avatar img {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    min-height: 40px !important;
    max-width: 40px !important;
    max-height: 40px !important;
    object-fit: cover !important;
    border-radius: 50% !important;
    display: block !important;
}

.pj-chat-title span {
    font-size: 16px;
    font-weight: 600;
}

.pj-chat-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pj-chat-actions .pj-close-btn {
    position: relative;
    top: auto;
    right: auto;
    width: 32px;
    height: 32px;
    background: rgba(0, 0, 0, 0.1);
}

.pj-chat-actions .pj-close-btn:hover {
    background: rgba(0, 0, 0, 0.2);
}

.pj-menu-btn {
    background: transparent;
    border: none;
    color: #000;
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
    font-weight: bold;
}

/* === MENU === */
.pj-menu {
    position: absolute;
    top: 60px;
    right: 10px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    z-index: 1000;
    min-width: 200px;
}

.pj-hidden {
    display: none !important;
}

.pj-menu-item {
    padding: 12px 16px;
    cursor: pointer;
    font-size: 14px;
    color: #000;
    transition: background 0.2s;
}

.pj-menu-item:hover {
    background: #ffdf8d;
}

.pj-menu-item.pj-menu-header {
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    color: #666;
    padding: 8px 16px;
    cursor: default;
    letter-spacing: 0.5px;
}

.pj-menu-item.pj-menu-header:hover {
    background: transparent;
}

.pj-menu-item.pj-menu-session-id {
    font-family: 'Courier New', monospace;
    word-break: break-all;
    cursor: text;
    user-select: all;
    -webkit-user-select: all;
    -moz-user-select: all;
    -ms-user-select: all;
    padding: 8px 16px;
    background: #f8f8f8;
    border-top: 1px solid #e0e0e0;
    border-bottom: 1px solid #e0e0e0;
}

.pj-menu-item.pj-menu-session-id:hover {
    background: #f0f0f0;
}

.pj-menu-divider {
    height: 1px;
    background: #e0e0e0;
    margin: 4px 0;
}

/* === FINISH CONVERSATION POPUP === */
.pj-popup-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.pj-finish-popup {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    width: 90%;
    max-width: 320px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.pj-finish-popup h3 {
    margin: 0 0 12px 0;
    font-size: 18px;
    font-weight: 600;
    color: #000;
}

.pj-finish-popup p {
    margin: 0 0 20px 0;
    font-size: 14px;
    color: #666;
    line-height: 1.5;
}

.pj-popup-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.pj-popup-cancel,
.pj-popup-confirm {
    padding: 10px 20px;
    border-radius: 6px;
    border: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.pj-popup-cancel {
    background: #f0f0f0;
    color: #333;
}

.pj-popup-cancel:hover {
    background: #e0e0e0;
}

.pj-popup-confirm {
    background: #ffdf8d;
    color: #000;
}

.pj-popup-confirm:hover {
    background: #ffd770;
    transform: translateY(-1px);
}

/* === CHAT BODY === */
.pj-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f8f8;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

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

.pj-message.bot-message {
    background: #fff;
    color: #000;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.pj-message.user-message {
    background: #c2c2c2;
    color: #000;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.pj-message.system-message {
    background: #f0f0f0;
    color: #666;
    align-self: center;
    text-align: center;
    font-style: italic;
    font-size: 13px;
    border-radius: 20px;
    max-width: 80%;
}

.pj-message a {
    color: #000;
    text-decoration: underline;
}

/* Typing indicator */
.pj-typing {
    display: flex;
    gap: 5px;
    padding: 12px 16px;
}

.pj-typing span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #999;
    animation: pj-bounce 1.4s infinite ease-in-out both;
}

.pj-typing span:nth-child(1) {
    animation-delay: -0.32s;
}

.pj-typing span:nth-child(2) {
    animation-delay: -0.16s;
}

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

/* === PRODUCT CARDS === */
.pj-product-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    overflow: hidden;
    margin: 8px 0;
    max-width: 220px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.pj-product-image {
    width: 100%;
    height: 120px;
    object-fit: cover;
}

.pj-product-image.pj-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f0f0;
    color: #999;
    font-size: 40px;
}

.pj-product-info {
    padding: 12px;
}

.pj-product-title {
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 8px 0;
    color: #000;
}

.pj-product-price {
    font-size: 15px;
    font-weight: bold;
    color: #27ae60;
    margin: 0 0 10px 0;
}

.pj-product-btn {
    width: 100%;
    background: #ffdf8d;
    color: #000;
    border: none;
    padding: 10px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
    margin-bottom: 8px;
}

.pj-product-btn:last-child {
    margin-bottom: 0;
}

.pj-product-btn:hover {
    opacity: 0.9;
}

.pj-product-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* === CHAT INPUT === */
.pj-chat-input {
    padding: 15px;
    background: #fff;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

#pj-input {
    flex: 1;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    padding: 10px 15px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 100px;
    overflow-y: auto;
}

#pj-input:focus {
    outline: none;
    border-color: #ffdf8d;
}

#pj-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #ffdf8d;
    color: #000;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.2s;
}

#pj-send-btn:hover:not(:disabled) {
    opacity: 0.9;
}

#pj-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pj-chat-footer {
    padding: 10px 15px;
    background: #fff;
    text-align: center;
}

/* === MOBILE RESPONSIVE === */
@media screen and (max-width: 768px) {
    /* Keep the same desktop look on mobile, just adjust sizes */
    
    #wp-chatbot-ai-wrapper {
        bottom: 15px !important;
        right: 15px !important;
    }

    .wp-chatbot-ai-button {
        width: 55px;
        height: 55px;
    }

    #wp-chatbot-ai-chat-window {
        bottom: 80px;
        right: 15px;
        width: 95vw;
        max-width: 380px;
        height: 85vh;
        max-height: 600px;
    }

    .pj-product-card {
        max-width: 180px;
    }

    .pj-product-image {
        height: 100px;
    }
    
    #pj-input {
        max-height: 80px;
    }
}
