/* assets/css/chatbot.css */

/* ── Variables ──────────────────────────────────────────── */
:root {
    --sma-accent: #1e73be;
    --sma-accent-hover: #1e73bedd;
    --sma-accent-light: #1e73be15;
    --sma-bg: #ffffff;
    --sma-bg-secondary: #f7f8fa;
    --sma-text: #1a1a2e;
    --sma-text-light: #666;
    --sma-border: #e0e0e0;
    --sma-radius: 16px;
    --sma-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    --sma-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
}

/* ── Floating Toggle Button ─────────────────────────────── */
/* ── Floating Toggle Button ─────────────────────────────── */
.sma-chat-toggle {
    position: fixed;
    bottom: 24px;
    z-index: 999998;
    height: 56px;
    padding: 0 22px;
    border-radius: 28px;
    background: var(--sma-accent);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-radius 0.3s ease;
    line-height: 1;
    font-family: var(--sma-font);
    white-space: nowrap;
}

.sma-chat-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
}

.sma-chat-toggle.sma-pos-bottom-right { right: 24px; }
.sma-chat-toggle.sma-pos-bottom-left  { left: 24px; }

.sma-toggle-icon-open {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 22px;
}

.sma-toggle-label {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.sma-toggle-icon-close {
    font-size: 22px;
    font-style: normal;
}

/* Mobile: show just the icon */
@media (max-width: 480px) {
    .sma-chat-toggle {
        width: 52px;
        height: 52px;
        padding: 0;
        border-radius: 50%;
        bottom: 16px;
    }

    .sma-chat-toggle.sma-pos-bottom-right { right: 16px; }
    .sma-chat-toggle.sma-pos-bottom-left  { left: 16px; }

    .sma-toggle-label {
        display: none;
    }

    .sma-toggle-icon-open {
        font-size: 24px;
    }
}

/* ── Inline Chat (shortcode) ────────────────────────────── */
.sma-inline-chat {
    border-radius: var(--sma-radius);
    overflow: hidden;
    box-shadow: var(--sma-shadow);
    font-family: var(--sma-font);
    border: 1px solid var(--sma-border);
}

.sma-inline-chat .sma-chat-container {
    height: 100%;
}

/* ── Chat Container Layout ──────────────────────────────── */
.sma-chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--sma-bg);
}

/* ── Header ─────────────────────────────────────────────── */
.sma-chat-header {
    background: var(--sma-accent);
    color: #fff;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.sma-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sma-header-icon {
    font-size: 28px;
    line-height: 1;
}

.sma-header-title {
    display: block;
    font-weight: 700;
    font-size: 15px;
    line-height: 1.2;
}

.sma-header-subtitle {
    display: block;
    font-size: 11px;
    opacity: 0.85;
    line-height: 1.3;
}

.sma-header-actions {
    display: flex;
    gap: 6px;
}

.sma-header-actions button {
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.sma-header-actions button:hover {
    background: rgba(255,255,255,0.3);
}

/* ── Messages Area ──────────────────────────────────────── */
.sma-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

/* Scrollbar */
.sma-chat-messages::-webkit-scrollbar { width: 6px; }
.sma-chat-messages::-webkit-scrollbar-track { background: transparent; }
.sma-chat-messages::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }

/* ── Message Bubbles ────────────────────────────────────── */
.sma-message {
    max-width: 88%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.55;
    word-wrap: break-word;
    position: relative;
}

.sma-message-user {
    align-self: flex-end;
    background: var(--sma-accent);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.sma-message-assistant {
    align-self: flex-start;
    background: var(--sma-bg-secondary);
    color: var(--sma-text);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--sma-border);
}

/* Markdown inside assistant messages */
.sma-message-assistant h1,
.sma-message-assistant h2,
.sma-message-assistant h3 {
    margin: 8px 0 4px;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.3;
}

.sma-message-assistant h1 { font-size: 17px; }
.sma-message-assistant h2 { font-size: 15px; }

