/* ===================================
   SPACE GAME ROOM - MODERN GLASS UI
   ================================== */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@400;500;700&display=swap');

:root {
    --fb-primary: #FF0080;
    /* Vibrant Pink */
    --fb-secondary: #7928CA;
    /* Deep Purple */
    --fb-accent: #00DFD8;
    /* Cyan */
    --fb-text: #ffffff;
    --fb-text-muted: rgba(255, 255, 255, 0.7);
    --fb-glass-bg: rgba(20, 20, 30, 0.75);
    --fb-glass-border: rgba(255, 255, 255, 0.15);
    --fb-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --fb-font: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --fb-ease: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Container */
#francisco-bot-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2147483647;
    /* Ensure top layer */
    font-family: var(--fb-font);
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    pointer-events: none;
    /* Let clicks pass through container area */
}

/* Allow pointer events on interactive children */
#francisco-bot-container>* {
    pointer-events: auto;
}

/* Toggle Button */
#fb-toggle-btn {
    width: 60px !important;
    height: 60px !important;
    min-width: 60px;
    min-height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--fb-primary), var(--fb-secondary));
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 20px rgba(255, 0, 128, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s var(--fb-ease), box-shadow 0.3s var(--fb-ease);
    position: relative;
    overflow: hidden;
    padding: 0;
}

#fb-toggle-btn::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.3s;
}

#fb-toggle-btn:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 8px 30px rgba(255, 0, 128, 0.6);
}

#fb-toggle-btn:hover::before {
    opacity: 1;
}

#fb-toggle-btn svg {
    width: 32px;
    height: 32px;
    stroke: white;
    /* Changed from fill to stroke for outline icons */
    fill: none;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
    display: block;
    /* Prevent collapse */
}

/* Chat Window */
.francisco-bot-widget {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 600px;
    max-height: calc(100vh - 120px);
    background: var(--fb-glass-bg);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border: 1px solid var(--fb-glass-border);
    border-radius: 20px;
    box-shadow: var(--fb-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transition: opacity 0.3s var(--fb-ease), transform 0.3s var(--fb-ease);
    pointer-events: none;
    transform-origin: bottom right;
}

.francisco-bot-widget.fb-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Header */
.fb-chat-header {
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid var(--fb-glass-border);
    padding: 14px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.fb-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.fb-brand-icon {
    font-size: 20px;
}

.fb-brand-text {
    display: flex;
    flex-direction: column;
}

.fb-title {
    font-size: 15px;
    font-weight: 700;
    color: white;
    letter-spacing: -0.01em;
}

.fb-status {
    font-size: 11px;
    color: var(--fb-accent);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
}

.fb-status::before {
    content: '';
    display: block;
    width: 6px;
    height: 6px;
    background: var(--fb-accent);
    border-radius: 50%;
    box-shadow: 0 0 6px var(--fb-accent);
}

.fb-header-actions button {
    background: none;
    border: none;
    color: var(--fb-text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    transition: all 0.2s;
    line-height: 0;
}

.fb-header-actions button:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

/* Messages Area */
.fb-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.fb-chat-messages::-webkit-scrollbar {
    width: 5px;
}

.fb-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.fb-message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    position: relative;
    animation: fb-fade-in 0.3s ease-out forwards;
}

@keyframes fb-fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fb-message.bot {
    align-self: flex-start;
}

.fb-message.user {
    align-self: flex-end;
    align-items: flex-end;
}

.fb-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.55;
    word-break: break-word;
    /* Ensure long words wrap */
    overflow-wrap: break-word;
    /* Additional safety for wrapping */
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    position: relative;
    max-width: 100%;
}

/* Bot Bubble Style */
.fb-message.bot .fb-bubble {
    background: #333340;
    color: #f0f0f0;
    border-bottom-left-radius: 4px;
    /* Default tail position for received messages usually */
    border-top-left-radius: 18px;
    /* Override previous if needed */
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* User Bubble Style */
.fb-message.user .fb-bubble {
    background: linear-gradient(135deg, var(--fb-primary), #D6006E);
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 3px 10px rgba(255, 0, 128, 0.2);
    border: none;
    text-align: right;
    /* Often user text aligns right */
}

.fb-message.user .fb-bubble p {
    margin: 0;
    text-align: left;
    /* Keep internal text readable */
}

/* Links & Sources */
.fb-citations {
    margin-top: 6px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.fb-source-tag {
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--fb-text-muted);
    border: 1px solid rgba(255, 255, 255, 0.1);
    text-decoration: none;
    transition: all 0.2s;
    display: inline-block;
}

.fb-source-tag--link:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border-color: var(--fb-accent);
}

/* Report Button */
.fb-report-area {
    margin-top: 6px;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.fb-message:hover .fb-report-area {
    opacity: 1;
}

.fb-report-btn {
    font-size: 10px;
    color: #aaa;
    background: transparent;
    border: 1px solid #555;
    padding: 2px 8px;
    border-radius: 99px;
    cursor: pointer;
}

.fb-report-btn:hover {
    color: white;
    border-color: #888;
}

/* Chips Area */
.fb-chips-area {
    padding: 10px 16px;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    -webkit-mask-image: linear-gradient(to right, black 90%, transparent 100%);
    mask-image: linear-gradient(to right, black 90%, transparent 100%);
}

.fb-chips-area::-webkit-scrollbar {
    display: none;
}

.fb-chip {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: white;
    padding: 8px 14px;
    border-radius: 18px;
    font-size: 13px;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.fb-chip:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: var(--fb-accent);
    transform: translateY(-1px);
}

/* Input Area */
.fb-chat-input-area {
    padding: 14px 18px;
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    gap: 10px;
    align-items: center;
    border-top: 1px solid var(--fb-glass-border);
}

#fb-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 10px 16px;
    color: white;
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
}

#fb-input:focus {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--fb-accent);
    box-shadow: 0 0 0 1px rgba(0, 223, 216, 0.2);
}

#fb-input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

#fb-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--fb-accent);
    /* Cyan color by default */
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

#fb-send-btn:hover {
    transform: scale(1.1);
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    /* White on hover */
    box-shadow: 0 0 15px rgba(0, 223, 216, 0.4);
    /* Cyan glow */
}

