/* Nyaa Chat Bot Frontend Styles */
:root {
    --nyaa-primary: #6366f1;
    --nyaa-primary-dark: #4338ca;
    --nyaa-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #4f46e5 100%);
    --nyaa-bg-glass: rgba(255, 255, 255, 0.98);
    --nyaa-shadow: 0 12px 36px rgba(99, 102, 241, 0.28), 0 4px 14px rgba(0, 0, 0, 0.1);
    --nyaa-radius: 18px;
    --nyaa-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.nyaa-theme-gradient-emerald {
    --nyaa-primary: #059669;
    --nyaa-primary-dark: #065f46;
    --nyaa-gradient: linear-gradient(135deg, #10b981 0%, #059669 50%, #047857 100%);
    --nyaa-shadow: 0 12px 36px rgba(16, 185, 129, 0.28), 0 4px 14px rgba(0, 0, 0, 0.1);
}

.nyaa-theme-gradient-cyan {
    --nyaa-primary: #0284c7;
    --nyaa-primary-dark: #0369a1;
    --nyaa-gradient: linear-gradient(135deg, #0ea5e9 0%, #0284c7 50%, #0369a1 100%);
    --nyaa-shadow: 0 12px 36px rgba(14, 165, 233, 0.28), 0 4px 14px rgba(0, 0, 0, 0.1);
}

/* Wrapper */
#nyaa-bot-wrapper {
    position: fixed;
    z-index: 9999999;
    font-family: var(--nyaa-font);
    user-select: none;
    box-sizing: border-box;
}

#nyaa-bot-wrapper * {
    box-sizing: border-box;
}

/* Draggable Launcher Button - Compact & Perfectly Sized */
#nyaa-draggable-launcher {
    position: fixed;
    bottom: 95px;
    right: 24px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--nyaa-gradient);
    color: #ffffff;
    padding: 6px 14px 6px 8px;
    border-radius: 40px;
    cursor: grab;
    box-shadow: var(--nyaa-shadow);
    border: 2px solid rgba(255, 255, 255, 0.5);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
    z-index: 10000000;
    touch-action: none;
    height: 46px;
    max-height: 46px;
}

#nyaa-draggable-launcher:active {
    cursor: grabbing;
    transform: scale(0.96);
}

#nyaa-draggable-launcher:hover {
    transform: translateY(-2px) scale(1.03);
    box-shadow: 0 16px 42px rgba(99, 102, 241, 0.35);
}

.nyaa-avatar-glow {
    position: absolute;
    top: -3px; left: -3px; right: -3px; bottom: -3px;
    border-radius: 40px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    animation: nyaa-pulse 2.5s infinite;
    pointer-events: none;
}

@keyframes nyaa-pulse {
    0% { transform: scale(0.97); opacity: 0.8; }
    50% { transform: scale(1.06); opacity: 0; }
    100% { transform: scale(1.08); opacity: 0; }
}

/* Launcher Icon Circle - Strictly 32x32px */
.nyaa-bot-icon-circle {
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
    max-width: 32px;
    max-height: 32px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    overflow: hidden;
    flex-shrink: 0;
    position: relative;
}

.nyaa-custom-avatar-img {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    min-width: 100% !important;
    min-height: 100% !important;
    object-fit: cover !important;
    border-radius: 50% !important;
    display: block !important;
    flex-shrink: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
}

.nyaa-bot-emoji {
    display: block;
    line-height: 1;
    font-size: 18px;
}

.nyaa-launcher-label {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.nyaa-drag-indicator {
    font-size: 13px;
    opacity: 0.65;
    cursor: grab;
    margin-left: 2px;
}

/* Chat Window Container */
.nyaa-chat-container {
    display: none;
    position: fixed;
    bottom: 95px;
    right: 24px;
    width: 380px;
    height: 570px;
    max-height: calc(100vh - 120px);
    background: var(--nyaa-bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.85);
    border-radius: var(--nyaa-radius);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.18), 0 8px 24px rgba(99, 102, 241, 0.15);
    flex-direction: column;
    overflow: hidden;
    z-index: 10000001;
    animation: nyaa-slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.nyaa-chat-container.active {
    display: flex;
}

@keyframes nyaa-slideUp {
    from { opacity: 0; transform: translateY(18px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Chat Header */
.nyaa-chat-header {
    background: var(--nyaa-gradient);
    color: #ffffff;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.nyaa-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nyaa-header-avatar {
    position: relative;
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    max-width: 36px;
    max-height: 36px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 19px;
    overflow: hidden;
    flex-shrink: 0;
}

.nyaa-header-avatar-img {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: cover !important;
    border-radius: 50% !important;
    display: block !important;
}

.nyaa-online-dot {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 9px;
    height: 9px;
    background: #10b981;
    border: 2px solid #ffffff;
    border-radius: 50%;
    z-index: 2;
}

.nyaa-header-info h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.2;
}

.nyaa-header-info p {
    margin: 2px 0 0;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.9);
}

.nyaa-fcc-badge {
    background: rgba(255, 255, 255, 0.25);
    padding: 1px 5px;
    border-radius: 4px;
    font-weight: 700;
    font-size: 10px;
}

.nyaa-header-actions {
    display: flex;
    gap: 6px;
}

.nyaa-header-actions button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #ffffff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.15s;
    padding: 0;
}

.nyaa-header-actions button:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: scale(1.08);
}

