/* ============================================================
   Chat Widget
   ============================================================ */

.chat-bubble {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #4f46e5;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    cursor: pointer;
    box-shadow: 0 4px 18px rgba(79, 70, 229, 0.45);
    z-index: 9999;
    transition: transform 0.2s, background 0.2s;
}

.chat-bubble:hover {
    transform: scale(1.08);
    background: #4338ca;
}

.chat-bubble-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #ef4444;
    font-size: 9px;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
}

/* Widget okno */
.chat-widget {
    position: fixed;
    bottom: 96px;
    right: 28px;
    width: 340px;
    max-height: 520px;
    border-radius: 16px;
    background: #1e1e2e;
    color: #e2e8f0;
    box-shadow: 0 8px 40px rgba(0,0,0,0.45);
    z-index: 9998;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: inherit;
    font-size: 14px;
}

[data-theme="light"] .chat-widget {
    background: #fff;
    color: #1e293b;
    box-shadow: 0 8px 40px rgba(0,0,0,0.15);
}

.chat-widget-header {
    background: #4f46e5;
    color: #fff;
    padding: 12px 16px;
    font-weight: 600;
    font-size: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.chat-close-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,0.8);
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
    padding: 0 2px;
    transition: color 0.15s;
}

.chat-close-btn:hover {
    color: #fff;
}

.chat-status-bar {
    padding: 4px 14px;
    font-size: 11px;
    color: #6b7280;
    background: #17172a;
    flex-shrink: 0;
    min-height: 20px;
}

[data-theme="light"] .chat-status-bar {
    background: #f8fafc;
    color: #9ca3af;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-msg {
    display: flex;
    flex-direction: column;
    max-width: 82%;
}

.chat-msg--visitor {
    align-self: flex-end;
    align-items: flex-end;
}

.chat-msg--admin {
    align-self: flex-start;
    align-items: flex-start;
}

.chat-msg-text {
    padding: 8px 12px;
    border-radius: 12px;
    line-height: 1.45;
    word-break: break-word;
    white-space: pre-wrap;
}

.chat-msg--visitor .chat-msg-text {
    background: #4f46e5;
    color: #fff;
    border-bottom-right-radius: 3px;
}

.chat-msg--admin .chat-msg-text {
    background: #2d2d44;
    color: #e2e8f0;
    border-bottom-left-radius: 3px;
}

[data-theme="light"] .chat-msg--admin .chat-msg-text {
    background: #f1f5f9;
    color: #1e293b;
}

.chat-msg-time {
    font-size: 10px;
    color: #6b7280;
    margin-top: 2px;
    padding: 0 4px;
}

.chat-msg--system {
    text-align: center;
    font-size: 11px;
    color: #6b7280;
    padding: 2px 0;
    font-style: italic;
}

.chat-form {
    flex-shrink: 0;
    border-top: 1px solid rgba(255,255,255,0.07);
    padding: 10px;
}

[data-theme="light"] .chat-form {
    border-top-color: #e2e8f0;
}

.chat-intro {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-input {
    width: 100%;
    background: #2d2d44;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    color: #e2e8f0;
    padding: 8px 10px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.15s;
    box-sizing: border-box;
}

[data-theme="light"] .chat-input {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #1e293b;
}

.chat-input:focus {
    border-color: #4f46e5;
}

#chatCompose {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chat-compose-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.chat-textarea {
    flex: 1;
    background: #2d2d44;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    color: #e2e8f0;
    padding: 8px 10px;
    font-size: 13px;
    font-family: inherit;
    resize: none;
    outline: none;
    line-height: 1.4;
    transition: border-color 0.15s;
}

[data-theme="light"] .chat-textarea {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #1e293b;
}

.chat-textarea:focus {
    border-color: #4f46e5;
}

.chat-send-btn {
    background: #4f46e5;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}

.chat-send-btn:hover {
    background: #4338ca;
}

.chat-end-btn {
    background: none;
    border: none;
    color: #6b7280;
    font-size: 11px;
    cursor: pointer;
    padding: 0;
    text-align: center;
    width: 100%;
    transition: color 0.15s;
}

.chat-end-btn:hover {
    color: #ef4444;
}

@media (max-width: 400px) {
    .chat-widget {
        width: calc(100vw - 24px);
        right: 12px;
        bottom: 84px;
    }
    .chat-bubble {
        right: 16px;
        bottom: 16px;
    }
}
