@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

/* ============================================================
   CSS Custom Properties — primary color is set dynamically by JS
   ============================================================ */
:root {
    --brycen-primary: #9CCD62;
    --brycen-primary-dark: #7DB046;
    --brycen-bg: #f8f9fb;
    --brycen-white: #ffffff;
    --brycen-text: #1e1e2f;
    --brycen-text-light: #999;
    --brycen-border: #e2e4e9;
    --brycen-shadow: rgba(0, 0, 0, 0.15);
    --brycen-code-bg: #1e1e2f;
    --brycen-code-text: #e2e8f0;
    --brycen-inline-code-bg: #eef0f4;
    --brycen-inline-code-text: #d6336c;
    --brycen-link: #6366f1;
    --brycen-link-hover: #4f46e5;
    --brycen-blockquote-border: #8b5cf6;
    --brycen-blockquote-bg: #f3f0ff;
}

*, *::before, *::after {
    box-sizing: border-box;
}

/* ============================================================
   LAUNCHER BUTTON
   ============================================================ */
.brycen-chat-launcher {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 58px;
    height: 58px;
    background: linear-gradient(135deg, var(--brycen-primary), var(--brycen-primary-dark));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(124, 176, 70, 0.45);
    z-index: 99999;
    transition: transform 0.2s, box-shadow 0.2s;
    border: none;
    outline: none;
}

.brycen-chat-launcher:hover {
    transform: scale(1.08);
    box-shadow: 0 8px 28px rgba(124, 176, 70, 0.55);
}

/* ============================================================
   CHAT WIDGET CONTAINER
   ============================================================ */
.brycen-chat-widget {
    display: none;
    flex-direction: column;
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 380px;
    height: 520px;
    background: var(--brycen-white);
    border-radius: 16px;
    box-shadow: 0 12px 40px var(--brycen-shadow);
    overflow: hidden;
    z-index: 100000;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

.brycen-chat-widget.brycen-open {
    display: flex;
}

/* Mobile full-screen */
@media (max-width: 480px) {
    .brycen-chat-widget {
        width: 100%;
        height: 100%;
        bottom: 0;
        right: 0;
        border-radius: 0;
    }
}

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

.brycen-chat-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brycen-chat-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.brycen-chat-header-info h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
}

.brycen-chat-header-info span {
    font-size: 11px;
    opacity: 0.85;
}

.brycen-chat-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.brycen-chat-close-btn:hover {
    background: rgba(255, 255, 255, 0.35);
}

/* ============================================================
   MESSAGE WINDOW
   ============================================================ */
.brycen-chat-window {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background: var(--brycen-bg);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.brycen-chat-window::-webkit-scrollbar {
    width: 5px;
}

.brycen-chat-window::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 10px;
}

/* ============================================================
   MESSAGES
   ============================================================ */
.brycen-msg {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 13.5px;
    max-width: 78%;
    line-height: 1.5;
    word-wrap: break-word;
    animation: brycenFadeUp 0.25s ease;
}

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

