/* =============================================================
   GestBot — Chatbot Widget
   ============================================================= */

/* ── Floating Button ─────────────────────────────────────────── */
#gestbot-btn {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #e4e7eb;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0,0,0,0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px;
    z-index: 900;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    outline: none;
    overflow: hidden;
}
#gestbot-btn img { width: 100%; height: 100%; object-fit: contain; }
#gestbot-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 24px rgba(45,90,69,0.28);
    border-color: #4caf50;
}
#gestbot-btn.open {
    border-color: #4caf50;
    box-shadow: 0 4px 20px rgba(76,175,80,0.35);
}
[data-theme="dark"] #gestbot-btn { background: #181b25; border-color: #262d3d; }
[data-theme="dark"] #gestbot-btn:hover,
[data-theme="dark"] #gestbot-btn.open { border-color: #4caf50; }

/* Unread badge */
#gestbot-badge {
    position: absolute;
    top: 2px; right: 2px;
    width: 12px; height: 12px;
    background: #ef4444;
    border-radius: 50%;
    border: 2px solid #fff;
    display: none;
}
#gestbot-badge.show { display: block; }

/* ── Chat Panel ──────────────────────────────────────────────── */
#gestbot-panel {
    position: fixed;
    bottom: 158px;
    right: 20px;
    width: 360px;
    max-height: 560px;
    background: var(--card-bg, #ffffff);
    border: 1px solid var(--border-color, #e4e7eb);
    border-radius: 20px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.18);
    display: flex;
    flex-direction: column;
    z-index: 901;
    overflow: hidden;
    opacity: 0;
    transform: translateY(18px) scale(0.96);
    pointer-events: none;
    transition: opacity 0.22s ease, transform 0.22s ease;
}
#gestbot-panel.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* ── Panel Header ────────────────────────────────────────────── */
.gestbot-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: linear-gradient(135deg, #1e3a2e 0%, #2d5a45 60%, #3d8b5e 100%);
    color: #fff;
    flex-shrink: 0;
}
.gestbot-avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    border: 1.5px solid rgba(255,255,255,0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    padding: 4px;
}
.gestbot-avatar img { width: 100%; height: 100%; object-fit: contain; }
.gestbot-title { flex: 1; }
.gestbot-title h4 {
    font-size: 14px;
    font-weight: 700;
    margin: 0;
    line-height: 1.2;
    display: flex;
    align-items: center;
    gap: 6px;
}
.gestbot-title span { font-size: 11px; opacity: 0.75; }

/* Online dot */
.gb-online-dot {
    width: 7px; height: 7px;
    background: #4ade80;
    border-radius: 50%;
    flex-shrink: 0;
    animation: gb-pulse 2.2s infinite;
}
@keyframes gb-pulse {
    0%,100% { opacity: 1; transform: scale(1); }
    50%      { opacity: 0.45; transform: scale(0.85); }
}

