/* Resolver - Chat Widget Styles */

.wpc-chat {
    --wpc-accent: #0A1332;
    --wpc-accent-hover: #363A4D;
    --wpc-bg: #ffffff;
    --wpc-bg-user: var(--wpc-accent);
    --wpc-bg-bot: #f1f5f9;
    --wpc-text: #1a1a1a;
    --wpc-text-user: #ffffff;
    --wpc-text-bot: #1a1a1a;
    --wpc-text-muted: #666666;
    --wpc-border: #dcdcdc;
    --wpc-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
    --wpc-radius: 12px;
    --wpc-panel-width: 400px;
    --wpc-panel-height: 700px;
    --wpc-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;

    position: fixed;
    z-index: 99999;
    font-family: var(--wpc-font);
    font-size: 14px;
    line-height: 1.5;
    box-sizing: border-box;
}

.wpc-chat *,
.wpc-chat *::before,
.wpc-chat *::after {
    box-sizing: border-box;
}

/* Positioning */
.wpc-position-bottom-right {
    bottom: 20px;
    right: 20px;
}

.wpc-position-bottom-left {
    bottom: 20px;
    left: 20px;
}

/* Toggle Button */
.wpc-toggle {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background-color: var(--wpc-accent);
    color: #ffffff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--wpc-shadow);
    transition: transform 0.2s;
}
.wpc-toggle svg {
    width: 32px;
    height: 32px;
}

.wpc-toggle:hover {
    transform: scale(1.05);
}

.wpc-toggle:focus-visible {
    outline: 2px solid var(--wpc-accent);
    outline-offset: 2px;
}

/* Panel */
.wpc-panel {
    position: absolute;
    right: 0;
    bottom: 84px;
    width: var(--wpc-panel-width);
    height: var(--wpc-panel-height);
    max-height: 76vh;
    background: var(--wpc-bg);
    border-radius: 12px;
    box-shadow: var(--wpc-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.wpc-position-bottom-right .wpc-panel,
:host(.wpc-position-bottom-right) .wpc-panel {
    right: 0;
}

.wpc-position-bottom-left .wpc-panel,
:host(.wpc-position-bottom-left) .wpc-panel {
    left: 0;
    right: auto;
}
.wpc-panel.is-admin {
    right: 0 !important;
    left: auto !important;
}

.wpc-panel[hidden] {
    display: none;
}
.wpc-panel-footer {
    font-size: 12px;
    padding: 0 12px 12px;
    text-align: center;
}
.wpc-panel-footer a {
    color: var(--wpc-text);
}
.wpc-panel-footer a:hover,
.wpc-panel-footer a:active,
.wpc-panel-footer a:focus {
    text-decoration: underline;
}

/* Header */
.wpc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--wpc-accent);
    color: #ffffff;
    flex-shrink: 0;
}

.wpc-bot-name {
    font-weight: 600;
    font-size: 15px;
}

.wpc-new-chat,
.wpc-close {
    background: none;
    border: none;
    color: #ffffff;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    opacity: 0.8;
    transition: opacity 0.2s;
}
.wpc-new-chat {
    margin-left: auto;
    padding-bottom: 1px;
}
.wpc-new-chat svg {
    width: 21px;
    height: 21px;
    fill: currentColor;
}

.wpc-new-chat:hover,
.wpc-close:hover {
    opacity: 1;
}

/* Messages Area */
.wpc-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.wpc-messages::-webkit-scrollbar {
    width: 4px;
}

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

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

/* Messages */
.wpc-message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
}

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

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

/* Avatar layout — only applied when .wpc-chat--has-avatar is present */
.wpc-chat--has-avatar .wpc-message-bot,
:host(.wpc-chat--has-avatar) .wpc-message-bot {
    flex-direction: row;
    align-items: flex-end;
    gap: 8px;
    max-width: 90%;
}

.wpc-bot-avatar {
    width: 28px;
    height: 28px;
    object-fit: cover;
    flex-shrink: 0;
    align-self: flex-start;
    margin-top: 4px;
    border-radius: var(--wpc-avatar-radius, 0);
}