/* Confirm Modal Overlay */
.nyaa-confirm-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(4px);
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: nyaa-fadeIn 0.2s ease;
}

.nyaa-confirm-box {
    background: #ffffff;
    border-radius: 16px;
    padding: 22px 20px;
    text-align: center;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.25);
    max-width: 300px;
}

.nyaa-confirm-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.nyaa-confirm-box h4 {
    margin: 0 0 6px;
    font-size: 16px;
    color: #0f172a;
    font-weight: 700;
}

.nyaa-confirm-box p {
    margin: 0 0 16px;
    font-size: 12.5px;
    color: #64748b;
    line-height: 1.4;
}

.nyaa-confirm-actions {
    display: flex;
    gap: 8px;
}

.nyaa-btn-danger {
    flex: 1;
    background: #ef4444;
    color: #ffffff;
    border: none;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
}

.nyaa-btn-danger:hover {
    background: #dc2626;
}

.nyaa-btn-cancel {
    flex: 1;
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #cbd5e1;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.nyaa-btn-cancel:hover {
    background: #e2e8f0;
}

/* Pre-Chat Onboarding Card */
.nyaa-onboarding-card {
    padding: 28px 24px;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    background: #ffffff;
}

.nyaa-onboarding-icon {
    width: 60px;
    height: 60px;
    min-width: 60px;
    min-height: 60px;
    max-width: 60px;
    max-height: 60px;
    border-radius: 50%;
    background: #e0e7ff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    margin-bottom: 12px;
    overflow: hidden;
    border: 2px solid var(--nyaa-primary);
}

.nyaa-onboarding-avatar-img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    border-radius: 50% !important;
    display: block !important;
}

.nyaa-onboarding-card h4 {
    margin: 0 0 6px;
    font-size: 17px;
    color: #0f172a;
    font-weight: 700;
}

.nyaa-onboarding-card p {
    margin: 0 0 18px;
    font-size: 12.5px;
    color: #64748b;
    line-height: 1.45;
}

#nyaa-onboarding-form {
    width: 100%;
    text-align: left;
}

.nyaa-field-group {
    margin-bottom: 12px;
}

.nyaa-field-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #334155;
    margin-bottom: 4px;
}

.nyaa-field-group input {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid #cbd5e1;
    border-radius: 10px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.nyaa-field-group input:focus {
    border-color: var(--nyaa-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

#nyaa-btn-start-chat {
    width: 100%;
    background: var(--nyaa-gradient);
    color: #ffffff;
    border: none;
    padding: 11px;
    border-radius: 10px;
    font-size: 13.5px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.3);
    transition: transform 0.2s, box-shadow 0.2s;
    margin-top: 6px;
}

#nyaa-btn-start-chat:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(99, 102, 241, 0.4);
}

/* Chat Body */
.nyaa-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8fafc;
}

.nyaa-msg-row {
    display: flex;
    gap: 8px;
    max-width: 88%;
}

.nyaa-msg-row.bot, .nyaa-msg-row.agent {
    align-self: flex-start;
}

.nyaa-msg-row.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.nyaa-msg-row.system {
    align-self: center;
    max-width: 94%;
}

.nyaa-msg-avatar {
    width: 30px;
    height: 30px;
    min-width: 30px;
    min-height: 30px;
    max-width: 30px;
    max-height: 30px;
    background: #e0e7ff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    flex-shrink: 0;
    overflow: hidden;
}

.nyaa-msg-avatar-img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    border-radius: 50% !important;
    display: block !important;
}

.nyaa-msg-row.user .nyaa-msg-avatar {
    background: var(--nyaa-primary);
    color: #ffffff;
}

.nyaa-msg-row.agent .nyaa-msg-avatar {
    background: #10b981;
    color: #ffffff;
}

.nyaa-msg-bubble {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.45;
    word-break: break-word;
}

.nyaa-msg-row.bot .nyaa-msg-bubble {
    background: #ffffff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-top-left-radius: 4px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.nyaa-msg-row.agent .nyaa-msg-bubble {
    background: #ffffff;
    color: #0f172a;
    border-left: 3px solid #10b981;
    border: 1px solid #d1fae5;
    border-left-width: 3px;
    border-top-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.1);
}