.sma-message-assistant ul,
.sma-message-assistant ol {
    padding-left: 20px;
    margin: 6px 0;
}

.sma-message-assistant li {
    margin-bottom: 3px;
}

.sma-message-assistant p {
    margin: 6px 0;
}

.sma-message-assistant p:first-child { margin-top: 0; }
.sma-message-assistant p:last-child  { margin-bottom: 0; }

.sma-message-assistant code {
    background: #e8e8e8;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
}

.sma-message-assistant pre {
    background: #2d2d2d;
    color: #f8f8f2;
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 13px;
    margin: 8px 0;
}

.sma-message-assistant pre code {
    background: none;
    padding: 0;
    color: inherit;
}

.sma-message-assistant a {
    color: var(--sma-accent);
    text-decoration: underline;
}

.sma-message-assistant strong {
    font-weight: 700;
}

/* ── References ─────────────────────────────────────────── */
.sma-references {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--sma-border);
}

.sma-references-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--sma-text-light);
    margin-bottom: 6px;
    letter-spacing: 0.5px;
}

.sma-ref-link {
    display: inline-block;
    font-size: 12px;
    color: var(--sma-accent);
    text-decoration: none;
    background: var(--sma-accent-light);
    padding: 3px 10px;
    border-radius: 12px;
    margin: 2px 4px 2px 0;
    transition: background 0.2s;
}

.sma-ref-link:hover {
    background: var(--sma-accent);
    color: #fff;
    text-decoration: none;
}

/* ── Typing Indicator ───────────────────────────────────── */
.sma-typing {
    align-self: flex-start;
    display: flex;
    gap: 5px;
    padding: 14px 18px;
    background: var(--sma-bg-secondary);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    border: 1px solid var(--sma-border);
}

.sma-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #999;
    animation: smaBounce 1.4s infinite ease-in-out;
}

.sma-typing-dot:nth-child(1) { animation-delay: 0s; }
.sma-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.sma-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes smaBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40%           { transform: scale(1);   opacity: 1; }
}

/* ── Suggestions ────────────────────────────────────────── */
.sma-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 16px 4px;
}

.sma-suggestion {
    font-size: 12px;
    padding: 6px 12px;
    border: 1px solid var(--sma-border);
    border-radius: 20px;
    background: var(--sma-bg);
    color: var(--sma-accent);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    font-family: var(--sma-font);
}

.sma-suggestion:hover {
    background: var(--sma-accent);
    color: #fff;
    border-color: var(--sma-accent);
}

/* ── Input Area ─────────────────────────────────────────── */
.sma-chat-input-wrap {
    flex-shrink: 0;
    border-top: 1px solid var(--sma-border);
    background: var(--sma-bg);
}

.sma-chat-form {
    display: flex;
    align-items: flex-end;
    padding: 12px 16px;
    gap: 8px;
}

.sma-chat-input {
    flex: 1;
    border: 1px solid var(--sma-border);
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 14px;
    font-family: var(--sma-font);
    resize: none;
    max-height: 120px;
    line-height: 1.4;
    outline: none;
    transition: border-color 0.2s;
}

.sma-chat-input:focus {
    border-color: var(--sma-accent);
}

.sma-btn-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--sma-accent);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.2s;
}

.sma-btn-send:hover {
    background: var(--sma-accent-hover);
    transform: scale(1.05);
}

.sma-btn-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ── Error message ──────────────────────────────────────── */
.sma-message-error {
    align-self: center;
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
    border-radius: 12px;
    padding: 10px 16px;
    font-size: 13px;
    text-align: center;
    max-width: 90%;
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 480px) {
    .sma-chat-widget {
        width: calc(100vw - 16px);
        height: calc(100vh - 100px);
        bottom: 80px;
        right: 8px !important;
        left: 8px !important;
        border-radius: 12px;
    }

    .sma-chat-toggle {
        width: 52px;
        height: 52px;
        bottom: 16px;
        font-size: 24px;
    }

    .sma-chat-toggle.sma-pos-bottom-right { right: 16px; }
    .sma-chat-toggle.sma-pos-bottom-left  { left: 16px; }

    .sma-suggestion {
        font-size: 11px;
        padding: 5px 10px;
    }
}

