/**
 * ==========================================================================
 * IINSHA AI-BOS 2.0 — NEXT-GEN GEMINI / COPILOT / CHATGPT GLASS CHATBOX UI
 * Ultra-Modern Obsidian Glass Design, Floating Pill Input Dock,
 * Animated AI Sparkle Orb, Multi-turn Generative UI Cards
 * ==========================================================================
 */

:root {
    --copilot-bg: rgba(13, 17, 23, 0.92);
    --copilot-surface: rgba(22, 27, 34, 0.85);
    --copilot-card: rgba(30, 41, 59, 0.7);
    --copilot-border: rgba(255, 255, 255, 0.12);
    --copilot-border-glow: rgba(99, 102, 241, 0.35);
    --copilot-cyan: #38bdf8;
    --copilot-indigo: #6366f1;
    --copilot-purple: #a855f7;
    --copilot-emerald: #10b981;
    --copilot-amber: #f59e0b;
    --copilot-text: #f8fafc;
    --copilot-text-muted: #94a3b8;
    --copilot-font: 'Inter', system-ui, -apple-system, sans-serif;
    --copilot-radius-window: 24px;
    --copilot-radius-bubble: 18px;
    --copilot-radius-pill: 9999px;
}

/* ==========================================================================
   1. FLOATING LAUNCHER (Gemini Sparkle + Copilot Gradient Pill)
   ========================================================================== */
#iinsha-copilot-trigger,
.iinsha-cockpit-launcher {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(15, 23, 42, 0.88);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 8px 18px 8px 10px;
    border-radius: var(--copilot-radius-pill);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 25px rgba(99, 102, 241, 0.3);
    cursor: pointer;
    transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    user-select: none;
    font-family: var(--copilot-font);
}

#iinsha-copilot-trigger:hover,
.iinsha-cockpit-launcher:hover {
    transform: translateY(-4px) scale(1.03);
    border-color: var(--copilot-cyan);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.7), 0 0 35px rgba(99, 102, 241, 0.55);
}

.copilot-trigger-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #38bdf8 0%, #6366f1 50%, #a855f7 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: 0 0 16px rgba(99, 102, 241, 0.6);
    flex-shrink: 0;
}

.copilot-trigger-avatar svg {
    width: 22px;
    height: 22px;
    filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.8));
    animation: sparkleSpin 8s linear infinite;
}

@keyframes sparkleSpin {
    0% { transform: rotate(0deg) scale(1); }
    50% { transform: rotate(180deg) scale(1.08); }
    100% { transform: rotate(360deg) scale(1); }
}

.copilot-trigger-status,
.cockpit-status-dot {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 12px;
    height: 12px;
    background: var(--copilot-emerald);
    border: 2px solid #0f172a;
    border-radius: 50%;
    box-shadow: 0 0 8px var(--copilot-emerald);
    animation: pulseStatus 2s infinite;
}

@keyframes pulseStatus {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.copilot-trigger-label {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
}

.copilot-trigger-title {
    font-size: 0.88rem;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: 0.3px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.copilot-trigger-subtitle {
    font-size: 0.72rem;
    color: var(--copilot-cyan);
    font-weight: 500;
}

/* Teaser Bubble */
#iinsha-copilot-teaser {
    position: fixed;
    bottom: 84px;
    right: 24px;
    z-index: 99998;
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(20px);
    padding: 12px 16px;
    border-radius: 16px;
    max-width: 290px;
    box-shadow: 0 12px 35px rgba(0,0,0,0.5), 0 0 20px rgba(99, 102, 241, 0.2);
    font-size: 0.8rem;
    color: #e2e8f0;
    line-height: 1.45;
    animation: fadeInSlide 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-family: var(--copilot-font);
}

#iinsha-copilot-teaser .teaser-close {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 0.75rem;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

#iinsha-copilot-teaser .teaser-close:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

/* ==========================================================================
   2. MAIN CHAT WINDOW CONTAINER (ChatGPT / Gemini Obsidian Glass Aesthetic)
   ========================================================================== */
#iinsha-copilot-window,
.iinsha-cockpit-modal {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 440px;
    height: 660px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 48px);
    background: var(--copilot-bg);
    backdrop-filter: blur(28px) saturate(190%);
    -webkit-backdrop-filter: blur(28px) saturate(190%);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: var(--copilot-radius-window);
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.85), 
                0 0 40px rgba(99, 102, 241, 0.25),
                inset 0 1px 1px rgba(255, 255, 255, 0.15);
    z-index: 100000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    animation: chatOpen 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    font-family: var(--copilot-font);
}

