:root {
    --bg-color: #0d1117;
    --card-bg: rgba(22, 27, 34, 0.9);
    --accent: #7d56f5;
    --accent-glow: rgba(125, 86, 245, 0.3);
    --text-primary: #f0f6fc;
    --text-secondary: #8b949e;
    --border: #30363d;
    --glass: rgba(255, 255, 255, 0.05);
    --user-msg-bg: #7d56f5;
    --ai-msg-bg: #21262d;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-sans);
    background-color: var(--bg-color);
    background-image:
        radial-gradient(circle at 10% 20%, rgba(125, 86, 245, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(33, 136, 255, 0.05) 0%, transparent 40%);
    color: var(--text-primary);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: background 0.5s ease;
}

body.is-minimized {
    background: transparent;
    height: auto;
}

body.is-minimized #chat-container,
body.is-minimized .input-area,
body.is-minimized #ops-panel {
    display: none !important;
}

/* Header */
header {
    padding: 1rem 1.5rem;
    background: rgba(13, 17, 23, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 100;
    cursor: default;
}

.is-minimized header {
    border-bottom: none;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0; /* Allows children to handle overflow */
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--accent), #2188ff);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.1rem;
    box-shadow: 0 0 15px var(--accent-glow);
    flex-shrink: 0;
}

.logo-text {
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: -0.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.status-indicator {
    display: flex;
    align-items: center;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Chat Container */
#chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 2rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    scroll-behavior: smooth;
}

/* Scrollbar */
#chat-container::-webkit-scrollbar {
    width: 6px;
}

#chat-container::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}

/* Messages */
.message {
    max-width: 85%;
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    align-self: flex-end;
}

.message.ai {
    align-self: flex-start;
}

.bubble {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 0.95rem;
    line-height: 1.5;
    word-wrap: break-word;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.user .bubble {
    background: var(--user-msg-bg);
    color: white;
    border-bottom-right-radius: 4px;
}

.ai .bubble {
    background: var(--ai-msg-bg);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border);
}

.ai .bubble p {
    margin: 0 0 8px 0;
}

.ai .bubble p:last-child {
    margin-bottom: 0;
}

.ai .bubble strong {
    color: #a485ff;
    background: rgba(125, 86, 245, 0.15);
    padding: 2px 6px;
    border-radius: 6px;
    font-weight: 600;
    margin: 0 2px;
    display: inline-block;
    border: 1px solid rgba(125, 86, 245, 0.3);
}

.ai .bubble ul, 
.ai .bubble ol {
    margin: 8px 0 8px 24px;
    padding: 0;
}

.ai .bubble li {
    margin-bottom: 4px;
}

.message-info {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 5px;
    margin-bottom: 2px;
}

.user .message-info {
    text-align: right;
}

/* Input Area */
.input-area {
    padding: 1.5rem;
    background: linear-gradient(to top, var(--bg-color) 80%, transparent);
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    position: relative;
}

.input-box {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 24px;
    display: flex;
    align-items: center;
    padding: 8px 8px 8px 20px;
    transition: all 0.3s;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.input-box:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(125, 86, 245, 0.1), 0 10px 30px rgba(0, 0, 0, 0.3);
}

input[type="text"] {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    padding: 10px 0;
    font-size: 1rem;
    outline: none;
}

input[type="text"]::placeholder {
    color: var(--text-secondary);
}

.send-btn {
    width: 40px;
    height: 40px;
    background: var(--accent);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.send-btn:hover {
    transform: scale(1.05);
    background: #8b68f7;
}

.send-btn:disabled {
    background: var(--border);
    cursor: not-allowed;
    transform: none;
}

/* Typing Indicator */
.typing {
    display: flex;
    gap: 4px;
    padding: 5px 0;
}

.dot {
    width: 6px;
    height: 6px;
    background: var(--text-secondary);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
}

.dot:nth-child(2) {
    animation-delay: 0.2s;
}

.dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

/* Mobile Optimizations */
@media (max-width: 600px) {
    #chat-container {
        padding: 1rem;
    }

    .message {
        max-width: 90%;
    }

    .input-area {
        padding: 1rem;
    }

    .bubble {
        font-size: 1rem;
        /* Slightly larger for readability on mobile */
    }
}

/* Feedback Buttons */
.feedback-btns {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.feedback-btns button {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    padding: 4px 8px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 4px;
}

.feedback-btns button:hover {
    background: var(--glass);
    border-color: var(--accent);
    color: var(--text-primary);
    transform: translateY(-1px);
}

.feedback-btns button:active {
    transform: translateY(0);
}

/* Quick Q&A Panel (Replaces Ops Panel) */
.qa-panel {
    position: fixed;
    bottom: 100px;
    left: 20px;
    right: 20px;
    max-width: 860px;
    margin: 0 auto;
    background: rgba(22, 27, 34, 0.98);
    backdrop-filter: blur(25px);
    border: 1px solid var(--accent);
    border-radius: 20px;
    z-index: 200;
    display: none;
    flex-direction: column;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6), 0 0 30px var(--accent-glow);
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
}

.qa-panel.active {
    display: flex;
}

.qa-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--accent);
    background: rgba(255, 255, 255, 0.02);
}

.qa-header button {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.85rem;
    transition: color 0.2s;
}

.qa-header button:hover {
    color: white;
}

.qa-body {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.qa-item {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-primary);
    padding: 12px 16px;
    font-size: 0.9rem;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.qa-item:hover {
    background: rgba(125, 86, 245, 0.1);
    border-color: var(--accent);
    transform: translateX(4px);
}

.qa-item:active {
    transform: translateX(2px);
}

.tool-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin-right: 12px;
    transition: color 0.2s;
}

.tool-btn:hover {
    color: var(--accent);
}

.ctrl-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
}

.ctrl-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}