/**
 * WC Chat Widget Styles.
 *
 * @package WC_Chat
 */

/* Base widget styles */
.wc-chat-widget {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    position: fixed;
    z-index: 999999; /* FIX: Increased z-index so Elementor/Theme layers don't cover it */
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border-radius: 12px;
    overflow: hidden;
    background-color: var(--wc-chat-background, #ffffff);
    color: var(--wc-chat-text, #000000);
    transition: all 0.3s ease;
    width: var(--wc-chat-width, 340px);
    height: var(--wc-chat-height, 480px);
    max-height: 85vh;
    max-width: 90vw;
}

/* Widget states */
.wc-chat-widget-closed {
    display: none !important;
}

.wc-chat-widget-open {
    display: flex !important;
}

.wc-chat-widget-minimized {
    height: auto;
    min-height: 60px;
}

.wc-chat-widget-minimized .wc-chat-widget-messages,
.wc-chat-widget-minimized .wc-chat-widget-input {
    display: none;
}

/* Positioning for Chat Widget */
.wc-chat-position-bottom-right,
#wc-chat-widget.bottom-right {
    bottom: 20px;
    right: 20px;
    left: auto;
    top: auto;
}

.wc-chat-position-bottom-left,
#wc-chat-widget.bottom-left {
    bottom: 20px;
    left: 20px;
    right: auto;
    top: auto;
}

.wc-chat-position-top-right,
#wc-chat-widget.top-right {
    top: 20px;
    right: 20px;
    bottom: auto;
    left: auto;
}

.wc-chat-position-top-left,
#wc-chat-widget.top-left {
    top: 20px;
    left: 20px;
    bottom: auto;
    right: auto;
}

/* Widget header */
.wc-chat-widget-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background-color: var(--wc-chat-primary, #007cba);
    color: #ffffff;
    gap: 12px;
    flex-wrap: nowrap;
}

.wc-chat-agent-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.wc-chat-widget-header-info {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    min-width: 0;
}

.wc-chat-agent-name {
    font-weight: 600;
    margin: 0;
    font-size: 1rem;
    line-height: 1.2;
}

.wc-chat-widget-status {
    font-size: 0.75rem;
    opacity: 0.9;
}

.wc-chat-widget-close {
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 1.25rem;
    cursor: pointer;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.wc-chat-widget-close:hover {
    background-color: rgba(255,255,255,0.2);
}

/* Messages container */
.wc-chat-widget-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Message bubbles */
.wc-chat-widget-message {
    max-width: 80%;
    word-wrap: break-word;
    display: flex;
    align-items: flex-start;
}

.wc-chat-widget-message-user {
    align-self: flex-end;
    background-color: var(--wc-chat-primary, #007cba);
    color: #ffffff;
    border-radius: 18px 18px 4px 18px;
    padding: 10px 14px;
}

.wc-chat-widget-message-bot {
    align-self: flex-start;
    background-color: #f1f3f4;
    color: #202124;
    border-radius: 18px 18px 18px 4px;
    padding: 10px 14px;
}

.wc-chat-widget-message-system {
    align-self: center;
    text-align: center;
    color: #5f6368;
    font-size: 0.875rem;
    padding: 8px 12px;
    background-color: rgba(0,0,0,0.05);
    border-radius: 12px;
    margin: 8px 0;
}

.wc-chat-widget-message-error {
    align-self: center;
    text-align: center;
    color: #d93025;
    background-color: rgba(217,48,37,0.1);
    border-radius: 12px;
    padding: 8px 12px;
    margin: 8px 0;
}

.wc-chat-message-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    margin-right: 10px;
    flex-shrink: 0;
}

.wc-chat-message-content {
    line-height: 1.4;
    word-wrap: break-word;
    max-width: 100%;
}

.wc-chat-message-time {
    font-size: 0.75rem;
    opacity: 0.7;
    margin-top: 4px;
    align-self: flex-end;
}

/* Typing indicator */
.wc-chat-widget-typing {
    align-self: flex-start;
}

.wc-chat-widget-typing .wc-chat-message-content {
    display: flex;
    gap: 4px;
}

.wc-chat-widget-typing .wc-chat-message-content span {
    display: block;
    width: 8px;
    height: 8px;
    background-color: #5f6368;
    border-radius: 50%;
    animation: typingDot 1.4s infinite ease-in-out;
}

.wc-chat-widget-typing .wc-chat-message-content span:nth-child(1) {
    animation-delay: 0s;
}

.wc-chat-widget-typing .wc-chat-message-content span:nth-child(2) {
    animation-delay: 0.2s;
}

.wc-chat-widget-typing .wc-chat-message-content span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingDot {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-8px); }
}