.gestbot-header-btns { display: flex; gap: 6px; }
.gestbot-header-btns button {
    background: rgba(255,255,255,0.12);
    border: none;
    color: #fff;
    width: 28px; height: 28px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.gestbot-header-btns button:hover { background: rgba(255,255,255,0.25); }

/* ── Messages Area ───────────────────────────────────────────── */
#gestbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}
#gestbot-messages::-webkit-scrollbar { width: 4px; }
#gestbot-messages::-webkit-scrollbar-thumb { background: var(--border-color, #e4e7eb); border-radius: 2px; }

/* Bubble base */
.gestbot-msg {
    max-width: 88%;
    padding: 10px 13px;
    border-radius: 16px;
    font-size: 13.5px;
    line-height: 1.55;
    word-wrap: break-word;
}
.gestbot-msg.bot {
    background: var(--bg-secondary, #f3f4f6);
    color: var(--text-primary, #111827);
    border-bottom-left-radius: 4px;
    align-self: flex-start;
}
.gestbot-msg.user {
    background: linear-gradient(135deg, #1e3a2e, #2d5a45);
    color: #fff;
    border-bottom-right-radius: 4px;
    align-self: flex-end;
}

/* Markdown inside bot bubble */
.gestbot-msg.bot strong { font-weight: 700; color: #111827; }
.gestbot-msg.bot br + br { display: none; }

/* ── Mini bar chart ──────────────────────────────────────────── */
.gb-chart {
    background: rgba(0,0,0,0.04);
    border-radius: 10px;
    padding: 10px 12px;
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 9px;
}
.gb-bar-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}
.gb-bar-label { font-size: 12px; font-weight: 600; color: #374151; }
.gb-bar-val   { font-size: 11.5px; color: #6b7280; }
.gb-bar-val small { opacity: 0.75; margin-left: 2px; }
.gb-bar-track {
    height: 7px;
    background: rgba(0,0,0,0.08);
    border-radius: 4px;
    overflow: hidden;
}
.gb-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.65s cubic-bezier(0.4,0,0.2,1);
}
[data-theme="dark"] .gb-chart  { background: rgba(255,255,255,0.06); }
[data-theme="dark"] .gb-bar-label { color: #d1d5db; }
[data-theme="dark"] .gb-bar-val   { color: #9ca3af; }
[data-theme="dark"] .gb-bar-track { background: rgba(255,255,255,0.1); }

/* Typing indicator */
.gestbot-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background: var(--bg-secondary, #f3f4f6);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    width: 58px;
}
.gestbot-typing span {
    width: 7px; height: 7px;
    background: #9ca3af;
    border-radius: 50%;
    animation: gestbot-bounce 1.2s infinite;
}
.gestbot-typing span:nth-child(2) { animation-delay: 0.2s; }
.gestbot-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes gestbot-bounce {
    0%,60%,100% { transform: translateY(0); }
    30%          { transform: translateY(-7px); }
}

/* ── Welcome screen ──────────────────────────────────────────── */
.gestbot-welcome {
    text-align: center;
    padding: 6px 8px 2px;
}
.gb-welcome-icon {
    width: 56px; height: 56px;
    background: linear-gradient(135deg, rgba(45,90,69,0.12), rgba(76,175,80,0.08));
    border: 1.5px solid rgba(76,175,80,0.25);
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 14px;
    font-size: 26px;
}
.gb-welcome-title {
    font-size: 14.5px;
    font-weight: 700;
    color: var(--text-primary, #111827);
    margin: 0 0 6px;
}
.gb-welcome-sub {
    font-size: 12.5px;
    color: var(--text-secondary, #6b7280);
    line-height: 1.5;
    margin: 0 0 14px;
}

/* Quick suggestions */
.gestbot-suggestions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px;
    margin-top: 4px;
}
.gestbot-sug {
    background: var(--bg-secondary, #f3f4f6);
    border: 1px solid var(--border-color, #e4e7eb);
    color: var(--text-primary, #374151);
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    line-height: 1.35;
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
    font-family: inherit;
}
.gestbot-sug:hover {
    background: rgba(45,90,69,0.08);
    border-color: rgba(76,175,80,0.4);
    color: #1e3a2e;
    transform: translateY(-1px);
}
[data-theme="dark"] .gestbot-sug {
    background: rgba(76,175,80,0.08);
    border-color: rgba(76,175,80,0.2);
    color: #d1d5db;
}
[data-theme="dark"] .gestbot-sug:hover {
    background: rgba(76,175,80,0.15);
    color: #fff;
}

/* ── Input Area ──────────────────────────────────────────────── */
.gestbot-input-area {
    padding: 10px 12px;
    border-top: 1px solid var(--border-color, #e4e7eb);
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-shrink: 0;
    background: var(--card-bg, #ffffff);
}
#gestbot-input {
    flex: 1;
    border: 1.5px solid var(--border-color, #e0e4e8);
    border-radius: 20px;
    padding: 9px 15px;
    font-size: 13.5px;
    resize: none;
    outline: none;
    background: var(--input-bg, #f8f9fa);
    color: var(--text-primary, #111827);
    max-height: 100px;
    line-height: 1.4;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}
#gestbot-input:focus {
    border-color: #2d5a45;
    box-shadow: 0 0 0 3px rgba(45,90,69,0.08);
}
#gestbot-input::placeholder { color: var(--text-secondary, #9ca3af); }

#gestbot-send {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1e3a2e, #2d5a45);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
    transition: transform 0.15s, opacity 0.15s, box-shadow 0.15s;
}
#gestbot-send:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(45,90,69,0.4);
}
#gestbot-send:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }

/* ── Dark Mode ───────────────────────────────────────────────── */
[data-theme="dark"] #gestbot-panel {
    background: #181b25;
    border-color: #262d3d;
    box-shadow: 0 12px 40px rgba(0,0,0,0.45);
}
[data-theme="dark"] .gestbot-msg.bot  { background: #262d3d; color: #e4e6eb; }
[data-theme="dark"] .gestbot-msg.bot strong { color: #f3f4f6; }
[data-theme="dark"] .gestbot-typing   { background: #262d3d; }
[data-theme="dark"] .gestbot-typing span { background: #6b7280; }
[data-theme="dark"] .gestbot-input-area { background: #181b25; border-color: #262d3d; }
[data-theme="dark"] #gestbot-input    { background: #262d3d; border-color: #333d52; color: #e4e6eb; }
[data-theme="dark"] .gestbot-welcome  { color: #9ca3af; }
[data-theme="dark"] #gestbot-badge    { border-color: #181b25; }
[data-theme="dark"] .gb-welcome-title { color: #e4e6eb; }

/* ── Mobile ──────────────────────────────────────────────────── */
@media (max-width: 600px) {
    #gestbot-btn { bottom: 78px; right: 14px; width: 50px; height: 50px; padding: 6px; }

    #gestbot-panel {
        bottom: 0; right: 0; left: 0;
        width: 100%;
        max-height: 88vh;
        border-radius: 22px 22px 0 0;
        border-bottom: none;
        transform: translateY(100%);
        opacity: 1;
        transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
    }
    #gestbot-panel.open { transform: translateY(0); opacity: 1; }
    #gestbot-messages   { padding: 12px 14px; flex: 1; min-height: 0; }
    .gestbot-input-area { padding: 10px 14px 18px; }
    #gestbot-input      { font-size: 16px; }
    .gestbot-msg        { font-size: 14px; max-width: 92%; }
    .gestbot-suggestions { grid-template-columns: 1fr 1fr; }
    .gestbot-sug        { font-size: 12.5px; padding: 9px 10px; }
}

/* ── Tutorial badge ─────────────────────────────────────────── */
.gb-tutorial-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(74,222,128,.1);
    border: 1px solid rgba(74,222,128,.25);
    color: #22c55e;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 99px;
    margin-bottom: 10px;
    letter-spacing: .4px;
    text-transform: uppercase;
}
.gb-tutorial-msg {
    border-left: 2px solid rgba(74,222,128,.4) !important;
}
.gestbot-sug-tutorial {
    grid-column: 1 / -1;
    background: rgba(74,222,128,.08) !important;
    border-color: rgba(74,222,128,.3) !important;
    color: #22c55e !important;
    font-weight: 700 !important;
}
.gestbot-sug-tutorial:hover {
    background: rgba(74,222,128,.16) !important;
}
