/* Nyrge Chat Widget — Fully isolated styles */

.nyrge-chat-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 99998;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.nyrge-chat-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.nyrge-chat-btn svg {
    width: 28px;
    height: 28px;
    fill: #fff;
}

.nyrge-chat-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    line-height: 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', sans-serif;
}

.nyrge-chat-badge.has-unread {
    display: flex;
}

/* Panel */
.nyrge-chat-panel {
    position: fixed;
    bottom: 92px;
    right: 24px;
    width: 360px;
    height: 480px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    display: none;
    flex-direction: column;
    z-index: 99999;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', sans-serif;
    animation: nyrge-chat-slide-up 0.25s ease-out;
}

.nyrge-chat-panel.open {
    display: flex;
}

@keyframes nyrge-chat-slide-up {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header */
.nyrge-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    color: #fff;
    border-radius: 12px 12px 0 0;
    flex-shrink: 0;
}

.nyrge-chat-header-title {
    font-size: 15px;
    color: #fff;
    font-weight: 600;
    margin: 0;
}

.nyrge-chat-header-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    opacity: 0.8;
}

.nyrge-chat-header-close:hover {
    opacity: 1;
}

/* Messages */
.nyrge-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.nyrge-chat-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.45;
    word-wrap: break-word;
    animation: nyrge-chat-fade 0.2s ease;
}

@keyframes nyrge-chat-fade {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.nyrge-chat-msg-visitor {
    align-self: flex-end;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.nyrge-chat-msg-agent,
.nyrge-chat-msg-ai {
    align-self: flex-start;
    background: #f3f4f6;
    color: #1f2937;
    border-bottom-left-radius: 4px;
}

.nyrge-chat-msg-ai {
    background: #ede9fe;
    color: #5b21b6;
}

.nyrge-chat-msg-system {
    align-self: center;
    background: #fef3c7;
    color: #92400e;
    font-size: 12px;
    font-style: italic;
    border-radius: 8px;
    max-width: 90%;
    text-align: center;
}

.nyrge-chat-msg-name {
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 2px;
    opacity: 0.7;
}

/* Typing indicator */
.nyrge-chat-typing {
    align-self: flex-start;
    background: #f3f4f6;
    padding: 10px 18px;
    border-radius: 16px;
    display: none;
}

.nyrge-chat-typing.active {
    display: flex;
    gap: 4px;
    align-items: center;
}

.nyrge-chat-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #9ca3af;
    animation: nyrge-chat-dot 1.2s infinite ease-in-out;
}

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

@keyframes nyrge-chat-dot {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* Input area */
.nyrge-chat-input-area {
    display: flex;
    align-items: center;
    padding: 12px;
    border-top: 1px solid #e5e7eb;
    gap: 8px;
    flex-shrink: 0;
}

.nyrge-chat-input {
    flex: 1;
    border: 1px solid #d1d5db;
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    resize: none;
    line-height: 1.4;
}

.nyrge-chat-input:focus {
    border-color: #0066ff;
    box-shadow: 0 0 0 2px rgba(0, 102, 255, 0.15);
}

.nyrge-chat-send {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.15s;
}

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

.nyrge-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.nyrge-chat-send svg {
    width: 18px;
    height: 18px;
    fill: #fff;
}

/* Intro form */
.nyrge-chat-intro {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.nyrge-chat-intro label {
    font-size: 13px;
    font-weight: 500;
    color: #374151;
}

.nyrge-chat-intro input {
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
}

.nyrge-chat-intro input:focus {
    border-color: #0066ff;
}

.nyrge-chat-intro-btn {
    border: none;
    color: #fff;
    padding: 10px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 4px;
    font-family: inherit;
}

/* Offline message */
.nyrge-chat-offline {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    text-align: center;
    color: #6b7280;
    font-size: 14px;
    line-height: 1.5;
}

/* Mobile responsive */
@media (max-width: 480px) {
    .nyrge-chat-panel {
        width: calc(100vw - 16px);
        height: calc(100vh - 120px);
        bottom: 80px;
        right: 8px;
        border-radius: 12px;
    }

    .nyrge-chat-btn {
        bottom: 16px;
        right: 16px;
    }
}
