/* ===================================
   JIJIMINGO BOT - CLEAN & WARM UI
   ================================== */

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

:root {
    --fb-primary: #FF9F43; /* Warm Orange */
    --fb-primary-dark: #EE5A24; /* Deep Orange */
    --fb-bg: #FFFFFF;
    --fb-text: #2d3436;
    --fb-text-muted: #636e72;
    --fb-bot-bubble: #f1f2f6;
    --fb-user-bubble: #FF9F43;
    --fb-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    --fb-border: #dfe6e9;
    --fb-font: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --fb-ease: cubic-bezier(0.4, 0, 0.2, 1);
    --fb-desktop-safe-offset: 24px;
    --fb-mobile-safe-offset: 28px;
    --fb-mobile-open-offset: 96px;
    --fb-mobile-open-height-offset: 124px;
}

/* Container */
#francisco-bot-container {
    position: fixed;
    right: 16px;
    left: auto;
    bottom: calc(var(--fb-desktop-safe-offset) + env(safe-area-inset-bottom));
    z-index: 2147483647;
    font-family: var(--fb-font);
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    pointer-events: none;
}

#francisco-bot-container > * {
    pointer-events: auto;
}

/* Toggle Button */
#fb-toggle-btn {
    width: 60px !important;
    height: 60px !important;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--fb-primary), var(--fb-primary-dark));
    border: none;
    box-shadow: 0 4px 15px rgba(255, 159, 67, 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);
    padding: 0;
}

#fb-toggle-btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 8px 25px rgba(255, 159, 67, 0.5);
}

#fb-toggle-btn svg {
    width: 30px;
    height: 30px;
    stroke: white;
    stroke-width: 2;
    fill: none;
}

/* Chat Window */
.francisco-bot-widget {
    position: absolute;
    right: 0;
    left: auto;
    bottom: 84px;
    width: 360px;
    max-width: calc(100% - 32px);
    height: min(600px, calc(100vh - 126px));
    max-height: min(600px, calc(100vh - 126px));
    background: var(--fb-bg);
    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;
    border: 1px solid var(--fb-border);
}

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

/* Header */
.fb-chat-header {
    background: linear-gradient(135deg, var(--fb-primary), var(--fb-primary-dark));
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white;
}

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

.fb-brand-icon {
    font-size: 24px;
    background: rgba(255,255,255,0.2);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

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

.fb-title {
    font-size: 16px;
    font-weight: 700;
}

.fb-status {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 5px;
}

.fb-status::before {
    content: '';
    width: 6px;
    height: 6px;
    background: #00b894; /* Online Green */
    border-radius: 50%;
    display: block;
}

.fb-header-actions button {
    background: none;
    border: none;
    color: rgba(255,255,255,0.8);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s;
    line-height: 0;
}

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

/* Quick links */
.fb-quick-links {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    background: #fff;
    border-bottom: 1px solid #f0f0f0;
    overflow-x: auto;
}

.fb-quick-links::-webkit-scrollbar {
    display: none;
}

.fb-quick-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid rgba(255, 159, 67, 0.5);
    color: var(--fb-primary-dark);
    background: #fff8f0;
    text-decoration: none;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.fb-quick-link:hover {
    color: #fff;
    background: var(--fb-primary);
    border-color: var(--fb-primary);
}

/* Messages Area */
.fb-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #f9f9f9;
}

.fb-message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    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.5;
    word-break: break-word;
    overflow-wrap: anywhere;
    position: relative;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.fb-message.bot .fb-bubble {
    background: white;
    color: var(--fb-text);
    border-top-left-radius: 4px;
    border: 1px solid #eee;
}

.fb-message.user .fb-bubble {
    background: var(--fb-primary);
    color: white;
    border-top-right-radius: 4px;
}

/* Chips */
.fb-chips-area {
    padding: 10px 16px;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    background: white;
    border-top: 1px solid #f0f0f0;
}

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

.fb-chip {
    background: white;
    border: 1px solid var(--fb-primary);
    color: var(--fb-primary);
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 13px;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.fb-chip:hover {
    background: var(--fb-primary);
    color: white;
}

/* Input Area */
.fb-chat-input-area {
    padding: 15px;
    background: white;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
    align-items: center;
}

#fb-input {
    flex: 1;
    background: #f1f2f6;
    border: 1px solid transparent;
    border-radius: 20px;
    padding: 12px 16px;
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
}

#fb-input:focus {
    background: white;
    border-color: var(--fb-primary);
    box-shadow: 0 0 0 2px rgba(255, 159, 67, 0.1);
}

#fb-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--fb-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

#fb-send-btn:hover {
    background: #fff3e0;
    transform: scale(1.05);
}

#fb-send-btn svg {
    width: 24px;
    height: 24px;
}

/* Loading */
.fb-loading {
    width: 14px;
    height: 14px;
    border: 2px solid #ddd;
    border-top-color: var(--fb-primary);
    border-radius: 50%;
    animation: fb-spin 0.8s linear infinite;
    display: inline-block;
    vertical-align: middle;
    margin-right: 5px;
}

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

/* Cards & Actions */
.fb-card {
    background: white;
    border: 1px solid #eee;
    border-radius: 12px;
    overflow: hidden;
    margin-top: 8px;
    max-width: 260px;
}

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

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

.fb-card-title {
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--fb-text);
}

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

.fb-card-btn {
    display: block;
    width: 100%;
    padding: 8px 0;
    text-align: center;
    background: var(--fb-primary);
    color: white;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
}

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

/* History View */
.fb-history-view {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f9f9f9;
}

.fb-hist-item {
    background: white;
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 10px;
    border: 1px solid #eee;
    cursor: default;
}

.fb-hist-date {
    font-size: 11px;
    color: #999;
    margin-bottom: 4px;
}

.fb-hist-q {
    font-weight: 600;
    font-size: 14px;
    color: var(--fb-text);
    margin-bottom: 4px;
}

.fb-hist-a {
    font-size: 13px;
    color: var(--fb-text-muted);
    line-height: 1.4;
}

/* Mobile */
@media (max-width: 768px), (pointer: coarse) {
    #francisco-bot-container:not(.fb-mode-inline) {
        left: auto;
        right: 12px;
        bottom: calc(var(--fb-mobile-safe-offset) + env(safe-area-inset-bottom));
        align-items: flex-end;
        padding-right: 0;
    }

    #fb-toggle-btn {
        width: 58px !important;
        height: 58px !important;
        margin-left: auto;
    }

    .francisco-bot-widget:not(.fb-mode-inline) {
        position: fixed;
        left: 12px;
        right: 12px;
        width: auto;
        height: min(600px, calc(100% - var(--fb-mobile-open-height-offset)));
        max-height: min(600px, calc(100% - var(--fb-mobile-open-height-offset)));
        bottom: calc(var(--fb-mobile-open-offset) + env(safe-area-inset-bottom));
        max-width: 420px;
        margin: 0;
        border-radius: 16px;
        transform-origin: bottom center;
        box-sizing: border-box;
    }

    .fb-quick-links {
        padding: 8px 10px;
    }

    #fb-input {
        font-size: 16px;
    }
}
