/* ===== Reset & Base ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.form-control {
    display: block;
    width: 100%;
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.5;
    color: #212529;
    background-color: #fff;
    border: 1px solid #dee2e6;
    appearance: none;
    outline: none;
}

.form-control:focus {
    outline: none;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
    font-weight: 400;
    line-height: 1.5;
    text-align: center;
    vertical-align: middle;
    cursor: pointer;
    user-select: none;
    border: 1px solid transparent;
    background-color: transparent;
}

:root {
    --sidebar-bg: #1a1a1a;
    --sidebar-width: 260px;
    --green-accent: #00e600;
    --green-hover: #00cc00;
    --green-dim: #00b300;
    --dark-text: #e0e0e0;
    --dark-muted: #888;
    --header-bg: #1a1a1a;
    --chat-bg: #ffffff;
    --user-bubble: #00e600;
    --user-bubble-text: #1a1a1a;
    --bot-bubble: #f0f0f0;
    --bot-bubble-text: #333;
}

body {
    font-family: Arimo, sans-serif;
    font-size: 20px;
    font-weight: 400;
    line-height: 1.4em;
    height: 100vh;
    display: flex;
    overflow: hidden;
    background-color: var(--chat-bg);
}

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background-color: var(--sidebar-bg);
    display: none;
    flex-direction: column;
    flex-shrink: 0;
    border-right: 1px solid #2a2a2a;
    transition: transform 0.3s ease;
    z-index: 1000;
}

.sidebar-header {
    padding: 16px 16px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid #2a2a2a;
}

.sidebar-logo {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--green-accent);
}

.sidebar-brand {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--green-accent);
    letter-spacing: 0.5px;
}

.new-chat-btn {
    margin: 12px 12px 0;
    padding: 10px 16px;
    background: transparent;
    border: 1.5px solid var(--green-accent);
    color: var(--green-accent);
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.new-chat-btn:hover {
    background-color: var(--green-accent);
    color: #1a1a1a;
}

.sidebar-divider {
    height: 1px;
    background-color: #2a2a2a;
    margin: 12px 0;
}

.sidebar-label {
    padding: 0 16px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--dark-muted);
    margin-bottom: 4px;
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 4px 8px;
}

.chat-history-item {
    padding: 10px 12px;
    border-radius: 6px;
    color: var(--dark-text);
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-history-item:hover {
    background-color: #2a2a2a;
}

.chat-history-item.active {
    background-color: #2a2a2a;
    color: var(--green-accent);
}

.chat-history-item i {
    flex-shrink: 0;
    font-size: 0.8rem;
    color: var(--dark-muted);
}

.chat-history-item.active i {
    color: var(--green-accent);
}

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid #2a2a2a;
    color: var(--dark-muted);
    font-size: 0.7rem;
    text-align: center;
}

/* ===== Sidebar overlay (mobile) ===== */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

.sidebar-overlay.show {
    display: block;
}

/* ===== Main Wrapper ===== */
.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* ===== Header ===== */
header {
    background-color: var(--header-bg);
    padding: 14px 20px;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    gap: 12px;
}

header h1 {
    font-size: 1.3rem;
    color: var(--green-accent);
    font-weight: 700;
    margin: 0;
    flex: 1;
    text-align: center;
}

.sidebar-toggle {
    background: none;
    border: none;
    font-size: 1.4rem;
    color: #e0e0e0;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background-color 0.15s;
}

.sidebar-toggle:hover {
    background-color: rgba(0, 0, 0, 0.08);
}

.header-spacer {
    width: 40px;
}

/* ===== Auth Button (header) ===== */
.btn-auth {
    background-color: #fff;
    color: #333;
    border: 1.5px solid #ccc;
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    transition: all 0.2s;
}

.btn-auth:hover {
    border-color: var(--green-accent);
    color: var(--green-accent);
}

.auth-status.authorized {
    color: var(--green-accent);
    font-size: 1.2rem;
}

/* ===== Main / Chat ===== */
main {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background-color: var(--chat-bg);
}

/* ===== Chat Messages Container ===== */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
}

/* Hide scrollbar but keep scrolling */
.chat-messages::-webkit-scrollbar {
    width: 0;
    display: none;
}

.chat-messages {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* ===== Messages ===== */
.message {
    display: flex;
    gap: 10px;
    max-width: 85%;
}

.user-message {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.bot-message {
    align-self: flex-start;
}

.bot-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    margin-top: 2px;
}

.bot-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.message-bubble {
    padding: 10px 16px;
    border-radius: 16px;
    font-size: 0.85em;
    line-height: 1.4em;
    word-wrap: break-word;
}

.user-message .message-bubble {
    background-color: var(--user-bubble);
    color: var(--user-bubble-text);
    border-bottom-right-radius: 4px;
    font-weight: 500;
}

.bot-message .message-bubble {
    background-color: var(--bot-bubble);
    color: var(--bot-bubble-text);
    border-bottom-left-radius: 4px;
}

/* ===== Footer / Input ===== */
footer {
    background-color: var(--chat-bg);
    border-top: 1px solid #e0e0e0;
    padding: 12px 16px;
    flex-shrink: 0;
}

.input-bar {
    display: flex;
    gap: 8px;
    max-width: 800px;
    margin: 0 auto;
    padding: 0 12px;
}

.input-bar .form-control {
    border-radius: 24px;
    padding: 10px 20px;
    border: 1.5px solid #ccc;
    font-size: 0.93rem;
    transition: border-color 0.2s;
    min-width: 50%;
    flex: 1;
}

.input-bar .form-control:focus {
    border-color: var(--green-accent);
    box-shadow: 0 0 0 2px rgba(0, 230, 0, 0.15);
}

.input-bar .btn {
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.1rem;
    transition: all 0.2s;
}

.btn-send {
    background-color: var(--green-accent);
    color: #1a1a1a;
    border: none;
}

.btn-send:hover {
    background-color: var(--green-hover);
    color: #1a1a1a;
}

.btn-mic {
    background: transparent;
    border: 1.5px solid #ccc;
    color: #555;
}

.btn-mic:hover {
    border-color: var(--green-accent);
    color: var(--green-accent);
}

.btn-mic.listening {
    background-color: #dc3545;
    border-color: #dc3545;
    color: #fff;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(220, 53, 69, 0); }
    100% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0); }
}

/* ===== Typing Indicator ===== */
.typing-indicator {
    display: flex;
    gap: 5px;
    padding: 12px 16px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background-color: #adb5bd;
    border-radius: 50%;
    animation: bounce 1.4s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

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

/* ===== Scrollbar (sidebar) ===== */
.chat-history::-webkit-scrollbar {
    width: 6px;
}

.chat-history::-webkit-scrollbar-thumb {
    background-color: #333;
    border-radius: 3px;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-wrapper {
        width: 100%;
    }

    .message {
        max-width: 92%;
    }

    header h1 {
        font-size: 1.15rem;
    }
}

@media (min-width: 769px) {
    .sidebar-toggle {
        display: none;
    }

    .header-spacer {
        display: none;
    }
}