.brycen-user-msg {
    background: linear-gradient(135deg, var(--brycen-primary), var(--brycen-primary-dark));
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.brycen-bot-msg {
    background: var(--brycen-white);
    color: var(--brycen-text);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

/* ============================================================
   MARKDOWN STYLES (inside bot messages)
   ============================================================ */
.brycen-bot-msg strong {
    font-weight: 600;
}

.brycen-bot-msg em {
    font-style: italic;
}

.brycen-bot-msg del {
    text-decoration: line-through;
    opacity: 0.7;
}

.brycen-bot-msg .md-h {
    margin: 6px 0 4px;
    line-height: 1.3;
}

.brycen-bot-msg h1.md-h {
    font-size: 17px;
}

.brycen-bot-msg h2.md-h {
    font-size: 15px;
}

.brycen-bot-msg h3.md-h {
    font-size: 14px;
}

.brycen-bot-msg .md-codeblock {
    background: var(--brycen-code-bg);
    color: var(--brycen-code-text);
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 12px;
    overflow-x: auto;
    margin: 6px 0;
    font-family: 'Courier New', monospace;
    white-space: pre-wrap;
    word-break: break-word;
}

.brycen-bot-msg .md-inline-code {
    background: var(--brycen-inline-code-bg);
    color: var(--brycen-inline-code-text);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12.5px;
    font-family: 'Courier New', monospace;
}

.brycen-bot-msg .md-list {
    margin: 6px 0;
    padding-left: 20px;
}

.brycen-bot-msg .md-li {
    margin: 2px 0;
}

.brycen-bot-msg .md-bq {
    border-left: 3px solid var(--brycen-blockquote-border);
    padding: 4px 10px;
    margin: 6px 0;
    background: var(--brycen-blockquote-bg);
    border-radius: 0 6px 6px 0;
    font-style: italic;
    color: #555;
}

.brycen-bot-msg .md-hr {
    border: none;
    border-top: 1px solid #ddd;
    margin: 8px 0;
}

.brycen-bot-msg .md-link {
    color: var(--brycen-link);
    text-decoration: underline;
    word-break: break-all;
}

.brycen-bot-msg .md-link:hover {
    color: var(--brycen-link-hover);
}

/* User message links */
.brycen-user-msg a {
    color: #fff;
    text-decoration: underline;
}

/* ============================================================
   SUGGESTION CHIPS
   ============================================================ */
.brycen-suggestions-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px 0;
    align-self: flex-start;
}

.brycen-suggestion-chip {
    background: var(--brycen-white);
    color: var(--brycen-primary);
    border: 1.5px solid var(--brycen-primary);
    border-radius: 20px;
    padding: 7px 14px;
    font-size: 12.5px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.brycen-suggestion-chip:hover {
    background: var(--brycen-primary);
    color: var(--brycen-white);
    box-shadow: 0 3px 10px rgba(124, 176, 70, 0.3);
}

/* ============================================================
   TYPING INDICATOR
   ============================================================ */
.brycen-typing {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 0;
}

.brycen-typing span {
    width: 7px;
    height: 7px;
    background: var(--brycen-primary);
    border-radius: 50%;
    display: inline-block;
    animation: brycenBounce 1.3s infinite ease-in-out;
}

.brycen-typing span:nth-child(2) {
    animation-delay: 0.15s;
}

.brycen-typing span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes brycenBounce {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-7px);
    }
}

/* ============================================================
   INPUT AREA
   ============================================================ */
.brycen-chat-input-area {
    padding: 12px 14px;
    border-top: 1px solid #eee;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--brycen-white);
    flex-shrink: 0;
}

.brycen-chat-input {
    flex: 1;
    padding: 10px 16px;
    border: 1.5px solid var(--brycen-border);
    border-radius: 24px;
    outline: none;
    font-size: 13.5px;
    font-family: inherit;
    transition: border-color 0.2s;
    background: var(--brycen-bg);
}

.brycen-chat-input:focus {
    border-color: var(--brycen-primary);
    background: var(--brycen-white);
}

.brycen-chat-input::placeholder {
    color: var(--brycen-text-light);
}

.brycen-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    background: linear-gradient(135deg, var(--brycen-primary), var(--brycen-primary-dark));
    color: white;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s, box-shadow 0.15s;
    flex-shrink: 0;
}

.brycen-send-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 12px rgba(124, 176, 70, 0.4);
}

.brycen-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ============================================================
   RATE LIMIT WARNING
   ============================================================ */
.brycen-rate-limit-warning {
    background: #fff3cd;
    color: #856404;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 12px;
    align-self: center;
    text-align: center;
    animation: brycenFadeUp 0.25s ease;
}

/* ============================================================
   ERROR MESSAGE
   ============================================================ */
.brycen-error-msg {
    background: #fee;
    color: #c0392b;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 12.5px;
    align-self: flex-start;
    animation: brycenFadeUp 0.25s ease;
}
