/* ==========================================================================
   Claude Chatbot — Modern UI
   Glassmorphism + Smooth animations + Dark aesthetic
   ========================================================================== */

:root {
    --ccb-primary: #2F9638;
    --ccb-primary-light: #23A455;
    --ccb-primary-dark: #007135;
    --ccb-accent: #FBBA00;
    --ccb-bg-dark: #0A1F17;
    --ccb-bg-card: rgba(10, 31, 23, 0.95);
    --ccb-bg-glass: rgba(16, 45, 34, 0.8);
    --ccb-bg-input: rgba(16, 45, 34, 0.6);
    --ccb-text: #f1f5f9;
    --ccb-text-muted: #94a3b8;
    --ccb-border: rgba(148, 163, 184, 0.15);
    --ccb-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    --ccb-radius: 20px;
    --ccb-radius-sm: 12px;
    --ccb-radius-xs: 8px;
    --ccb-transition: cubic-bezier(0.4, 0, 0.2, 1);
    --ccb-chat-width: 420px;
    --ccb-chat-height: 640px;
}

/* ---------- Trigger Button ---------- */

.ccb-trigger {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99998;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    background: linear-gradient(135deg, var(--ccb-primary), var(--ccb-accent));
    color: #fff;
    box-shadow: 0 8px 32px rgba(47, 150, 56, 0.4), 0 0 0 0 rgba(47, 150, 56, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.4s var(--ccb-transition);
    animation: ccb-pulse 3s ease-in-out infinite;
}

.ccb-trigger:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 40px rgba(47, 150, 56, 0.5);
}

.ccb-trigger.ccb-hidden {
    transform: scale(0);
    opacity: 0;
    pointer-events: none;
}

.ccb-trigger svg {
    width: 28px;
    height: 28px;
    transition: transform 0.3s var(--ccb-transition);
}

.ccb-trigger:hover svg {
    transform: rotate(-10deg) scale(1.1);
}

@keyframes ccb-pulse {
    0%, 100% { box-shadow: 0 8px 32px rgba(47, 150, 56, 0.4), 0 0 0 0 rgba(47, 150, 56, 0.3); }
    50% { box-shadow: 0 8px 32px rgba(47, 150, 56, 0.4), 0 0 0 12px rgba(47, 150, 56, 0); }
}

/* ---------- Chat Container ---------- */

.ccb-container {
    position: fixed;
    bottom: 100px;
    right: 24px;
    z-index: 99999;
    width: var(--ccb-chat-width);
    height: var(--ccb-chat-height);
    max-height: calc(100vh - 140px);
    display: flex;
    flex-direction: column;
    border-radius: var(--ccb-radius);
    background: var(--ccb-bg-card);
    backdrop-filter: blur(40px) saturate(1.5);
    -webkit-backdrop-filter: blur(40px) saturate(1.5);
    border: 1px solid var(--ccb-border);
    box-shadow: var(--ccb-shadow);
    overflow: hidden;
    transition: all 0.4s var(--ccb-transition);
    transform-origin: bottom right;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

.ccb-container.ccb-closed {
    transform: scale(0.8) translateY(20px);
    opacity: 0;
    pointer-events: none;
}

/* ---------- Header ---------- */

.ccb-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    background: linear-gradient(135deg, rgba(47, 150, 56, 0.15), rgba(6, 182, 212, 0.1));
    border-bottom: 1px solid var(--ccb-border);
    flex-shrink: 0;
}

.ccb-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ccb-avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--ccb-primary), var(--ccb-accent));
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ccb-avatar svg {
    width: 22px;
    height: 22px;
    color: #fff;
}

.ccb-header-info h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--ccb-text);
    line-height: 1.2;
}

.ccb-header-info span {
    font-size: 12px;
    color: var(--ccb-text-muted);
}

.ccb-header-info .ccb-status-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #22c55e;
    margin-right: 4px;
    animation: ccb-status-pulse 2s ease-in-out infinite;
}

@keyframes ccb-status-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.ccb-close-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--ccb-border);
    color: var(--ccb-text-muted);
    width: 34px;
    height: 34px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.ccb-close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--ccb-text);
}

/* ---------- Category Selector ---------- */

.ccb-categories {
    display: flex;
    gap: 6px;
    padding: 12px 16px;
    overflow-x: auto;
    border-bottom: 1px solid var(--ccb-border);
    flex-shrink: 0;
    scrollbar-width: none;
}

.ccb-categories::-webkit-scrollbar {
    display: none;
}

.ccb-category-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 20px;
    border: 1px solid var(--ccb-border);
    background: transparent;
    color: var(--ccb-text-muted);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.25s var(--ccb-transition);
    font-family: inherit;
}

