/* =========================================================
   RESET
========================================================= */

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;

    width: 100%;
    height: 100%;

    font-family: Arial, sans-serif;

    background: #f1f1f1;
}


/* =========================================================
   GÓRNY PASEK
========================================================= */

.preview-bar {
    height: 56px;
    width: 100%;

    position: fixed;

    top: 0;
    left: 0;

    z-index: 1000;

    background: #181818;
    color: white;

    display: flex;
    align-items: center;
    justify-content: center;

    gap: 20px;

    box-shadow:
        0 2px 10px rgba(0, 0, 0, 0.2);
}


.preview-info {
    font-size: 14px;
    color: #ddd;
}


.buttons {
    display: flex;
    gap: 6px;
}


button {
    border: 0;

    padding: 8px 14px;

    border-radius: 6px;

    background: #333;
    color: white;

    cursor: pointer;

    font-size: 13px;

    transition:
        background 0.2s ease,
        opacity 0.2s ease;
}


button:hover {
    background: #444;
}


button.active {
    background: white;
    color: #111;
}


button.disabled {
    opacity: 0.35;
    cursor: not-allowed;
}


button.disabled:hover {
    background: #333;
}


/* =========================================================
   PODGLĄD
========================================================= */

.preview-area {
    position: absolute;

    top: 56px;
    left: 0;
    right: 0;
    bottom: 0;

    display: flex;

    justify-content: center;
    align-items: flex-start;

    padding: 20px;

    overflow: auto;
}


.preview-frame {
    width: 100%;
    height: 100%;

    border: 1px solid #ccc;

    background: white;

    box-shadow:
        0 5px 25px rgba(0, 0, 0, 0.12);

    transition:
        width 0.25s ease,
        height 0.25s ease;
}


.preview-frame.desktop {
    width: 100%;
    height: 100%;
}


.preview-frame.mobile {
    width: 390px;
    height: 844px;

    max-width: 100%;
}


/* =========================================================
   POPUP DESKTOP
========================================================= */

.desktop-popup {
    display: none;

    position: fixed;

    right: 20px;
    bottom: 90px;

    width: calc(100% - 40px);
    max-width: 380px;

    padding: 15px 16px;

    background: #181818;
    color: white;

    border-radius: 10px;

    box-shadow:
        0 8px 30px rgba(0, 0, 0, 0.3);

    z-index: 2000;

    align-items: center;

    gap: 12px;

    animation: popupIn 0.3s ease;
}


.popup-icon {
    font-size: 26px;
    flex-shrink: 0;
}


.popup-content {
    display: flex;

    flex-direction: column;

    gap: 4px;

    flex: 1;
}


.popup-content strong {
    font-size: 14px;
}


.popup-content span {
    font-size: 12px;

    color: #bbb;

    line-height: 1.4;
}


.popup-close {
    padding: 0;

    width: 28px;
    height: 28px;

    flex-shrink: 0;

    background: transparent;

    color: #aaa;

    font-size: 22px;
}


.popup-close:hover {
    background: transparent;
    color: white;
}


