/* ============================================================
   SOMSANITHTECH AI - FLOATING CHAT BUTTON
   Add this to the end of your main style.css
   ============================================================ */

/* Floating Button Container */
.somsanith-float-chat {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Chat Button */
.somsanith-chat-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #f7971e, #ffd200);
    color: #111;
    font-size: 32px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(247, 151, 30, 0.4);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.somsanith-chat-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(247, 151, 30, 0.6);
}

.somsanith-chat-btn:active {
    transform: scale(0.95);
}

/* Badge for unread messages */
.somsanith-chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ff4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    border: 2px solid #fff;
}

.somsanith-chat-badge.active {
    display: flex;
}

/* Chat Widget */
.somsanith-chat-widget {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 380px;
    max-width: calc(100vw - 48px);
    height: 520px;
    max-height: calc(100vh - 180px);
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 10px 60px rgba(0, 0, 0, 0.3);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: somsanithSlideUp 0.3s ease;
    z-index: 9998;
    border: 1px solid rgba(247, 151, 30, 0.2);
}

.somsanith-chat-widget.open {
    display: flex;
}

@keyframes somsanithSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Widget Header */
.somsanith-chat-header {
    padding: 16px 20px;
    background: linear-gradient(135deg, #f7971e, #ffd200);
    color: #111;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.somsanith-chat-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.somsanith-chat-header-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.somsanith-chat-header-title {
    font-weight: 700;
    font-size: 16px;
}

.somsanith-chat-header-status {
    font-size: 11px;
    opacity: 0.8;
}

.somsanith-chat-close {
    background: none;
    border: none;
    color: #111;
    font-size: 22px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
    padding: 0 4px;
}

.somsanith-chat-close:hover {
    opacity: 1;
}

/* Widget Messages Area */
.somsanith-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    background: #f7f7f8;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.somsanith-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.somsanith-chat-messages::-webkit-scrollbar-thumb {
    background: #d0d0d0;
    border-radius: 10px;
}

/* Message Bubbles */
.somsanith-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.6;
    word-wrap: break-word;
    animation: somsanithMsgIn 0.2s ease;
}

@keyframes somsanithMsgIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.somsanith-msg.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #f7971e, #ffd200);
    color: #111;
    border-bottom-right-radius: 4px;
}

.somsanith-msg.ai {
    align-self: flex-start;
    background: #ffffff;
    color: #222;
    border: 1px solid #e5e5e5;
    border-bottom-left-radius: 4px;
}

.somsanith-msg.ai .somsanith-msg-label {
    font-size: 10px;
    font-weight: 700;
    color: #999;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.somsanith-msg .somsanith-msg-time {
    font-size: 10px;
    color: #999;
    margin-top: 4px;
    display: block;
}

.somsanith-msg.user .somsanith-msg-time {
    color: rgba(0, 0, 0, 0.4);
}

.somsanith-msg.ai code {
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
}

/* ============================================================
   COPY BUTTON — matches main somsanith-ai page (app.js)
   ============================================================ */

.somsanith-msg .somsanith-msg-content {
    position: relative;
}

.somsanith-copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 4px 10px;
    border: none;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.06);
    color: #666;
    font-size: 13px;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
    font-family: inherit;
    z-index: 5;
}

.somsanith-msg:hover .somsanith-copy-btn {
    opacity: 1;
}

.somsanith-copy-btn:hover {
    background: rgba(0, 0, 0, 0.12);
    color: #222;
}

.somsanith-copy-btn.copied {
    background: #4caf50;
    color: #fff;
}

.somsanith-copy-btn.copied:hover {
    background: #388e3c;
    color: #fff;
}

.somsanith-copy-btn svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
    flex: 0 0 auto;
}

/* Typing Indicator */
.somsanith-typing {
    align-self: flex-start;
    background: #ffffff;
    border: 1px solid #e5e5e5;
    padding: 12px 18px;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.somsanith-typing span {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #999;
    animation: somsanithTypingBounce 1.4s infinite ease-in-out;
}

.somsanith-typing span:nth-child(2) {
    animation-delay: 0.2s;
}
.somsanith-typing span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes somsanithTypingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* Widget Input */
.somsanith-chat-input {
    padding: 12px 16px;
    border-top: 1px solid #e5e5e5;
    display: flex;
    gap: 8px;
    background: #ffffff;
    flex-shrink: 0;
}

.somsanith-chat-input textarea {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 14px;
    resize: none;
    outline: none;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    min-height: 40px;
    max-height: 100px;
    line-height: 1.5;
    transition: border-color 0.2s;
}

.somsanith-chat-input textarea:focus {
    border-color: #f7971e;
}

.somsanith-chat-input textarea::placeholder {
    color: #aaa;
}

.somsanith-chat-send {
    padding: 8px 16px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #f7971e, #ffd200);
    color: #111;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.somsanith-chat-send:hover {
    opacity: 0.85;
    transform: scale(0.98);
}

.somsanith-chat-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 640px) {
    .somsanith-float-chat {
        bottom: 16px;
        right: 16px;
    }

    .somsanith-chat-btn {
        width: 56px;
        height: 56px;
        font-size: 26px;
    }

    .somsanith-chat-widget {
        bottom: 80px;
        right: 12px;
        width: calc(100vw - 24px);
        height: calc(100vh - 160px);
        max-height: 500px;
        border-radius: 12px;
    }

    .somsanith-chat-header {
        padding: 12px 16px;
    }

    .somsanith-chat-header-title {
        font-size: 14px;
    }

    .somsanith-chat-messages {
        padding: 12px 14px;
    }

    .somsanith-msg {
        font-size: 13px;
        padding: 8px 12px;
    }

    .somsanith-chat-input {
        padding: 8px 12px;
    }

    .somsanith-chat-input textarea {
        font-size: 13px;
        min-height: 36px;
    }

    .somsanith-chat-send {
        font-size: 13px;
        padding: 6px 14px;
    }

    /* Always show copy button on touch devices (no hover) */
    .somsanith-copy-btn {
        opacity: 1;
        background: rgba(0, 0, 0, 0.08);
        padding: 4px 8px;
        font-size: 12px;
    }
}