.ccb-category-btn:hover {
    border-color: var(--ccb-primary-light);
    color: var(--ccb-primary-light);
    background: rgba(47, 150, 56, 0.08);
}

.ccb-category-btn.ccb-active {
    background: linear-gradient(135deg, var(--ccb-primary), var(--ccb-primary-dark));
    border-color: transparent;
    color: #fff;
    box-shadow: 0 4px 15px rgba(47, 150, 56, 0.3);
}

.ccb-category-btn svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

/* ---------- Messages Area ---------- */

.ccb-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.2) transparent;
}

.ccb-messages::-webkit-scrollbar {
    width: 4px;
}

.ccb-messages::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.2);
    border-radius: 4px;
}

/* ---------- Welcome Screen ---------- */

.ccb-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
    flex: 1;
    animation: ccb-fade-in 0.5s ease;
}

.ccb-welcome-icon {
    width: 64px;
    height: 64px;
    border-radius: 20px;
    background: linear-gradient(135deg, var(--ccb-primary), var(--ccb-accent));
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    box-shadow: 0 8px 30px rgba(47, 150, 56, 0.3);
}

.ccb-welcome-icon svg {
    width: 32px;
    height: 32px;
    color: #fff;
}

.ccb-welcome h4 {
    color: var(--ccb-text);
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 6px;
}

.ccb-welcome p {
    color: var(--ccb-text-muted);
    font-size: 13px;
    margin: 0 0 20px;
    line-height: 1.5;
}

/* ---------- Suggestions ---------- */

.ccb-suggestions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.ccb-suggestion {
    padding: 12px 16px;
    border-radius: var(--ccb-radius-sm);
    border: 1px solid var(--ccb-border);
    background: var(--ccb-bg-glass);
    color: var(--ccb-text);
    font-size: 13px;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s ease;
    font-family: inherit;
    line-height: 1.4;
}

.ccb-suggestion:hover {
    border-color: var(--ccb-primary);
    background: rgba(47, 150, 56, 0.1);
    transform: translateX(4px);
}

/* ---------- Message Bubbles ---------- */

.ccb-message {
    display: flex;
    gap: 10px;
    animation: ccb-slide-in 0.3s var(--ccb-transition);
    max-width: 100%;
}

.ccb-message.ccb-user {
    flex-direction: row-reverse;
}

.ccb-msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 13px;
}

.ccb-message.ccb-assistant .ccb-msg-avatar {
    background: linear-gradient(135deg, var(--ccb-primary), var(--ccb-accent));
    color: #fff;
}

.ccb-message.ccb-user .ccb-msg-avatar {
    background: rgba(148, 163, 184, 0.15);
    color: var(--ccb-text-muted);
}