@keyframes popupIn {

    from {
        opacity: 0;
        transform: translateY(15px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* =========================================================
   CHAT — PRZYCISK
========================================================= */

.chat-button {
    position: fixed;

    right: 22px;
    bottom: 22px;

    width: 58px;
    height: 58px;

    border-radius: 50%;

    background: #181818;
    color: white;

    display: flex;

    align-items: center;
    justify-content: center;

    font-size: 25px;

    cursor: pointer;

    z-index: 3000;

    box-shadow:
        0 6px 25px rgba(0, 0, 0, 0.25);

    transition:
        transform 0.2s ease,
        background 0.2s ease;
}


.chat-button:hover {
    background: #292929;

    transform: scale(1.05);
}


.chat-button.open {
    transform: rotate(90deg);
}


/* =========================================================
   CHAT — PANEL
========================================================= */

.chat-panel {
    position: fixed;

    right: 22px;
    bottom: 92px;

    width: 380px;
    height: 550px;

    max-width: calc(100vw - 44px);
    max-height: calc(100vh - 120px);

    background: white;

    border-radius: 14px;

    overflow: hidden;

    display: flex;
    flex-direction: column;

    z-index: 2999;

    box-shadow:
        0 12px 45px rgba(0, 0, 0, 0.25);

    opacity: 0;

    visibility: hidden;

    transform:
        translateY(15px)
        scale(0.97);

    transition:
        opacity 0.2s ease,
        visibility 0.2s ease,
        transform 0.2s ease;
}


.chat-panel.open {
    opacity: 1;

    visibility: visible;

    transform:
        translateY(0)
        scale(1);
}


/* =========================================================
   CHAT — HEADER
========================================================= */

.chat-header {
    height: 58px;

    flex-shrink: 0;

    background: #181818;
    color: white;

    display: flex;

    align-items: center;
    justify-content: space-between;

    padding: 0 16px;
}


.chat-title {
    display: flex;

    flex-direction: column;

    gap: 2px;
}


.chat-title strong {
    font-size: 14px;
}


.chat-status {
    font-size: 11px;
    color: #aaa;
}


.chat-close {
    width: 32px;
    height: 32px;

    padding: 0;

    background: transparent;

    color: #aaa;

    font-size: 22px;
}


.chat-close:hover {
    background: #292929;
    color: white;
}


/* =========================================================
   CHAT — WIADOMOŚCI
========================================================= */

.chat-messages {
    flex: 1;

    overflow-y: auto;

    padding: 16px;

    display: flex;

    flex-direction: column;

    gap: 10px;

    background: #f7f7f7;
}


.message {
    max-width: 80%;

    padding: 9px 12px;

    border-radius: 12px;

    font-size: 13px;

    line-height: 1.4;

    word-wrap: break-word;
}


.message.other {
    align-self: flex-start;

    background: white;
    color: #222;

    border: 1px solid #e5e5e5;

    border-bottom-left-radius: 4px;
}


.message.me {
    align-self: flex-end;

    background: #181818;
    color: white;

    border-bottom-right-radius: 4px;
}


.message-time {
    display: block;

    margin-top: 4px;

    font-size: 9px;

    opacity: 0.5;
}


/* =========================================================
   CHAT — INPUT
========================================================= */

.chat-input-area {
    display: flex;

    align-items: flex-end;

    gap: 8px;

    padding: 10px;

    background: white;

    border-top:
        1px solid #e5e5e5;
}


.chat-input {
    flex: 1;

    min-width: 0;

    max-height: 100px;

    resize: none;

    border:
        1px solid #ddd;

    border-radius: 10px;

    padding: 9px 11px;

    outline: none;

    font-family: inherit;

    font-size: 13px;

    line-height: 1.4;
}


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


.chat-send {
    width: 40px;
    height: 40px;

    padding: 0;

    flex-shrink: 0;

    border-radius: 10px;

    background: #181818;
    color: white;

    font-size: 17px;
}


.chat-send:hover {
    background: #333;
}


/* =========================================================
   MOBILE
========================================================= */

@media (max-width: 768px) {

    .preview-bar {
        justify-content: space-between;

        padding: 0 12px;

        gap: 10px;
    }


    .preview-info {
        font-size: 12px;
    }


    .buttons {
        gap: 4px;
    }


    .buttons button {
        padding: 7px 9px;

        font-size: 12px;
    }


    .preview-area {
        padding: 10px;
    }


    .desktop-popup {
        display: flex;
    }


    /* CHAT MOBILE */

    .chat-button {
        right: 16px;
        bottom: 16px;

        width: 54px;
        height: 54px;
    }


    .chat-panel {
        left: 10px;
        right: 10px;

        bottom: 80px;

        width: auto;

        max-width: none;

        height:
            calc(100vh - 100px);

        max-height: none;

        border-radius: 14px;
    }
}


/* =========================================================
   BARDZO MAŁE TELEFONY
========================================================= */

@media (max-width: 400px) {

    .preview-info {
        display: none;
    }


    .preview-bar {
        justify-content: flex-end;
    }


    .chat-panel {
        left: 6px;
        right: 6px;

        bottom: 76px;

        height:
            calc(100vh - 88px);
    }
}