.nyaa-msg-row.agent .nyaa-msg-bubble strong {
    color: #059669;
    display: block;
    margin-bottom: 2px;
    font-size: 11.5px;
}

.nyaa-msg-row.user .nyaa-msg-bubble {
    background: var(--nyaa-gradient);
    color: #ffffff;
    border-top-right-radius: 4px;
    box-shadow: 0 3px 10px rgba(99, 102, 241, 0.2);
}

.nyaa-msg-row.system .nyaa-msg-bubble {
    background: #e2e8f0;
    color: #334155;
    font-size: 11.5px;
    border-radius: 10px;
    padding: 6px 12px;
    text-align: center;
}

.nyaa-msg-bubble p {
    margin: 0 0 4px;
}
.nyaa-msg-bubble p:last-child {
    margin: 0;
}

/* Live Agent Status Banner */
.nyaa-agent-banner {
    background: #ecfdf5;
    border-top: 1px solid #a7f3d0;
    border-bottom: 1px solid #a7f3d0;
    padding: 6px 14px;
}

.nyaa-agent-banner-inner {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11.5px;
    font-weight: 700;
    color: #065f46;
}

.nyaa-live-pulse {
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    animation: nyaa-blink 1.2s infinite;
}

/* Quick Chips */
.nyaa-quick-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}

.nyaa-chip {
    background: #ffffff;
    border: 1px solid var(--nyaa-primary);
    color: var(--nyaa-primary);
    padding: 5px 10px;
    border-radius: 16px;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.nyaa-chip:hover {
    background: var(--nyaa-primary);
    color: #ffffff;
    transform: translateY(-1px);
}

/* Cards (Social, FCC, Site Pages) */
.nyaa-social-cards-wrap {
    margin-top: 6px;
}

.nyaa-social-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-top: 6px;
}

.nyaa-soc-card {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 10px;
    border-radius: 8px;
    font-size: 11.5px;
    font-weight: 700;
    text-decoration: none;
    color: #ffffff !important;
    transition: transform 0.2s, box-shadow 0.2s;
    border: none;
    cursor: pointer;
}

.nyaa-soc-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 3px 10px rgba(0,0,0,0.15);
}

.nyaa-soc-card.tw { background: #000000; }
.nyaa-soc-card.mail { background: #ea4335; }
.nyaa-soc-card.tel { background: #0284c7; }
.nyaa-soc-card.live-btn { background: #10b981; }

.nyaa-ref-box {
    background: #f1f5f9;
    border-left: 4px solid var(--nyaa-primary);
    padding: 8px 12px;
    border-radius: 6px;
    margin-top: 6px;
}

.nyaa-ref-box strong {
    font-size: 12.5px;
    color: #0f172a;
}

.nyaa-ref-box p {
    font-size: 11.5px;
    color: #475569;
    margin: 3px 0 6px;
}

.nyaa-link-btn, .nyaa-read-btn {
    display: inline-block;
    background: var(--nyaa-primary);
    color: #ffffff !important;
    padding: 3px 8px;
    border-radius: 5px;
    font-size: 11px;
    font-weight: 700;
    text-decoration: none;
}

.nyaa-site-pages-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 6px;
}

.nyaa-page-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 8px 10px;
}

.nyaa-page-card strong a {
    color: #1e293b;
    text-decoration: none;
    font-size: 12.5px;
}

.nyaa-page-card p {
    font-size: 11px;
    color: #64748b;
    margin: 3px 0 6px;
}

/* Typing Indicator */
.nyaa-typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 14px 6px;
}

.nyaa-typing-bubble {
    background: #ffffff;
    padding: 6px 12px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    display: flex;
    gap: 4px;
}

.nyaa-typing-bubble span {
    width: 5px;
    height: 5px;
    background: #94a3b8;
    border-radius: 50%;
    animation: nyaa-blink 1.4s infinite both;
}

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

@keyframes nyaa-blink {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1.1); }
}

/* Chat Footer Input */
.nyaa-chat-footer {
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    padding: 10px 14px 8px;
    flex-shrink: 0;
}

#nyaa-chat-form {
    display: flex;
    gap: 8px;
}

#nyaa-user-input {
    flex: 1;
    padding: 9px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 20px;
    font-size: 12.5px;
    outline: none;
    transition: all 0.2s;
}

#nyaa-user-input:focus {
    border-color: var(--nyaa-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

#nyaa-btn-send {
    background: var(--nyaa-gradient);
    color: #ffffff;
    border: none;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
    padding: 0;
    flex-shrink: 0;
}

#nyaa-btn-send:hover {
    transform: scale(1.08);
}

.nyaa-footer-credits {
    text-align: center;
    font-size: 10px;
    color: #94a3b8;
    margin-top: 5px;
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    .nyaa-chat-container {
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        bottom: 0 !important;
        right: 0 !important;
        left: 0 !important;
        top: 0 !important;
        border-radius: 0;
    }
}