.wpc-message-body {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Custom toggle icon */
img.wpc-icon-chat {
    display: block;
    width: 28px;
    height: 28px;
    object-fit: cover;
}

.wpc-message-content {
    padding: 8px 14px;
    border-radius: 8px;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.wpc-message-user .wpc-message-content {
    background: var(--wpc-bg-user);
    color: var(--wpc-text-user);
    border-bottom-right-radius: 0;
}

.wpc-message-bot .wpc-message-content {
    background: var(--wpc-bg-bot);
    color: var(--wpc-text-bot);
    border-bottom-left-radius: 0;
    white-space: normal;
}

/* Markdown rendering inside bot messages */
.wpc-message-bot .wpc-message-content strong { font-weight: 700; }
.wpc-message-bot .wpc-message-content em { font-style: italic; }

.wpc-message-bot .wpc-message-content a {
    color: var(--wpc-accent);
    text-decoration: underline;
}
.wpc-message-bot .wpc-message-content a:hover { opacity: 0.8; }

.wpc-message-bot .wpc-message-content code {
    background: rgba(0, 0, 0, 0.08);
    border-radius: 3px;
    padding: 1px 5px;
    font-family: monospace;
    font-size: 0.9em;
}

.wpc-message-bot .wpc-message-content pre {
    background: rgba(0, 0, 0, 0.08);
    border-radius: 6px;
    padding: 10px 12px;
    overflow-x: auto;
    margin: 6px 0;
}

.wpc-message-bot .wpc-message-content pre code {
    background: none;
    padding: 0;
    font-size: 0.85em;
    line-height: 1.5;
}
.wpc-message-bot .wpc-message-content ul {
    list-style: disc;
}
.wpc-message-bot .wpc-message-content ul,
.wpc-message-bot .wpc-message-content ol {
    margin: 4px 0;
    padding-left: 20px;
}

.wpc-message-bot .wpc-message-content li { margin: 2px 0; }

.wpc-message-bot .wpc-message-content h1,
.wpc-message-bot .wpc-message-content h2,
.wpc-message-bot .wpc-message-content h3 {
    font-weight: 600;
    margin: 8px 0 4px;
}

.wpc-message-bot .wpc-message-content h1 { font-size: 1.1em; }
.wpc-message-bot .wpc-message-content h2 { font-size: 1.05em; }
.wpc-message-bot .wpc-message-content h3 { font-size: 1em; }

/* Typing indicator */
.wpc-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 14px;
    background: var(--wpc-bg-bot);
    border-radius: 8px;
    border-bottom-left-radius: 0;
    align-self: flex-start;
}

.wpc-typing-dot {
    width: 6px;
    height: 6px;
    background: var(--wpc-text-muted);
    border-radius: 50%;
    animation: wpc-bounce 1.4s ease-in-out infinite;
}

.wpc-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.wpc-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes wpc-bounce {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-4px);
    }
}

/* Message timestamp */
.wpc-message-time {
    font-size: 11px;
    color: var(--wpc-text-muted);
    margin-top: 3px;
    padding: 0 2px;
}

.wpc-message-user .wpc-message-time {
    text-align: right;
}

/* Bot message meta row: name · time · 👍 👎 */
.wpc-message-meta {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-top: 4px;
    padding: 0 2px;
}

.wpc-message-meta .wpc-message-time {
    margin: 0;
    padding: 0;
}

.wpc-message-sender {
    font-size: 11px;
    color: var(--wpc-text-muted);
}

.wpc-meta-sep {
    font-size: 11px;
    color: var(--wpc-text-muted);
    opacity: 0.4;
}

.wpc-rate-btn {
    background: none;
    border: none;
    padding: 6px;
    border-radius: 4px;
    background-color: var(--wpc-bg-bot);
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    transition: opacity 0.15s, transform 0.1s;
    display: inline-flex;
    align-items: center;
}
.wpc-rate-btn:hover {
    background-color: #DAF5E1;
}
.wpc-rate-btn.wpc-rate-down:hover {
    background-color: #FFE1DE;
}
.wpc-rate-btn--active {
    background-color: #DAF5E1;
}
.wpc-rate-btn--active.wpc-rate-down {
    background-color: #FFE1DE;
}

.wpc-rate-btn svg {
    width: 10px;
    height: 10px;
    fill: currentColor;
    color: var(--wpc-text-muted);
    display: block;
}
.wpc-rate-btn--active svg {
    fill: #18B14E;
}
.wpc-rate-btn--active.wpc-rate-down svg {
    fill: #E72F22;
}

.wpc-rate-btn:disabled {
    cursor: default;
    pointer-events: none;
}

/* Error message */
.wpc-message-error .wpc-message-content {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* Input Area */
.wpc-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    flex-shrink: 0;
    flex-wrap: wrap;
    position: relative;
}

.wpc-char-counter {
    position: absolute;
    bottom: 2px;
    right: 58px;
    font-size: 10px;
    color: var(--wpc-text-muted);
    pointer-events: none;
}

.wpc-char-counter--over {
    color: #dc2626;
    font-weight: 600;
}

.wpc-input {
    font-size: 14px !important;
    flex: 1 !important;
    border: 1px solid var(--wpc-border) !important;
    border-radius: 16px !important;
    padding: 8px 12px !important;
    font-size: 14px !important;
    font-family: var(--wpc-font) !important;
    outline: none !important;
    transition: border-color 0.2s;
    background: #fff !important;
    color: var(--wpc-text) !important;
}

.wpc-input:focus {
    border-color: var(--wpc-accent) !important;
    box-shadow: none;
}

.wpc-input::placeholder {
    color: var(--wpc-text-muted) !important;
}

.wpc-send {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--wpc-accent);
    color: #ffffff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background-color 0.2s;
}

.wpc-send:hover {
    background: var(--wpc-accent-hover);
}

.wpc-send:disabled {
    background: #e5e7eb;
    color: #9ca3af;
    cursor: not-allowed;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .wpc-panel {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
        border: none;
    }

    .wpc-chat.wpc-open .wpc-toggle {
        display: none;
    }
}
