/**
 * Property Chatbot AI - Styles
 * 
 * @package Property_Chatbot_AI
 * @version 1.0.0
 */

/* =============================================================================
 * CSS VARIABLES & RESET
 * ============================================================================= */

.pcai-chatbot-container {
    --pcai-primary: #1a4d5c;
    --pcai-primary-dark: #153d4a;
    --pcai-text: #333;
    --pcai-text-light: #666;
    --pcai-bg: #fff;
    --pcai-bg-message: #f5f5f5;
    --pcai-border: #e0e0e0;
    --pcai-shadow: 0 5px 40px rgba(0, 0, 0, 0.16);
    --pcai-radius: 12px;
    --pcai-radius-small: 8px;
    
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    box-sizing: border-box;
}

.pcai-chatbot-container *,
.pcai-chatbot-container *::before,
.pcai-chatbot-container *::after {
    box-sizing: border-box;
}

/* Dark Theme */
.pcai-theme-dark {
    --pcai-text: #f0f0f0;
    --pcai-text-light: #aaa;
    --pcai-bg: #1e1e1e;
    --pcai-bg-message: #2d2d2d;
    --pcai-border: #404040;
}

/* =============================================================================
 * FIXED POSITION (FLOATING CHAT)
 * ============================================================================= */

.pcai-position-fixed {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 99999;
}

