:root {
    --projekt-chat-primary: #0073aa;
}

#projekt-chat-widget {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    z-index: 999999;
}

#projekt-chat-bubble {
    position: fixed;
    width: 60px;
    height: 60px;
    background: var(--projekt-chat-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    transition: transform 0.2s, background 0.2s;
    z-index: 999999;
}

/* Bubble positions */
#projekt-chat-bubble.pos-bottom-right { bottom: 24px; right: 24px; }
#projekt-chat-bubble.pos-bottom-left { bottom: 24px; left: 24px; }
#projekt-chat-bubble.pos-bottom-center { bottom: 24px; left: 50%; transform: translateX(-50%); }
#projekt-chat-bubble.pos-top-right { top: 24px; right: 24px; }
#projekt-chat-bubble.pos-top-left { top: 24px; left: 24px; }
#projekt-chat-bubble.pos-top-center { top: 24px; left: 50%; transform: translateX(-50%); }
#projekt-chat-bubble.pos-bottom-center:hover { transform: translateX(-50%) scale(1.1); }
#projekt-chat-bubble.pos-top-center:hover { transform: translateX(-50%) scale(1.1); }

#projekt-chat-bubble:hover {
    transform: scale(1.1);
    filter: brightness(0.85);
}

/* Unread badge */
.projekt-chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #d63638;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    line-height: 1;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

/* Pulse animation for new messages */
@keyframes projekt-chat-pulse {
    0% { box-shadow: 0 4px 12px rgba(0,0,0,0.25), 0 0 0 0 rgba(0,115,170,0.5); }
    70% { box-shadow: 0 4px 12px rgba(0,0,0,0.25), 0 0 0 14px rgba(0,115,170,0); }
    100% { box-shadow: 0 4px 12px rgba(0,0,0,0.25), 0 0 0 0 rgba(0,115,170,0); }
}

#projekt-chat-bubble.projekt-chat-has-new {
    animation: projekt-chat-pulse 1.5s infinite;
}

#projekt-chat-window {
    position: fixed;
    width: 380px;
    height: 520px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 999999;
}

/* Window positions */
#projekt-chat-window.pos-bottom-right { bottom: 96px; right: 24px; }
#projekt-chat-window.pos-bottom-left { bottom: 96px; left: 24px; }
#projekt-chat-window.pos-bottom-center { bottom: 96px; left: 50%; transform: translateX(-50%); }
#projekt-chat-window.pos-top-right { top: 96px; right: 24px; }
#projekt-chat-window.pos-top-left { top: 96px; left: 24px; }
#projekt-chat-window.pos-top-center { top: 96px; left: 50%; transform: translateX(-50%); }

#projekt-chat-header {
    background: var(--projekt-chat-primary);
    color: #fff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 16px;
    min-height: 56px;
}

#projekt-chat-logo {
    height: 32px;
    border-radius: 4px;
    flex-shrink: 0;
}

#projekt-chat-title {
    flex: 1;
}

#projekt-chat-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    opacity: 0.8;
    flex-shrink: 0;
}

#projekt-chat-close:hover {
    opacity: 1;
}

#projekt-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Agent message with photo */
.projekt-chat-agent-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 85%;
    align-self: flex-start;
}

.projekt-chat-agent-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.projekt-chat-agent-avatar-placeholder {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #ddd;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
    color: #888;
}

.projekt-chat-msg {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 16px;
    line-height: 1.4;
    word-wrap: break-word;
}

.projekt-chat-msg.visitor {
    align-self: flex-end;
    background: var(--projekt-chat-primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.projekt-chat-msg.admin {
    background: #f0f0f0;
    color: #333;
    border-bottom-left-radius: 4px;
}

.projekt-chat-agent-name {
    font-size: 11px;
    color: #888;
    margin-bottom: 2px;
    font-weight: 600;
}

.projekt-chat-time {
    font-size: 11px;
    color: #999;
    margin-top: 2px;
}

.projekt-chat-msg.visitor .projekt-chat-time {
    color: rgba(255, 255, 255, 0.7);
    text-align: right;
}

/* Name form */
.projekt-chat-name-form {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    justify-content: center;
}

.projekt-chat-name-form h3 {
    margin: 0;
    font-size: 18px;
    color: #333;
}

.projekt-chat-name-form p {
    margin: 0;
    color: #666;
    font-size: 13px;
    line-height: 1.5;
}

.projekt-chat-name-form input {
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
}

.projekt-chat-name-form input:focus {
    border-color: var(--projekt-chat-primary);
}

.projekt-chat-name-form button {
    padding: 10px;
    background: var(--projekt-chat-primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    font-weight: 600;
}

.projekt-chat-name-form button:hover {
    filter: brightness(0.85);
}

#projekt-chat-form {
    display: flex;
    padding: 12px;
    gap: 8px;
    border-top: 1px solid #eee;
}

#projekt-chat-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 14px;
    outline: none;
}

#projekt-chat-input:focus {
    border-color: var(--projekt-chat-primary);
}

#projekt-chat-form button {
    width: 40px;
    height: 40px;
    border: none;
    background: var(--projekt-chat-primary);
    color: #fff;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: filter 0.2s;
}

#projekt-chat-form button:hover {
    filter: brightness(0.85);
}

/* Typing indicator */
.projekt-chat-typing {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #888;
    font-size: 13px;
    padding: 4px 0;
}

.projekt-chat-typing-dots {
    display: inline-flex;
    gap: 3px;
    align-items: center;
}

.projekt-chat-typing-dots span {
    width: 6px;
    height: 6px;
    background: #aaa;
    border-radius: 50%;
    animation: projekt-chat-dot-bounce 1.4s infinite ease-in-out;
}

.projekt-chat-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.projekt-chat-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes projekt-chat-dot-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* Offline message */
.projekt-chat-offline-msg {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 30px 24px;
    text-align: center;
}

.projekt-chat-offline-msg p {
    color: #666;
    font-size: 15px;
    line-height: 1.6;
    margin: 0;
}

@media (max-width: 480px) {
    #projekt-chat-window {
        width: calc(100vw - 16px);
        height: calc(100vh - 120px);
        right: 8px;
        bottom: 80px;
        border-radius: 12px;
    }
}