.ccb-msg-bubble {
    max-width: 82%;
    padding: 12px 16px;
    border-radius: var(--ccb-radius-sm);
    font-size: 13.5px;
    line-height: 1.6;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.ccb-message.ccb-assistant .ccb-msg-bubble {
    background: var(--ccb-bg-glass);
    border: 1px solid var(--ccb-border);
    color: var(--ccb-text);
    border-top-left-radius: 4px;
}

.ccb-message.ccb-user .ccb-msg-bubble {
    background: linear-gradient(135deg, var(--ccb-primary), var(--ccb-primary-dark));
    color: #fff;
    border-top-right-radius: 4px;
}

/* Markdown inside bubbles */
.ccb-msg-bubble p { margin: 0 0 10px; line-height: 1.7; }
.ccb-msg-bubble p:last-child { margin-bottom: 0; }
.ccb-msg-bubble strong { font-weight: 700; color: #e2e8f0; }
.ccb-msg-bubble em { font-style: italic; color: var(--ccb-primary-light); }
.ccb-msg-bubble hr { border: none; border-top: 1px solid var(--ccb-border); margin: 14px 0; }
.ccb-msg-bubble code {
    background: rgba(47, 150, 56, 0.15);
    padding: 2px 7px;
    border-radius: 5px;
    font-size: 12px;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    color: var(--ccb-primary-light);
}
.ccb-msg-bubble pre {
    background: rgba(0, 0, 0, 0.35);
    padding: 14px;
    border-radius: 10px;
    overflow-x: auto;
    margin: 12px 0;
    border: 1px solid var(--ccb-border);
}
.ccb-msg-bubble pre code {
    background: none;
    padding: 0;
    color: var(--ccb-text);
}
.ccb-msg-bubble ul, .ccb-msg-bubble ol {
    margin: 10px 0;
    padding-left: 22px;
}
.ccb-msg-bubble li {
    margin: 6px 0;
    line-height: 1.6;
}
.ccb-msg-bubble li::marker {
    color: var(--ccb-primary-light);
}

/* Headings */
.ccb-msg-bubble h1, .ccb-msg-bubble h2, .ccb-msg-bubble h3 {
    font-weight: 700;
    color: #fff;
    margin: 16px 0 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--ccb-border);
    line-height: 1.3;
}
.ccb-msg-bubble h1 { font-size: 17px; }
.ccb-msg-bubble h2 { font-size: 15px; }
.ccb-msg-bubble h3 { font-size: 14px; border-bottom: none; }
.ccb-msg-bubble *:first-child { margin-top: 0; }

/* Tables */
.ccb-table-wrap {
    overflow-x: auto;
    margin: 12px 0;
    border-radius: 10px;
    border: 1px solid var(--ccb-border);
}
.ccb-msg-bubble table {
    border-collapse: collapse;
    font-size: 12.5px;
    width: 100%;
    margin: 0;
}
.ccb-msg-bubble thead th {
    background: rgba(47, 150, 56, 0.2);
    padding: 10px 14px;
    text-align: left;
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ccb-primary-light);
    border-bottom: 2px solid rgba(47, 150, 56, 0.3);
    white-space: nowrap;
}
.ccb-msg-bubble tbody td {
    padding: 9px 14px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.08);
    color: var(--ccb-text);
}
.ccb-msg-bubble tbody tr:last-child td {
    border-bottom: none;
}
.ccb-msg-bubble tbody tr:hover td {
    background: rgba(47, 150, 56, 0.06);
}
.ccb-msg-bubble tbody tr:nth-child(even) td {
    background: rgba(255, 255, 255, 0.02);
}
.ccb-msg-bubble th, .ccb-msg-bubble td {
    text-align: left;
}

/* ---------- Typing Indicator ---------- */

.ccb-typing {
    display: flex;
    gap: 10px;
    animation: ccb-fade-in 0.3s ease;
}

.ccb-typing .ccb-msg-avatar {
    background: linear-gradient(135deg, var(--ccb-primary), var(--ccb-accent));
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 13px;
}

.ccb-typing-dots {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 14px 18px;
    background: var(--ccb-bg-glass);
    border: 1px solid var(--ccb-border);
    border-radius: var(--ccb-radius-sm);
    border-top-left-radius: 4px;
}

.ccb-typing-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--ccb-primary-light);
    animation: ccb-bounce 1.4s ease-in-out infinite;
}

.ccb-typing-dots span:nth-child(2) { animation-delay: 0.16s; }
.ccb-typing-dots span:nth-child(3) { animation-delay: 0.32s; }

@keyframes ccb-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-8px); opacity: 1; }
}

/* ---------- Input Area ---------- */

.ccb-input-area {
    padding: 16px;
    border-top: 1px solid var(--ccb-border);
    flex-shrink: 0;
    background: rgba(15, 23, 42, 0.5);
}

.ccb-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: var(--ccb-bg-input);
    border: 1px solid var(--ccb-border);
    border-radius: 16px;
    padding: 6px 6px 6px 16px;
    transition: border-color 0.2s ease;
}

.ccb-input-wrapper:focus-within {
    border-color: var(--ccb-primary);
    box-shadow: 0 0 0 3px rgba(47, 150, 56, 0.1);
}

.ccb-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--ccb-text);
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 100px;
    line-height: 1.5;
    padding: 8px 0;
}

.ccb-input::placeholder {
    color: var(--ccb-text-muted);
}

.ccb-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, var(--ccb-primary), var(--ccb-primary-dark));
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.ccb-send-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(47, 150, 56, 0.4);
}

.ccb-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.ccb-send-btn svg {
    width: 18px;
    height: 18px;
}

/* ---------- Powered By ---------- */

.ccb-powered {
    text-align: center;
    padding: 8px;
    font-size: 10px;
    color: var(--ccb-text-muted);
    opacity: 0.5;
    border-top: 1px solid var(--ccb-border);
    flex-shrink: 0;
}

/* ---------- Animations ---------- */

@keyframes ccb-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes ccb-slide-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---------- Responsive ---------- */

@media (max-width: 480px) {
    .ccb-container {
        width: calc(100vw - 16px);
        height: calc(100vh - 90px);
        max-height: calc(100vh - 90px);
        bottom: 80px;
        right: 8px;
        border-radius: 16px;
    }

    .ccb-trigger {
        bottom: 16px;
        right: 16px;
        width: 56px;
        height: 56px;
    }
}