@keyframes chatOpen {
    from { opacity: 0; transform: translateY(30px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

#iinsha-copilot-window.hidden {
    display: none !important;
}

#iinsha-copilot-window.expanded,
#iinsha-copilot-window.fullscreen {
    width: 860px;
    height: 82vh;
    max-width: 94vw;
}

/* ==========================================================================
   3. CHAT HEADER BAR
   ========================================================================== */
.copilot-header,
.cockpit-header-bar {
    background: rgba(15, 23, 42, 0.95);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
    flex-shrink: 0;
}

.copilot-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.copilot-header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    background: linear-gradient(135deg, #38bdf8 0%, #6366f1 50%, #a855f7 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 14px rgba(99, 102, 241, 0.5);
    flex-shrink: 0;
}

.copilot-header-avatar svg {
    width: 20px;
    height: 20px;
}

.copilot-header-meta h4 {
    margin: 0;
    font-size: 0.92rem;
    font-weight: 700;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: 0.2px;
}

.copilot-online-badge {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.4);
    color: #34d399;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: var(--copilot-radius-pill);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.copilot-online-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 6px #10b981;
}

.copilot-header-meta span {
    font-size: 0.72rem;
    color: var(--copilot-text-muted);
    font-weight: 500;
    display: block;
    margin-top: 2px;
}

.copilot-header-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.copilot-ctrl-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #cbd5e1;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.copilot-ctrl-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    border-color: var(--copilot-cyan);
    transform: translateY(-1px);
}

.copilot-ctrl-btn.active {
    background: rgba(99, 102, 241, 0.25);
    color: var(--copilot-cyan);
    border-color: var(--copilot-cyan);
}

/* ==========================================================================
   4. QUICK ACTION CHIPS (Gemini Style Suggestion Pills)
   ========================================================================== */
.copilot-chips-bar {
    padding: 10px 14px;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    background: rgba(15, 23, 42, 0.6);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
}

.copilot-chips-bar::-webkit-scrollbar {
    display: none;
}

.copilot-chip {
    white-space: nowrap;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--copilot-radius-pill);
    padding: 6px 14px;
    font-size: 0.74rem;
    font-weight: 500;
    color: #e2e8f0;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    align-items: center;
    gap: 6px;
    user-select: none;
}

.copilot-chip:hover {
    background: rgba(99, 102, 241, 0.2);
    border-color: var(--copilot-cyan);
    color: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}

/* ==========================================================================
   5. MESSAGES STREAM & BUBBLES (ChatGPT / Gemini Markdown & Cards)
   ========================================================================== */
.copilot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scroll-behavior: smooth;
}