#fb-send-btn svg {
    width: 24px !important;
    height: 24px !important;
    min-width: 24px;
    min-height: 24px;
    stroke: currentColor;
    fill: none;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
    display: block !important;
    transition: transform 0.3s ease;
}

#fb-send-btn:hover svg {
    transform: translate(2px, -2px) rotate(-5deg);
    /* Fly effect */
    filter: drop-shadow(0 0 5px var(--fb-accent));
}

#fb-send-btn:disabled {
    background: transparent;
    opacity: 0.3;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Loading Spinner */
.fb-loading {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: var(--fb-accent);
    animation: fb-spin 0.8s linear infinite;
    display: inline-block;
    vertical-align: middle;
    margin-right: 6px;
}

@keyframes fb-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    .francisco-bot-widget {
        width: calc(100vw - 32px);
        height: min(600px, calc(100vh - 100px));
        bottom: 90px;
        right: 16px;
        border-radius: 20px;
    }

    #fb-toggle-btn {
        width: 56px;
        height: 56px;
    }
}

/* Store Selector */
.fb-store-selector {
    padding: 10px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    margin-top: 10px;
}

.fb-selector-title {
    text-align: center;
    color: #eee;
    font-size: 13px;
    margin-bottom: 8px;
    font-weight: 600;
}

.fb-store-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.fb-store-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ddd;
    padding: 8px;
    border-radius: 8px;
    font-size: 12px;
    cursor: pointer;
    text-align: left;
}

.fb-store-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}

/* ===================================
   CS FEATURES: GRID & CARDS
   =================================== */

/* Quick Action Grid */
.fb-quick-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-top: 10px;
    padding: 0 4px;
}

.fb-action-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--fb-text);
    text-align: center;
}

.fb-action-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--fb-accent);
    transform: translateY(-2px);
}

.fb-action-icon {
    font-size: 20px;
}

.fb-action-label {
    font-size: 12px;
    font-weight: 500;
}

/* Card UI */
.fb-card {
    background: rgba(30, 30, 40, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    overflow: hidden;
    margin-top: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    max-width: 280px;
}

.fb-card-img {
    width: 100%;
    height: 120px;
    background-color: #333;
    object-fit: cover;
}

.fb-card-content {
    padding: 12px 15px;
}

.fb-card-title {
    font-size: 14px;
    font-weight: 700;
    color: white;
    margin-bottom: 4px;
}

.fb-card-desc {
    font-size: 12px;
    color: var(--fb-text-muted);
    line-height: 1.4;
    margin-bottom: 12px;
}

.fb-card-actions {
    display: flex;
    gap: 6px;
}

.fb-card-btn {
    flex: 1;
    padding: 8px 0;
    text-align: center;
    background: var(--fb-primary);
    color: white;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: opacity 0.2s;
}

.fb-card-btn:hover {
    opacity: 0.9;
    color: white;
}

.fb-card-btn.secondary {
    background: rgba(255, 255, 255, 0.1);
}

/* ===================================
   INLINE SHORTCODE MODE
   =================================== */
#francisco-bot-container.fb-mode-inline {
    position: relative;
    top: auto;
    bottom: auto;
    left: auto;
    right: auto;
    width: 100%;
    height: 100%;
    min-height: 600px;
    z-index: 10;
    align-items: center;
    justify-content: center;
    margin: 20px 0;
}

#francisco-bot-container.fb-mode-inline #fb-toggle-btn {
    display: none !important;
}

.francisco-bot-widget.fb-mode-inline {
    position: relative;
    bottom: auto;
    right: auto;
    width: 100%;
    height: 100%;
    min-height: 600px;
    opacity: 1;
    transform: none;
    display: flex !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}


/* Mobile Fullscreen for Inline Mode */
@media (max-width: 480px) {
    #francisco-bot-container.fb-mode-inline {
        /* Force full screen overlay on mobile */
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100dvh;
        margin: 0;
        z-index: 999999;
        background: #000;
        /* Fallback bg */
    }

    .francisco-bot-widget.fb-mode-inline {
        width: 100% !important;
        height: 100% !important;
        max-height: none !important;
        border-radius: 0;
        border: none;
        box-shadow: none;
        background: var(--fb-glass-bg);
        /* Use theme bg */
        -webkit-backdrop-filter: blur(20px);
        backdrop-filter: blur(20px);
    }

    /* iPhone Safe Area Support */
    .francisco-bot-widget.fb-mode-inline .fb-chat-header {
        padding-top: max(14px, env(safe-area-inset-top));
    }

    .francisco-bot-widget.fb-mode-inline .fb-chat-input-area {
        padding-bottom: max(14px, env(safe-area-inset-bottom));
        background: rgba(20, 20, 30, 0.95);
        /* Slightly clearer bg for input */
    }

    .francisco-bot-widget.fb-mode-inline .fb-chat-messages {
        padding-bottom: 20px;
    }
}