/* Input area */
.wc-chat-widget-input {
    display: flex;
    padding: 12px;
    border-top: 1px solid #e0e0e0;
    background-color: var(--wc-chat-background, #ffffff);
    gap: 8px;
}

.wc-chat-widget-input-field {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #dadce0;
    border-radius: 24px;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.wc-chat-widget-input-field:focus {
    border-color: var(--wc-chat-primary, #007cba);
    box-shadow: 0 0 0 2px rgba(0,123,255,0.25);
}

.wc-chat-widget-input-field::placeholder {
    color: #9aa0a6;
}

.wc-chat-widget-send-button {
    background-color: var(--wc-chat-primary, #007cba);
    color: #ffffff;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.2s, transform 0.1s;
}

.wc-chat-widget-send-button:hover {
    opacity: 0.9;
    transform: scale(1.05);
}

.wc-chat-widget-send-button:active {
    transform: scale(0.95);
}

.wc-chat-widget-send-button:disabled {
    background-color: #9aa0a6;
    cursor: not-allowed;
    transform: none;
}

/* Floating Launcher button - FIX: Absolute position & high z-index provided by default */
.wc-chat-widget-launcher {
    position: fixed !important;
    bottom: 20px;
    right: 20px;
    z-index: 999999 !important;
    width: 60px;
    height: 60px;
    background-color: var(--wc-chat-primary, #007cba);
    color: #ffffff;
    border-radius: 50%;
    display: flex !important;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 1 !important;
    visibility: visible !important;
    transform: scale(1);
}

.wc-chat-widget-launcher.hidden {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
}

.wc-chat-widget-launcher-visible {
    opacity: 1 !important;
    visibility: visible !important;
    transform: scale(1);
}

.wc-chat-widget-launcher:hover {
    opacity: 0.9;
    transform: scale(1.1);
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .wc-chat-widget {
        width: 100vw;
        height: 100vh;
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
        bottom: 0 !important;
        right: 0 !important;
        left: 0 !important;
        top: 0 !important;
    }

    .wc-chat-widget-header,
    .wc-chat-widget-messages,
    .wc-chat-widget-input {
        padding: 16px;
    }
}

/* Animation for messages */
.wc-chat-widget-message {
    animation: messageFadeIn 0.3s ease-out;
}

@keyframes messageFadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Scrollbar styling */
.wc-chat-widget-messages::-webkit-scrollbar {
    width: 6px;
}

.wc-chat-widget-messages::-webkit-scrollbar-track {
    background: transparent;
}

.wc-chat-widget-messages::-webkit-scrollbar-thumb {
    background-color: rgba(0,0,0,0.2);
    border-radius: 3px;
}

/* FIX: Corrected typo from matches to messages */
.wc-chat-widget-messages::-webkit-scrollbar-thumb:hover {
    background-color: rgba(0,0,0,0.3);
}

/* Theme variations */
.wc-chat-theme-light {
    --wc-chat-primary: #007cba;
    --wc-chat-background: #ffffff;
    --wc-chat-text: #202124;
}

.wc-chat-theme-dark {
    --wc-chat-primary: #bb86fc;
    --wc-chat-background: #121212;
    --wc-chat-text: #e0e0e0;
}

.wc-chat-theme-dark .wc-chat-widget-message-bot {
    background-color: #1e1e1e;
    color: #e0e0e0;
}

.wc-chat-theme-dark .wc-chat-widget-header {
    background-color: #1e1e1e;
}

.wc-chat-theme-dark .wc-chat-widget-input {
    border-top: 1px solid #333;
}

/* Dark mode preferences */
@media (prefers-color-scheme: dark) {
    .wc-chat-theme-system {
        --wc-chat-primary: #bb86fc;
        --wc-chat-background: #121212;
        --wc-chat-text: #e0e0e0;
    }

    .wc-chat-theme-system .wc-chat-widget-message-bot {
        background-color: #1e1e1e;
        color: #e0e0e0;
    }

    .wc-chat-theme-system .wc-chat-widget-header {
        background-color: #1e1e1e;
    }

    .wc-chat-theme-system .wc-chat-widget-input {
        border-top: 1px solid #333;
    }
}