/* Custom Sleek Scrollbar */
.copilot-messages::-webkit-scrollbar {
    width: 6px;
}
.copilot-messages::-webkit-scrollbar-track {
    background: transparent;
}
.copilot-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}
.copilot-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.copilot-msg {
    max-width: 88%;
    font-size: 0.86rem;
    line-height: 1.6;
    word-break: break-word;
    animation: fadeInSlide 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.copilot-msg.copilot-msg-user,
.copilot-msg.user {
    align-self: flex-end;
}

.copilot-msg.copilot-msg-user .copilot-bubble,
.copilot-msg.user {
    background: linear-gradient(135deg, #4f46e5 0%, #3b82f6 100%);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #ffffff;
    padding: 10px 16px;
    border-radius: 20px 20px 4px 20px;
    box-shadow: 0 6px 18px rgba(79, 70, 229, 0.3);
}

.copilot-msg.copilot-msg-assistant,
.copilot-msg.assistant {
    align-self: flex-start;
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.copilot-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #38bdf8 0%, #6366f1 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.4);
}

.copilot-msg-avatar svg {
    width: 16px;
    height: 16px;
}

.copilot-msg.copilot-msg-assistant .copilot-bubble,
.copilot-msg.assistant {
    background: var(--copilot-surface);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #e2e8f0;
    padding: 12px 16px;
    border-radius: 4px 20px 20px 20px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

/* Rich Dynamic Interactive Cards Inside Chat */
.copilot-rich-card {
    background: var(--copilot-card);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    padding: 14px;
    margin-top: 10px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.35);
    transition: all 0.25s ease;
}

.copilot-rich-card:hover {
    border-color: var(--copilot-cyan);
    transform: translateY(-2px);
}

.copilot-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.copilot-card-title {
    font-weight: 700;
    color: #ffffff;
    font-size: 0.88rem;
}

.copilot-card-badge {
    background: rgba(56, 189, 248, 0.15);
    border: 1px solid rgba(56, 189, 248, 0.4);
    color: var(--copilot-cyan);
    font-size: 0.66rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.copilot-card-pricing {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin: 8px 0 12px 0;
}

.copilot-card-usd {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--copilot-amber);
}

.copilot-card-bdt {
    font-size: 0.78rem;
    color: #94a3b8;
}

.copilot-card-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.copilot-btn-sm {
    background: linear-gradient(135deg, #38bdf8 0%, #6366f1 100%);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    padding: 7px 14px;
    font-size: 0.76rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.copilot-btn-sm:hover {
    transform: translateY(-1px) scale(1.02);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.5);
}

.copilot-btn-outline-sm {
    background: rgba(255, 255, 255, 0.05);
    color: #e2e8f0;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 7px 14px;
    font-size: 0.76rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.copilot-btn-outline-sm:hover {
    border-color: var(--copilot-cyan);
    color: var(--copilot-cyan);
    background: rgba(56, 189, 248, 0.1);
}

/* Typing & Reasoning Indicator */
.copilot-typing {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--copilot-surface);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 10px 14px;
    border-radius: 16px;
    align-self: flex-start;
    font-size: 0.78rem;
    color: var(--copilot-cyan);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.copilot-dot {
    width: 6px;
    height: 6px;
    background: var(--copilot-cyan);
    border-radius: 50%;
    animation: typingPulse 1.4s infinite ease-in-out both;
}

.copilot-dot:nth-child(2) { animation-delay: -0.32s; }
.copilot-dot:nth-child(3) { animation-delay: -0.16s; }

@keyframes typingPulse {
    0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* ==========================================================================
   6. BOTTOM FLOATING PILL INPUT DOCK (ChatGPT / Gemini Style)
   ========================================================================== */
.copilot-footer {
    padding: 12px 16px 14px 16px;
    background: rgba(15, 23, 42, 0.95);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.copilot-input-container {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(22, 27, 34, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 28px;
    padding: 4px 6px 4px 14px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    transition: all 0.25s ease;
}

.copilot-input-container:focus-within {
    border-color: var(--copilot-indigo);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25), 0 4px 20px rgba(0, 0, 0, 0.4);
}

.copilot-textarea,
.copilot-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #ffffff;
    font-size: 0.88rem;
    line-height: 1.4;
    resize: none;
    max-height: 100px;
    padding: 6px 0;
    font-family: var(--copilot-font);
}

.copilot-textarea::placeholder,
.copilot-input::placeholder {
    color: #64748b;
    font-size: 0.84rem;
}

.copilot-icon-btn {
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: #94a3b8;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.copilot-icon-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    transform: scale(1.05);
}

.copilot-send-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1 0%, #38bdf8 100%);
    border: none;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.copilot-send-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 18px rgba(99, 102, 241, 0.6);
}

.copilot-send-btn svg {
    width: 16px;
    height: 16px;
}

.copilot-footer-meta {
    text-align: center;
    margin-top: 6px;
    font-size: 0.68rem;
    color: #64748b;
    font-weight: 500;
}

@keyframes fadeInSlide {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   7. MOBILE RESPONSIVENESS
   ========================================================================== */
@media (max-width: 640px) {
    #iinsha-copilot-window,
    .iinsha-cockpit-modal {
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
        bottom: 0;
        right: 0;
        border-radius: 0;
    }
    #iinsha-copilot-trigger,
    .iinsha-cockpit-launcher {
        bottom: 16px;
        right: 16px;
        padding: 6px 14px 6px 8px;
    }
}
