/* ==========================================================================
   LIBRYZO BOOK AI MODAL & PERMANENT FLOATING LAUNCHER
   ========================================================================== */

/* Floating Launcher Button (Permanent on screen) */
.book-ai-fab-btn {
    position: fixed !important;
    bottom: 26px !important;
    right: 26px !important;
    z-index: 99990 !important;
    display: inline-flex !important;
    align-items: center;
    gap: 10px;
    padding: 12px 20px 12px 16px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    background: linear-gradient(135deg, #c72832 0%, #8b1119 50%, #d8ad52 140%);
    color: #ffffff !important;
    box-shadow:
        0 14px 34px rgba(0, 0, 0, 0.45),
        0 0 24px rgba(199, 40, 50, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.35);
    cursor: pointer !important;
    pointer-events: auto !important;
    user-select: none;
    touch-action: manipulation;
    font-family: var(--font-inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s ease, filter 0.25s ease;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.book-ai-fab-btn:hover {
    transform: translateY(-3px) scale(1.04);
    box-shadow:
        0 18px 42px rgba(0, 0, 0, 0.55),
        0 0 32px rgba(216, 173, 82, 0.55),
        inset 0 1px 0 rgba(255, 255, 255, 0.45);
    filter: brightness(1.1);
    color: #ffffff;
}

.book-ai-fab-btn:active {
    transform: translateY(0) scale(0.97);
}

.book-ai-fab-icon {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.28);
    font-size: 1.15rem;
    color: #ffe699;
}

.book-ai-fab-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #10b981;
    border: 2px solid #8b1119;
    box-shadow: 0 0 8px #10b981;
    animation: fabPulse 2s infinite;
}

@keyframes fabPulse {
    0% { transform: scale(0.9); opacity: 0.8; }
    50% { transform: scale(1.3); opacity: 1; }
    100% { transform: scale(0.9); opacity: 0.8; }
}

.book-ai-fab-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.book-ai-fab-pill {
    padding: 2px 7px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 800;
    background: rgba(255, 255, 255, 0.2);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

/* Modal Overlay & Dialog */
.book-ai-modal-overlay {
    position: fixed !important;
    inset: 0 !important;
    z-index: 99999 !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.book-ai-modal-overlay.active {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
}

.book-ai-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(4, 8, 16, 0.78);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.book-ai-modal-dialog {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 820px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    transform: scale(0.94) translateY(18px);
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.book-ai-modal-overlay.active .book-ai-modal-dialog {
    transform: scale(1) translateY(0);
}

.book-ai-modal-card {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-height: 88vh;
    border-radius: 22px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: #091120;
    background: linear-gradient(165deg, rgba(16, 25, 44, 0.96) 0%, rgba(9, 17, 32, 0.98) 100%);
    box-shadow:
        0 24px 60px rgba(0, 0, 0, 0.7),
        0 0 35px rgba(199, 40, 50, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
    overflow: hidden;
}

/* Modal Topbar */
.book-ai-modal-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(14, 23, 42, 0.65);
    backdrop-filter: blur(10px);
    flex-shrink: 0;
}

.book-ai-modal-title-group {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.book-ai-modal-icon-badge {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(199, 40, 50, 0.35), rgba(216, 173, 82, 0.35));
    border: 1px solid rgba(255, 255, 255, 0.16);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #f7d27e;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.book-ai-modal-icon-badge .ai-pulse-dot {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #10b981;
    border: 2px solid #091120;
}

.book-ai-modal-eyebrow {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.76rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.65);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 2px;
}

.book-ai-modal-eyebrow .ai-status-indicator {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 6px #10b981;
}

.book-ai-usage-pill {
    background: rgba(216, 173, 82, 0.15);
    border: 1px solid rgba(216, 173, 82, 0.3);
    color: #f7d27e;
    padding: 1px 7px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
}

.book-ai-modal-title {
    margin: 0;
    font-family: var(--font-playfair, Georgia, serif);
    font-size: 1.05rem;
    font-weight: 700;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.book-ai-modal-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.book-ai-modal-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.8);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.95rem;
    transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.book-ai-modal-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    transform: scale(1.05);
}

.book-ai-modal-close:hover {
    background: rgba(239, 51, 64, 0.22);
    border-color: rgba(239, 51, 64, 0.45);
    color: #ff6b74;
}

/* Modal Shell Customizations */
.book-ai-shell-modal {
    display: flex !important;
    flex-direction: column !important;
    grid-template-columns: none !important;
    min-height: 0 !important;
    max-height: calc(88vh - 70px) !important;
    height: 600px;
    border: none !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
}

.book-ai-shell-modal .book-ai-chat {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    background: transparent;
}

.book-ai-shell-modal .book-ai-messages {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    padding: 18px 20px;
}

.book-ai-shell-modal .book-ai-welcome {
    margin-top: 10px;
    padding: 16px 12px;
}

.book-ai-shell-modal .book-ai-prompts {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
}

.book-ai-shell-modal .book-ai-composer-wrap {
    flex-shrink: 0;
    padding: 12px 18px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(8, 14, 26, 0.7);
}

/* Responsive adjustments */
@media (max-width: 640px) {
    .book-ai-fab-btn {
        bottom: 20px !important;
        right: 18px !important;
        padding: 10px 14px 10px 12px;
        font-size: 0.88rem;
    }

    .book-ai-fab-icon {
        width: 28px;
        height: 28px;
        font-size: 1rem;
    }

    .book-ai-modal-overlay {
        padding: 0 !important;
        align-items: flex-end !important;
    }

    .book-ai-modal-dialog {
        max-width: 100%;
        max-height: 94vh;
        transform: translateY(100%);
    }

    .book-ai-modal-overlay.active .book-ai-modal-dialog {
        transform: translateY(0);
    }

    .book-ai-modal-card {
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
        max-height: 94vh;
        height: 94vh;
    }

    .book-ai-shell-modal {
        height: calc(94vh - 66px) !important;
        max-height: calc(94vh - 66px) !important;
    }

    .book-ai-shell-modal .book-ai-prompts {
        grid-template-columns: 1fr;
    }

    .book-ai-modal-title {
        max-width: 180px;
        font-size: 0.95rem;
    }
}