.pcai-position-fixed .pcai-toggle-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--pcai-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: var(--pcai-shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.pcai-position-fixed .pcai-toggle-btn:hover {
    background: var(--pcai-primary-dark);
    transform: scale(1.05);
}

.pcai-position-fixed .pcai-chat-window {
    position: absolute;
    bottom: 75px;
    right: 0;
    width: 380px;
    height: 550px;
    max-height: calc(100vh - 100px);
    border-radius: var(--pcai-radius);
    box-shadow: var(--pcai-shadow);
    background: var(--pcai-bg);
    display: none;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.pcai-position-fixed .pcai-chat-window.pcai-open {
    display: flex;
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* =============================================================================
 * INLINE POSITION (EMBEDDED)
 * ============================================================================= */

.pcai-position-inline .pcai-toggle-btn {
    display: none;
}

.pcai-position-inline .pcai-chat-window {
    width: 100%;
    height: 600px;
    max-height: 80vh;
    border-radius: var(--pcai-radius);
    box-shadow: var(--pcai-shadow);
    background: var(--pcai-bg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* =============================================================================
 * HEADER
 * ============================================================================= */

.pcai-header {
    padding: 16px 20px;
    background: var(--pcai-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.pcai-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.pcai-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.pcai-header-text {
    display: flex;
    flex-direction: column;
}

.pcai-title {
    font-weight: 600;
    font-size: 15px;
}

.pcai-status {
    font-size: 12px;
    opacity: 0.85;
}

.pcai-close-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.pcai-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* =============================================================================
 * MESSAGES CONTAINER
 * ============================================================================= */

.pcai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--pcai-bg);
}

/* Message Bubble */
.pcai-message {
    max-width: 85%;
    animation: pcai-fadeIn 0.3s ease;
}

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

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

.pcai-message-assistant {
    align-self: flex-start;
}

.pcai-message-content {
    padding: 12px 16px;
    border-radius: var(--pcai-radius);
    word-wrap: break-word;
}

.pcai-message-user .pcai-message-content {
    background: var(--pcai-primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.pcai-message-assistant .pcai-message-content {
    background: var(--pcai-bg-message);
    color: var(--pcai-text);
    border-bottom-left-radius: 4px;
}

/* Typing Indicator */
.pcai-typing {
    display: flex;
    gap: 4px;
    padding: 16px;
}

.pcai-typing span {
    width: 8px;
    height: 8px;
    background: var(--pcai-text-light);
    border-radius: 50%;
    animation: pcai-bounce 1.4s infinite ease-in-out both;
}

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

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

/* =============================================================================
 * PROPERTY CARDS
 * ============================================================================= */

.pcai-properties {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 12px;
}

.pcai-property-card {
    display: flex;
    gap: 12px;
    background: var(--pcai-bg);
    border: 1px solid var(--pcai-border);
    border-radius: var(--pcai-radius-small);
    overflow: hidden;
    transition: box-shadow 0.2s, transform 0.2s;
}

.pcai-property-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.pcai-property-image {
    width: 100px;
    height: 80px;
    flex-shrink: 0;
    overflow: hidden;
}

.pcai-property-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.pcai-property-info {
    flex: 1;
    padding: 8px 10px 8px 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

.pcai-property-title {
    font-weight: 600;
    font-size: 13px;
    color: var(--pcai-text);
    margin: 0 0 4px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pcai-property-location {
    font-size: 11px;
    color: var(--pcai-text-light);
    margin: 0 0 6px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pcai-property-meta {
    display: flex;
    gap: 10px;
    font-size: 11px;
    color: var(--pcai-text-light);
}

.pcai-property-price {
    font-weight: 700;
    font-size: 14px;
    color: var(--pcai-primary);
    margin-top: 4px;
}

.pcai-property-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

/* View All Button */
.pcai-view-all {
    display: block;
    text-align: center;
    padding: 12px;
    background: var(--pcai-primary);
    color: #fff;
    text-decoration: none;
    border-radius: var(--pcai-radius-small);
    font-weight: 600;
    font-size: 13px;
    margin-top: 8px;
    transition: background 0.2s;
}

.pcai-view-all:hover {
    background: var(--pcai-primary-dark);
    color: #fff;
}

/* Map Button */
.pcai-map-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    background: linear-gradient(135deg, #2d8659 0%, #1e6b45 100%);
    color: #fff;
    text-decoration: none;
    border-radius: var(--pcai-radius-small);
    font-weight: 600;
    font-size: 14px;
    margin-top: 12px;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(45, 134, 89, 0.3);
}

.pcai-map-btn:hover {
    background: linear-gradient(135deg, #35a06a 0%, #258552 100%);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(45, 134, 89, 0.4);
}

.pcai-map-btn svg {
    flex-shrink: 0;
}

/* =============================================================================
 * INPUT AREA
 * ============================================================================= */

.pcai-input-area {
    padding: 16px;
    border-top: 1px solid var(--pcai-border);
    background: var(--pcai-bg);
    flex-shrink: 0;
}

.pcai-input-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.pcai-input {
    flex: 1;
    border: 1px solid var(--pcai-border);
    border-radius: var(--pcai-radius-small);
    padding: 12px 14px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    min-height: 44px;
    max-height: 120px;
    background: var(--pcai-bg);
    color: var(--pcai-text);
    outline: none;
    transition: border-color 0.2s;
}

.pcai-input:focus {
    border-color: var(--pcai-primary);
}

.pcai-input::placeholder {
    color: var(--pcai-text-light);
}

.pcai-send-btn {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: var(--pcai-radius-small);
    background: var(--pcai-primary);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.pcai-send-btn:hover {
    background: var(--pcai-primary-dark);
}

.pcai-send-btn:disabled {
    background: var(--pcai-border);
    cursor: not-allowed;
}

/* Voice Button */
.pcai-voice-btn {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: var(--pcai-radius-small);
    background: var(--pcai-bg-message);
    color: var(--pcai-text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    border: 1px solid var(--pcai-border);
}

.pcai-voice-btn:hover {
    background: var(--pcai-primary);
    color: #fff;
    border-color: var(--pcai-primary);
}

.pcai-voice-btn.pcai-recording {
    background: #dc3545;
    color: #fff;
    border-color: #dc3545;
    animation: pcai-pulse 1.5s infinite;
}

.pcai-voice-btn.pcai-recording .pcai-mic-icon {
    display: none;
}

.pcai-voice-btn.pcai-recording .pcai-mic-recording {
    display: block !important;
}

.pcai-voice-btn.pcai-processing {
    background: #ffc107;
    color: #000;
    border-color: #ffc107;
    cursor: wait;
}

@keyframes pcai-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.8; }
}

/* Voice Status */
.pcai-voice-status {
    text-align: center;
    padding: 8px;
    font-size: 12px;
    color: var(--pcai-text-light);
}

.pcai-voice-status .pcai-voice-text {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.pcai-voice-status .pcai-voice-text::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #dc3545;
    border-radius: 50%;
    animation: pcai-pulse 1s infinite;
}

/* Suggestion Chips */
.pcai-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.pcai-suggestion {
    background: var(--pcai-bg-message);
    border: 1px solid var(--pcai-border);
    border-radius: 16px;
    padding: 6px 12px;
    font-size: 12px;
    color: var(--pcai-text);
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.pcai-suggestion:hover {
    background: var(--pcai-primary);
    color: #fff;
    border-color: var(--pcai-primary);
}

/* Hide suggestions after first interaction */
.pcai-suggestions.pcai-hidden {
    display: none;
}

/* =============================================================================
 * RESPONSIVE
 * ============================================================================= */

@media (max-width: 480px) {
    .pcai-position-fixed {
        bottom: 10px;
        right: 10px;
    }
    
    .pcai-position-fixed .pcai-toggle-btn {
        width: 54px;
        height: 54px;
    }
    
    .pcai-position-fixed .pcai-chat-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        bottom: 70px;
        right: 0;
        border-radius: var(--pcai-radius-small);
    }
    
    .pcai-property-card {
        flex-direction: column;
    }
    
    .pcai-property-image {
        width: 100%;
        height: 120px;
    }
    
    .pcai-property-info {
        padding: 10px;
    }
}

/* =============================================================================
 * SCROLLBAR
 * ============================================================================= */

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

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

.pcai-messages::-webkit-scrollbar-thumb {
    background: var(--pcai-border);
    border-radius: 3px;
}

.pcai-messages::-webkit-scrollbar-thumb:hover {
    background: var(--pcai-text-light);
}
