/* ============================================================
   Support Chat Widget — traspberry.eu
   Colors: accent #FF6600, magenta rgba(214,19,126,0.829),
          dark #000, background #C0C0C0
   Font:   Helvetica, Arial, sans-serif
   ============================================================ */

/* ----- Widget container ----- */
.chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    font-family: 'Helvetica', 'Arial', sans-serif;
    font-size: 14px;
    line-height: 1.4;
}

/* ----- Toggle button ----- */
.chat-toggle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: rgba(214, 19, 126, 0.829);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
}

.chat-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 18px rgba(0,0,0,0.35);
}

.chat-toggle:active {
    transform: scale(0.96);
}

/* Badge for unread messages */
.chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    background: #FF6600;
    color: #fff;
    font-size: 11px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

/* ----- Chat window ----- */
.chat-window {
    position: absolute;
    bottom: 68px;
    right: 0;
    width: 340px;
    max-height: 520px;
    border-radius: 15px;
    background: #1a1a1a;
    color: #fff;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-sizing: border-box;
}

/* ----- Header ----- */
.chat-header {
    background: #000;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-radius: 15px 15px 0 0;
    flex-shrink: 0;
}

.chat-header-title {
    font-weight: 600;
    font-size: 15px;
    flex: 1;
}

.chat-new-top-btn {
    background: none;
    border: 1px solid #555;
    color: #999;
    font-size: 16px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    line-height: 1;
    transition: color 0.2s, border-color 0.2s;
}

.chat-new-top-btn:hover {
    color: #FF6600;
    border-color: #FF6600;
}

.chat-last-top-btn {
    background: none;
    border: 1px solid #555;
    color: #999;
    font-size: 14px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    line-height: 1;
    transition: color 0.2s, border-color 0.2s;
}

.chat-last-top-btn:hover {
    color: #4CAF50;
    border-color: #4CAF50;
}

.chat-last-top-btn.hidden,
.chat-new-top-btn.hidden {
    display: none !important;
}

.chat-close-btn {
    background: none;
    border: none;
    color: #999;
    font-size: 22px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    transition: color 0.2s;
}

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

/* ----- Info form ----- */
.chat-info-form {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
}

.chat-info-intro {
    font-size: 13px;
    color: #ccc;
    margin: 0 0 4px 0;
}

.chat-input,
.chat-select {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid #333;
    background: #2a2a2a;
    color: #fff;
    font-size: 13px;
    font-family: inherit;
    box-sizing: border-box;
}

.chat-input::placeholder {
    color: #888;
}

.chat-input:focus,
.chat-select:focus {
    outline: none;
    border-color: #FF6600;
}

.chat-select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23999' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 30px;
}

/* Honeypot — invisible to humans */
.chat-honeypot {
    position: absolute;
    left: -9999px;
    top: -9999px;
    opacity: 0;
    height: 0;
    width: 0;
    pointer-events: none;
}

/* Remember me checkbox */
.chat-remember-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #aaa;
    cursor: pointer;
}

.chat-remember-cb {
    accent-color: #FF6600;
}

/* Buttons */
.chat-btn {
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.2s, opacity 0.2s;
}

.chat-btn-primary {
    width: 100%;
    padding: 10px;
    background: #FF6600;
    color: #fff;
}

.chat-btn-primary:hover {
    background: #e65c00;
}

.chat-btn-send {
    width: 36px;
    height: 36px;
    padding: 0;
    background: rgba(214, 19, 126, 0.829);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-btn-send:hover {
    opacity: 0.85;
}

/* ----- Messages area ----- */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 200px;
    max-height: 340px;
}

.chat-msg {
    max-width: 80%;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 13px;
    word-wrap: break-word;
    position: relative;
}

.chat-msg-in {
    align-self: flex-start;
    background: #333;
    border-bottom-left-radius: 4px;
}

.chat-msg-out {
    align-self: flex-end;
    background: rgba(214, 19, 126, 0.5);
    border-bottom-right-radius: 4px;
}

.chat-msg-source {
    font-size: 10px;
    color: #888;
    margin-top: 2px;
}

.chat-msg-time {
    font-size: 10px;
    color: #777;
    margin-top: 2px;
    text-align: right;
}

/* ----- Input area ----- */
.chat-input-area {
    padding: 10px 12px;
    background: #1a1a1a;
    border-top: 1px solid #333;
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    box-sizing: border-box;
}

.chat-msg-input {
    flex: 1;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #333;
    background: #2a2a2a;
    color: #fff;
    font-size: 13px;
    font-family: inherit;
    resize: none;
    overflow: hidden;
    min-height: 36px;
    max-height: 120px;
    line-height: 1.4;
    box-sizing: border-box;
}

.chat-msg-input::placeholder {
    color: #888;
}

.chat-msg-input:focus {
    outline: none;
    border-color: #FF6600;
}

/* ----- Session ended ----- */
.chat-ended {
    padding: 20px 16px;
    text-align: center;
}

.chat-ended p {
    color: #aaa;
    font-size: 13px;
    margin: 0 0 12px 0;
}

.chat-ended-buttons {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.chat-btn-secondary {
    padding: 8px 16px;
    background: #333;
    color: #ccc;
    flex: 1;
}

.chat-btn-secondary:hover {
    background: #444;
    color: #fff;
}

/* ----- Shared utility ----- */
.chat-widget .hidden {
    display: none !important;
}

/* ----- Responsive ----- */
@media (max-width: 480px) {
    .chat-widget {
        right: 14px;
        bottom: 14px;
    }

    .chat-window {
        /* Expand left from the right-aligned widget to fill the viewport.
           right: -8px shifts the window's right edge past the widget's
           right edge so it ends ~12px from viewport right.
           width = 100vw − 24px → left edge ~12px from viewport left. */
        width: calc(100vw - 24px);
        right: -8px;
        bottom: 64px;
        max-height: calc(100vh - 100px);
        border-radius: 12px;
        box-sizing: border-box;
        overflow: hidden;
    }

    .chat-header {
        border-radius: 12px 12px 0 0;
    }

    .chat-toggle {
        width: 48px;
        height: 48px;
    }

    .chat-input-area {
        width: 100%;
        box-sizing: border-box;
    }

    .chat-msg-input {
        /* 16px prevents iOS auto-zoom on focus */
        font-size: 16px;
        min-width: 0;
    }

    .chat-btn-send {
        flex-shrink: 0;
    }
}

/* ----- Scrollbar (Webkit) ----- */
.chat-messages::-webkit-scrollbar {
    width: 5px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 3px;
}

/* ----- Loading/Typing indicators ----- */
.chat-typing {
    align-self: flex-start;
    font-size: 12px;
    color: #888;
    font-style: italic;
}
