:root {
    --prc-color: #2563eb;
    --prc-btn-bottom: 24px;
    --prc-btn-top: auto;
    --prc-btn-right: 24px;
    --prc-btn-left: auto;
    --prc-win-bottom: 90px;
    --prc-win-top: auto;
    --prc-win-right: 24px;
    --prc-win-left: auto;
}

#prc-widget-btn {
    position: fixed;
    bottom: var(--prc-btn-bottom);
    top: var(--prc-btn-top);
    right: var(--prc-btn-right);
    left: var(--prc-btn-left);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--prc-color);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
    transition: transform 0.2s, box-shadow 0.2s;
}

#prc-widget-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0,0,0,0.2);
}

#prc-widget-btn svg {
    width: 28px;
    height: 28px;
}

#prc-unread-dot {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #ef4444;
    color: white;
    font-size: 11px;
    font-weight: bold;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    border: 2px solid white;
}

#prc-window {
    position: fixed;
    bottom: var(--prc-win-bottom);
    top: var(--prc-win-top);
    right: var(--prc-win-right);
    left: var(--prc-win-left);
    width: 380px;
    max-width: calc(100vw - 48px);
    height: 600px;
    max-height: calc(100vh - 120px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 9999;
    transform: scale(0);
    transform-origin: bottom right;
    transition: transform 0.25s ease;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

#prc-window.open {
    transform: scale(1);
}

#prc-header {
    background: var(--prc-color);
    color: white;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

#prc-agent-avatar, #prc-agent-avatar-placeholder {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 18px;
    text-transform: uppercase;
}

#prc-header-info {
    flex: 1;
}

#prc-header-name {
    font-weight: 600;
    font-size: 16px;
}

#prc-header-status {
    font-size: 13px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
}

#prc-online-dot {
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    display: inline-block;
}

#prc-close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    opacity: 0.8;
    padding: 4px;
}

#prc-prechat {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#prc-prechat p {
    margin: 0 0 8px;
    color: #334155;
}

#prc-prechat input {
    padding: 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
}

#prc-start-btn {
    background: var(--prc-color);
    color: white;
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
}

#prc-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8fafc;
    visibility: hidden;
}

.prc-msg {
    display: flex;
    flex-direction: column;
    max-width: 80%;
}

.prc-msg.visitor {
    align-self: flex-end;
}

.prc-msg.agent {
    align-self: flex-start;
}

.prc-msg-bubble {
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
    word-break: break-word;
}

.prc-msg.visitor .prc-msg-bubble {
    background: var(--prc-color);
    color: white;
    border-bottom-right-radius: 4px;
}

.prc-msg.agent .prc-msg-bubble {
    background: white;
    color: #1e293b;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.prc-msg-time {
    font-size: 10px;
    color: #64748b;
    margin-top: 4px;
    padding: 0 4px;
}

.prc-msg.visitor .prc-msg-time {
    text-align: right;
}

.prc-msg-img {
    max-width: 200px;
    max-height: 200px;
    border-radius: 12px;
    cursor: pointer;
}

.prc-msg-file-link {
    color: inherit;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 6px;
}

#prc-typing-row {
    padding: 8px 16px;
    font-size: 12px;
    color: #64748b;
    display: none;
    align-items: center;
}

.prc-typing-dots {
    display: inline-flex;
    gap: 4px;
}

.prc-typing-dots span {
    width: 6px;
    height: 6px;
    background: #94a3b8;
    border-radius: 50%;
    animation: prc-bounce 1.4s infinite ease-in-out both;
}

.prc-typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.prc-typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes prc-bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

#prc-file-preview {
    padding: 8px 16px;
    background: #f1f5f9;
    display: none;
    align-items: center;
    gap: 8px;
    border-top: 1px solid #e2e8f0;
}

#prc-file-preview img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 6px;
}

#prc-file-preview-name {
    flex: 1;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#prc-file-preview-cancel {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    color: #64748b;
}

#prc-input-area {
    padding: 12px 16px;
    background: white;
    border-top: 1px solid #e2e8f0;
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

#prc-attach-btn {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    padding: 8px 4px;
    color: #64748b;
}

#prc-msg-input {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 10px 14px;
    font-size: 14px;
    resize: none;
    max-height: 100px;
    font-family: inherit;
}

#prc-send-btn {
    background: var(--prc-color);
    color: white;
    border: none;
    border-radius: 20px;
    padding: 8px 18px;
    font-weight: 600;
    cursor: pointer;
    font-size: 14px;
}

#prc-rating-box {
    padding: 20px;
    text-align: center;
    display: none;
}

.prc-star-row {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 16px 0;
}

.prc-star {
    font-size: 32px;
    color: #cbd5e1;
    cursor: pointer;
    transition: color 0.1s;
}

.prc-star.lit {
    color: #fbbf24;
}

#prc-rating-comment {
    width: 100%;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px;
    font-size: 14px;
    margin-bottom: 16px;
    font-family: inherit;
    resize: vertical;
}

#prc-submit-rating {
    background: var(--prc-color);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
}

@media (max-width: 480px) {
    #prc-window {
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        bottom: 0;
        right: 0;
        border-radius: 0;
    }
    #prc-widget-btn.chat-open {
        display: none;
    }
}