/* ── Model Badge ────────────────────────────────────────── */
.sma-model-badge {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px dashed var(--sma-border);
    font-size: 10px;
    color: var(--sma-text-light);
}

.sma-model-badge span {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--sma-bg);
    border: 1px solid var(--sma-border);
    white-space: nowrap;
}

.sma-badge-openai .sma-badge-provider {
    border-color: #10a37f;
    color: #10a37f;
}

.sma-badge-anthropic .sma-badge-provider {
    border-color: #d4a574;
    color: #b8860b;
}

.sma-badge-time {
    color: #888;
}

.sma-badge-category {
    color: var(--sma-accent);
}

/* ── Usage Bar ──────────────────────────────────────────── */
.sma-usage-bar {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--sma-bg-secondary);
    border-bottom: 1px solid var(--sma-border);
    font-size: 11px;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.sma-usage-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.sma-usage-tier {
    font-weight: 700;
    white-space: nowrap;
}

.sma-usage-count {
    color: var(--sma-text-light);
    white-space: nowrap;
}

.sma-usage-progress-wrap {
    width: 80px;
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
    overflow: hidden;
    flex-shrink: 0;
}

.sma-usage-progress {
    height: 100%;
    background: var(--sma-accent);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.sma-usage-progress.sma-usage-warning {
    background: #f0ad4e;
}

.sma-usage-progress.sma-usage-critical {
    background: #d9534f;
    animation: smaPulse 1.5s infinite;
}

.sma-usage-progress.sma-usage-unlimited {
    background: #5cb85c;
}

@keyframes smaPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.sma-upgrade-link {
    font-size: 11px;
    font-weight: 700;
    color: var(--sma-accent);
    text-decoration: none;
    white-space: nowrap;
    padding: 2px 8px;
    border: 1px solid var(--sma-accent);
    border-radius: 10px;
    transition: all 0.2s;
}

.sma-upgrade-link:hover {
    background: var(--sma-accent);
    color: #fff;
}

/* ── Access / Limit Messages ────────────────────────────── */
.sma-access-message,
.sma-limit-message {
    align-self: center;
    text-align: center;
    padding: 20px;
    margin: 12px;
    border-radius: 12px;
    max-width: 90%;
}

.sma-access-message {
    background: #f0f4f8;
    border: 1px solid #d0d7de;
}

.sma-limit-message {
    background: #fff8e1;
    border: 1px solid #ffe082;
}

.sma-access-message p,
.sma-limit-message p {
    margin: 0 0 12px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--sma-text);
}

.sma-access-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.sma-btn-login,
.sma-btn-upgrade {
    display: inline-block;
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    transition: all 0.2s;
    cursor: pointer;
}

.sma-btn-login {
    background: var(--sma-bg);
    color: var(--sma-accent);
    border: 2px solid var(--sma-accent);
}

.sma-btn-login:hover {
    background: var(--sma-accent);
    color: #fff;
}

.sma-btn-upgrade {
    background: var(--sma-accent);
    color: #fff;
    border: 2px solid var(--sma-accent);
}

.sma-btn-upgrade:hover {
    background: var(--sma-accent-hover);
    transform: scale(1.02);
}

/* ── Model Badge (from previous version) ────────────────── */
.sma-model-badge {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px dashed var(--sma-border);
    font-size: 10px;
    color: var(--sma-text-light);
}

.sma-model-badge span {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--sma-bg);
    border: 1px solid var(--sma-border);
    white-space: nowrap;
}

.sma-badge-openai .sma-badge-provider { border-color: #10a37f; color: #10a37f; }
.sma-badge-anthropic .sma-badge-provider { border-color: #d4a574; color: #b8860b; }
