/* ==========================================================================
   Bajt OrderChat – Floating Chat Widget
   ========================================================================== */

/* Kontener główny – fixed w prawym dolnym rogu */
.bajt-orderchat {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9990;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

/* ==========================================================================
   Przycisk toggle (koło z ikoną czatu)
   ========================================================================== */
.bajt-orderchat__toggle {
    position: relative;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #1a1a2e;
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.28);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
    outline: none;
    flex-shrink: 0;
    margin-top: 12px;
}

.bajt-orderchat__toggle:hover,
.bajt-orderchat__toggle:focus-visible {
    background: #16213e;
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

.bajt-orderchat__toggle:active {
    transform: scale(0.96);
}

/* Badge powiadomienia */
.bajt-orderchat__badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #e74c3c;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
}

/* ==========================================================================
   Okno chatu
   ========================================================================== */
.bajt-orderchat__window {
    display: none;
    flex-direction: column;
    width: 360px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.22);
    overflow: hidden;
    margin-bottom: 8px;

    /* Animacja wyjścia */
    opacity: 0;
    transform: translateY(16px) scale(0.97);
    transition: opacity 0.28s ease, transform 0.28s ease;
}

.bajt-orderchat__window--open {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* ==========================================================================
   Nagłówek
   ========================================================================== */
.bajt-orderchat__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: #1a1a2e;
    color: #fff;
    flex-shrink: 0;
    gap: 8px;
}

.bajt-orderchat__header-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 14px;
    letter-spacing: 0.01em;
    min-width: 0;
}

.bajt-orderchat__header-title span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bajt-orderchat__header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.bajt-orderchat__header-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.75);
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
    outline: none;
    padding: 0;
}

.bajt-orderchat__header-btn:hover,
.bajt-orderchat__header-btn:focus-visible {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

/* ==========================================================================
   Obszar wiadomości
   ========================================================================== */
.bajt-orderchat__messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
    background: #f8f9fb;
}

.bajt-orderchat__messages::-webkit-scrollbar {
    width: 4px;
}

.bajt-orderchat__messages::-webkit-scrollbar-track {
    background: transparent;
}

.bajt-orderchat__messages::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 2px;
}

/* ==========================================================================
   Bąbelki wiadomości
   ========================================================================== */
.bajt-orderchat__msg {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 13.5px;
    line-height: 1.55;
    word-break: break-word;
    white-space: pre-wrap;
    animation: msgSlideIn 0.2s ease;
}

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

/* Bot */
.bajt-orderchat__msg--bot {
    background: #fff;
    color: #222;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.bajt-orderchat__msg--bot a {
    color: #1a1a2e;
    word-break: break-all;
    font-size: 12px;
}

/* Użytkownik */
.bajt-orderchat__msg--user {
    background: #1a1a2e;
    color: #fff;
    border-bottom-right-radius: 4px;
    align-self: flex-end;
}

/* Wskaźnik pisania (3 kropki) */
.bajt-orderchat__msg--typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
}

.bajt-orderchat__msg--typing span {
    width: 7px;
    height: 7px;
    background: #aaa;
    border-radius: 50%;
    display: inline-block;
    animation: typingDot 1.2s infinite ease-in-out;
}

.bajt-orderchat__msg--typing span:nth-child(2) { animation-delay: 0.2s; }
.bajt-orderchat__msg--typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingDot {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30%            { transform: translateY(-5px); opacity: 1; }
}

/* ==========================================================================
   Formularz weryfikacji gościa
   ========================================================================== */
.bajt-orderchat__verify-form {
    flex-shrink: 0;
    padding: 12px 14px;
    border-top: 1px solid #eee;
    background: #fff;
}

.bajt-orderchat__verify-fields {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.bajt-orderchat__verify-input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 13.5px;
    outline: none;
    transition: border-color 0.15s;
    color: #222;
    background: #fafafa;
    box-sizing: border-box;
}

.bajt-orderchat__verify-input:focus {
    border-color: #1a1a2e;
    background: #fff;
}

.bajt-orderchat__verify-btn {
    width: 100%;
    padding: 10px;
    background: #1a1a2e;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, opacity 0.15s;
    outline: none;
}

.bajt-orderchat__verify-btn:hover:not(:disabled) {
    background: #16213e;
}

.bajt-orderchat__verify-btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.bajt-orderchat__verify-btn--error {
    background: #e74c3c !important;
}

/* ==========================================================================
   Obszar inputa czatu
   ========================================================================== */
.bajt-orderchat__input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid #eee;
    background: #fff;
    flex-shrink: 0;
}

.bajt-orderchat__input {
    flex: 1;
    padding: 9px 12px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 13.5px;
    resize: none;
    outline: none;
    transition: border-color 0.15s;
    max-height: 120px;
    min-height: 38px;
    line-height: 1.4;
    font-family: inherit;
    color: #222;
    background: #fafafa;
    box-sizing: border-box;
    overflow-y: auto;
}

.bajt-orderchat__input:focus {
    border-color: #1a1a2e;
    background: #fff;
}

.bajt-orderchat__send-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #1a1a2e;
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, transform 0.15s;
    flex-shrink: 0;
    outline: none;
}

.bajt-orderchat__send-btn:hover:not(:disabled) {
    background: #16213e;
    transform: scale(1.06);
}

.bajt-orderchat__send-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

/* ==========================================================================
   Responsywność – mobile
   ========================================================================== */
@media (max-width: 480px) {
    .bajt-orderchat {
        bottom: 16px;
        right: 12px;
    }

    .bajt-orderchat__window {
        width: calc(100vw - 24px);
        max-width: 100%;
        height: calc(100vh - 90px);
        max-height: none;
        border-radius: 12px;
        right: 0;
        position: fixed;
        bottom: 80px;
        margin: 0;
    }

    .bajt-orderchat__toggle {
        width: 52px;
        height: 52px;
    }
}

/* ==========================================================================
   Dostępność – redukcja ruchu
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
    .bajt-orderchat__window,
    .bajt-orderchat__toggle,
    .bajt-orderchat__msg {
        transition: none;
        animation: none;
    }

    .bajt-orderchat__msg--typing span {
        animation: none;
    }
}
