/**
 * AutoPrint Chat Widget Styles
 */

/* ══════════════════════════════════════════
   Chat bubble button
   ══════════════════════════════════════════ */
#apc-chat-bubble {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--apc-chat-primary, #0073aa);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0,0,0,0.25);
    transition: transform 0.2s, box-shadow 0.2s;
}

#apc-chat-bubble:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(0,0,0,0.3);
}

#apc-chat-bubble .apc-chat-bubble-close {
    display: none;
}

#apc-chat-bubble.apc-chat-open .apc-chat-bubble-icon {
    display: none;
}

#apc-chat-bubble.apc-chat-open .apc-chat-bubble-close {
    display: flex;
}

/* ══════════════════════════════════════════
   Chat window
   ══════════════════════════════════════════ */
#apc-chat-window {
    position: fixed;
    bottom: 100px;
    right: 24px;
    z-index: 99998;
    width: 380px;
    height: 520px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: apcChatSlideUp 0.3s ease;
}

@keyframes apcChatSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Header ── */
.apc-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    background: var(--apc-chat-primary, #0073aa);
    color: #fff;
    flex-shrink: 0;
}

.apc-chat-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.apc-chat-header-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #4ade80;
    animation: apcPulse 2s infinite;
}

@keyframes apcPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.apc-chat-header-title {
    font-weight: 600;
    font-size: 15px;
}

.apc-chat-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.apc-chat-header-btn {
    background: rgba(255,255,255,0.15);
    border: none;
    color: rgba(255,255,255,0.8);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
}

.apc-chat-header-btn:hover {
    background: rgba(255,255,255,0.25);
    color: #fff;
}

/* ── Messages area ── */
.apc-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.apc-chat-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
}

.apc-chat-msg a {
    color: inherit;
    text-decoration: underline;
}

.apc-chat-msg-user {
    align-self: flex-end;
    background: var(--apc-chat-primary, #0073aa);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.apc-chat-msg-assistant {
    align-self: flex-start;
    background: #f0f2f5;
    color: #333;
    border-bottom-left-radius: 4px;
}

/* ── Typing indicator ── */
.apc-chat-typing {
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.apc-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #bbb;
    animation: apcTypingBounce 1.2s infinite;
}

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

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

@keyframes apcTypingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* ── Input area ── */
.apc-chat-input-wrap {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid #eee;
    flex-shrink: 0;
}

#apc-chat-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 100px;
    line-height: 1.4;
    outline: none;
}

#apc-chat-input:focus {
    border-color: var(--apc-chat-primary, #0073aa);
    box-shadow: 0 0 0 2px rgba(0,115,170,0.1);
}

#apc-chat-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--apc-chat-primary, #0073aa);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
}

#apc-chat-send svg {
    width: 20px !important;
    height: 20px !important;
    stroke: #fff !important;
    fill: none !important;
    display: block !important;
}

#apc-chat-send:hover {
    filter: brightness(1.1);
}

#apc-chat-send:disabled {
    opacity: 0.5;
    cursor: default;
}

/* ── Attach photo button ── */
#apc-chat-attach {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: #f0f2f5;
    color: #555;
    border: 1px solid #ddd;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}

#apc-chat-attach:hover {
    background: #e4e8ed;
    color: var(--apc-chat-primary, #0073aa);
    border-color: var(--apc-chat-primary, #0073aa);
}

#apc-chat-attach svg {
    width: 22px !important;
    height: 22px !important;
    stroke: currentColor !important;
    fill: none !important;
    display: block !important;
}

/* Drag over highlight */
.apc-chat-dragover {
    background: #e8f4fd !important;
    outline: 2px dashed var(--apc-chat-primary, #0073aa);
    outline-offset: -4px;
}

/* ── Image preview before send ── */
.apc-chat-preview {
    position: relative;
    padding: 8px 14px;
    border-top: 1px solid #eee;
    background: #fafafa;
}

.apc-chat-preview img {
    max-height: 80px;
    max-width: 120px;
    border-radius: 8px;
    border: 1px solid #ddd;
}

#apc-chat-preview-remove {
    position: absolute;
    top: 4px;
    left: 130px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #e00;
    color: #fff;
    border: none;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── Image in chat message ── */
.apc-chat-msg-image {
    padding: 6px;
}

.apc-chat-msg-image img {
    max-width: 200px;
    max-height: 200px;
    border-radius: 10px;
    display: block;
}

/* ── AI disclaimer under input ── */
.apc-chat-disclaimer {
    text-align: center;
    font-size: 11px;
    color: #999;
    padding: 4px 14px 8px;
    flex-shrink: 0;
}

/* ── Privacy consent overlay ── */
.apc-chat-privacy {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    border-radius: 16px;
}

.apc-chat-privacy-content {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    max-width: 320px;
    max-height: 80%;
    overflow-y: auto;
    box-shadow: 0 8px 30px rgba(0,0,0,0.2);
}

.apc-chat-privacy-text {
    font-size: 13px;
    color: #444;
    line-height: 1.6;
    margin-bottom: 20px;
}

.apc-chat-privacy-buttons {
    display: flex;
    gap: 10px;
}

.apc-chat-privacy-btn {
    flex: 1;
    padding: 10px 16px;
    border-radius: 8px;
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.apc-chat-agree {
    background: var(--apc-chat-primary, #0073aa);
    color: #fff;
}

.apc-chat-agree:hover {
    filter: brightness(1.1);
}

.apc-chat-disagree {
    background: #f0f0f0;
    color: #666;
}

.apc-chat-disagree:hover {
    background: #e0e0e0;
}

/* ══════════════════════════════════════════
   Mobile responsive
   ══════════════════════════════════════════ */
@media (max-width: 480px) {
    #apc-chat-window {
        width: calc(100% - 16px);
        height: calc(100% - 80px);
        bottom: 8px;
        right: 8px;
        border-radius: 12px;
    }

    #apc-chat-bubble {
        bottom: 16px;
        right: 16px;
        width: 54px;
        height: 54px;
    }
}