/* ========================================
   CSS Variables & Base Styles
======================================== */
:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: rgba(99, 102, 241, 0.1);
    --secondary-color: #ec4899;
    --bg-dark: #0f0f23;
    --bg-card: #1a1a2e;
    --bg-input: #16162a;
    --text-primary: #ffffff;
    --text-secondary: #a0a0b8;
    --text-muted: #6b6b80;
    --border-color: rgba(255, 255, 255, 0.1);
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* ========================================
   Auth Pages Styles
======================================== */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    background: linear-gradient(135deg, var(--bg-dark) 0%, #1a1a3e 50%, var(--bg-dark) 100%);
}

.auth-container {
    position: relative;
    width: 100%;
    max-width: 420px;
}

.auth-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 40px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    position: relative;
    z-index: 1;
    backdrop-filter: blur(10px);
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-header .logo {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: float 3s ease-in-out infinite;
}

.auth-header .logo svg {
    width: 36px;
    height: 36px;
    color: white;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-8px);
    }
}

.auth-header h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--text-primary), var(--primary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.auth-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input {
    padding: 14px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 15px;
    transition: var(--transition);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-group input::placeholder {
    color: var(--text-muted);
}

.error-message {
    color: var(--error-color);
    font-size: 14px;
    text-align: center;
    min-height: 20px;
    display: none;
}

.error-message.show {
    display: block;
    animation: shake 0.4s ease;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

.btn {
    padding: 14px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn.loading .btn-text {
    display: none;
}

.btn .btn-loading {
    display: none;
}

.btn.loading .btn-loading {
    display: block;
}

.btn .spinner {
    width: 24px;
    height: 24px;
}

.auth-footer {
    margin-top: 24px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

.auth-decoration {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.glow {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.5;
}

.glow-1 {
    width: 300px;
    height: 300px;
    background: var(--primary-color);
    top: -100px;
    right: -100px;
    animation: pulse 4s ease-in-out infinite;
}

.glow-2 {
    width: 200px;
    height: 200px;
    background: var(--secondary-color);
    bottom: -50px;
    left: -50px;
    animation: pulse 4s ease-in-out infinite 1s;
}

.glow-3 {
    width: 150px;
    height: 150px;
    background: #06b6d4;
    top: 50%;
    left: -80px;
    animation: pulse 4s ease-in-out infinite 2s;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 0.3;
        transform: scale(1);
    }

    50% {
        opacity: 0.5;
        transform: scale(1.1);
    }
}

/* ========================================
   Chat Page Styles
======================================== */
.chat-page {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--bg-card);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h2 {
    font-size: 18px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.new-chat-btn {
    width: 100%;
    padding: 12px;
    background: var(--primary-light);
    color: var(--primary-color);
    border: 1px dashed var(--primary-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
}

.new-chat-btn:hover {
    background: var(--primary-color);
    color: white;
    border-style: solid;
}

.conversation-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.conversation-item {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.conversation-item:hover {
    background: var(--primary-light);
}

.conversation-item.active {
    background: var(--primary-color);
}

.conversation-item .title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
}

.conversation-item .delete-btn {
    opacity: 0;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    transition: var(--transition);
}

.conversation-item:hover .delete-btn {
    opacity: 1;
}

.conversation-item .delete-btn:hover {
    color: var(--error-color);
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 16px;
}

.user-details {
    flex: 1;
    overflow: hidden;
}

.user-name {
    font-weight: 600;
    font-size: 14px;
}

.user-expire {
    font-size: 12px;
    color: var(--text-muted);
}

.user-expire.warning {
    color: var(--warning-color);
}

.user-expire.danger {
    color: var(--error-color);
}

.sidebar-actions {
    display: flex;
    gap: 8px;
}

.sidebar-actions button {
    flex: 1;
    padding: 10px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
}

.sidebar-actions button:hover {
    background: var(--primary-light);
    color: var(--primary-color);
    border-color: var(--primary-color);
}

/* Main Chat Area */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-dark);
    overflow: hidden;
}

.chat-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-card);
}

.chat-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    padding-bottom: 40px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.message {
    display: flex;
    gap: 16px;
    max-width: 85%;
    animation: fadeIn 0.3s ease;
    align-items: flex-start;
    /* Allow sticky copy button to work properly */
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.message.assistant .message-avatar {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
}

.message.user .message-avatar {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
}

.message-content {
    background: var(--bg-card);
    padding: 16px 20px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    line-height: 1.7;
    font-size: 15px;
}

.message-content-wrapper {
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.message-content-wrapper .message-content {
    border: none;
    border-radius: 0;
}

.message.user .message-content {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.message-content pre {
    background: var(--bg-input);
    padding: 12px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 12px 0;
}

.message-content code {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 13px;
}

.welcome-message {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.welcome-message h2 {
    font-size: 28px;
    margin-bottom: 12px;
    background: linear-gradient(135deg, var(--text-primary), var(--primary-color));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.welcome-message p {
    font-size: 16px;
    max-width: 500px;
    margin: 0 auto;
}

/* Chat Input */
.chat-input-container {
    padding: 20px 24px;
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
}

.chat-input-wrapper {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    max-width: 900px;
    margin: 0 auto;
}

.chat-input {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px 18px;
    color: var(--text-primary);
    font-size: 15px;
    resize: none;
    max-height: 150px;
    line-height: 1.5;
    transition: var(--transition);
}

.chat-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.chat-input::placeholder {
    color: var(--text-muted);
}

.send-btn {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.send-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.send-btn svg {
    width: 22px;
    height: 22px;
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 8px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--text-secondary);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {

    0%,
    60%,
    100% {
        transform: translateY(0);
    }

    30% {
        transform: translateY(-8px);
    }
}

/* ========================================
   Admin Page Styles
======================================== */
.admin-page {
    min-height: 100vh;
    padding: 24px;
    background: linear-gradient(135deg, var(--bg-dark) 0%, #1a1a3e 100%);
}

.admin-container {
    max-width: 1200px;
    margin: 0 auto;
}

.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 32px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.admin-header h1 {
    font-size: 28px;
    background: linear-gradient(135deg, var(--text-primary), var(--primary-color));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.admin-header-actions {
    display: flex;
    gap: 12px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    padding: 24px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.stat-card h3 {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.stat-card .value {
    font-size: 32px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.admin-section {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.section-header h2 {
    font-size: 18px;
}

/* Table */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 16px 20px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background: var(--bg-input);
    font-weight: 600;
    font-size: 13px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

td {
    font-size: 14px;
}

tr:hover {
    background: var(--primary-light);
}

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.badge-admin {
    background: rgba(236, 72, 153, 0.15);
    color: #ec4899;
}

.badge-user {
    background: rgba(99, 102, 241, 0.15);
    color: #6366f1;
}

.badge-active {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.badge-inactive {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.badge-expired {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.badge-warning {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.action-btns {
    display: flex;
    gap: 8px;
}

.action-btn {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition);
}

.action-btn:hover {
    background: var(--primary-light);
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.action-btn.danger:hover {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error-color);
    border-color: var(--error-color);
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 32px;
    max-width: 450px;
    width: 90%;
    border: 1px solid var(--border-color);
    transform: scale(0.9);
    transition: var(--transition);
}

.modal-overlay.show .modal {
    transform: scale(1);
}

.modal-header {
    margin-bottom: 24px;
}

.modal-header h3 {
    font-size: 20px;
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.modal-footer {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
}

.btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--primary-light);
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-sm {
    padding: 10px 20px;
    font-size: 14px;
}

/* ========================================
   Responsive Styles
======================================== */
@media (max-width: 768px) {
    .chat-page {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        max-height: 50vh;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .message {
        max-width: 95%;
    }

    .admin-header {
        flex-direction: column;
        gap: 16px;
        align-items: flex-start;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    table {
        font-size: 13px;
    }

    th,
    td {
        padding: 12px;
    }
}

/* ========================================
   Scrollbar Styles
======================================== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-input);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ========================================
   Thinking Block Styles
======================================== */
.thinking-block {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(236, 72, 153, 0.05));
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    overflow: hidden;
}

.thinking-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: rgba(99, 102, 241, 0.1);
    cursor: pointer;
    user-select: none;
    transition: var(--transition);
}

.thinking-header:hover {
    background: rgba(99, 102, 241, 0.15);
}

.thinking-icon {
    font-size: 18px;
}

.thinking-title {
    flex: 1;
    font-weight: 600;
    font-size: 14px;
    color: var(--primary-color);
}

.thinking-toggle {
    color: var(--text-secondary);
    transition: transform 0.3s ease;
}

.thinking-block.collapsed .thinking-toggle {
    transform: rotate(-90deg);
}

.thinking-content {
    padding: 16px;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.8;
    max-height: 300px;
    overflow-y: auto;
    transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.3s ease;
}

.thinking-block.collapsed .thinking-content {
    max-height: 0;
    padding: 0 16px;
    opacity: 0;
    overflow: hidden;
}

/* Streaming Cursor */
.cursor {
    display: inline-block;
    color: var(--primary-color);
    animation: blink 1s infinite;
}

@keyframes blink {

    0%,
    50% {
        opacity: 1;
    }

    51%,
    100% {
        opacity: 0;
    }
}

/* ========================================
   Enhanced Markdown Content Styles
======================================== */
.message-content h1,
.message-content h2,
.message-content h3 {
    margin: 16px 0 8px 0;
    font-weight: 600;
    color: var(--text-primary);
}

.message-content h1 {
    font-size: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

.message-content h2 {
    font-size: 18px;
}

.message-content h3 {
    font-size: 16px;
}

.message-content p {
    margin: 8px 0;
}

.message-content ul,
.message-content ol {
    margin: 8px 0;
    padding-left: 24px;
}

.message-content li {
    margin: 4px 0;
}

.message-content blockquote {
    border-left: 3px solid var(--primary-color);
    padding-left: 16px;
    margin: 12px 0;
    color: var(--text-secondary);
    font-style: italic;
}

.message-content hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 16px 0;
}

.message-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 13px;
}

.message-content table th,
.message-content table td {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    text-align: left;
}

.message-content table th {
    background: var(--bg-input);
    font-weight: 600;
    color: var(--text-primary);
}

.message-content table tr:hover {
    background: var(--primary-light);
}

.message-content pre {
    background: var(--bg-input);
    padding: 16px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 12px 0;
    border: 1px solid var(--border-color);
}

.message-content code {
    font-family: 'Consolas', 'Monaco', 'Fira Code', monospace;
    font-size: 13px;
    background: rgba(99, 102, 241, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
}

.message-content pre code {
    background: transparent;
    padding: 0;
}

.message-content strong {
    font-weight: 600;
    color: var(--text-primary);
}

.message-content em {
    font-style: italic;
    color: var(--text-secondary);
}

/* ========================================
   Message Copy Button (Side - Sticky)
======================================== */
.message-copy-btn-wrapper {
    position: sticky;
    top: 80px;
    /* Below header */
    align-self: flex-start;
    flex-shrink: 0;
    margin-left: 8px;
    z-index: 10;
}

.copy-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 6px 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 11px;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.copy-btn:hover {
    background: var(--primary-light);
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.copy-btn.copied {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success-color);
    border-color: var(--success-color);
}

.copy-btn svg {
    width: 12px;
    height: 12px;
}

/* ========================================
   Stop Generation Button
======================================== */
.stop-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid var(--error-color);
    border-radius: var(--radius-sm);
    color: var(--error-color);
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    margin: 0 auto;
    margin-top: 12px;
}

.stop-btn:hover {
    background: rgba(239, 68, 68, 0.25);
}

.stop-btn svg {
    width: 16px;
    height: 16px;
}

.stop-btn-container {
    position: fixed;
    bottom: 100px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    padding: 10px 0;
    z-index: 51;
    background: linear-gradient(to top, var(--bg-dark) 0%, transparent 100%);
    pointer-events: none;
}

.stop-btn-container .stop-btn {
    pointer-events: auto;
}

/* User message content should be simpler */
.message.user .message-content h1,
.message.user .message-content h2,
.message.user .message-content h3,
.message.user .message-content strong {
    color: white;
}

.message.user .message-content code {
    background: rgba(255, 255, 255, 0.2);
}

/* ========================================
   Quick Action Buttons
======================================== */
.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 20px;
    justify-content: center;
}

.quick-action-btn {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(236, 72, 153, 0.1));
    border: 1px solid rgba(99, 102, 241, 0.3);
    color: var(--text-primary);
    padding: 12px 18px;
    border-radius: var(--radius-md);
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
}

.quick-action-btn:hover {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.4), rgba(236, 72, 153, 0.2));
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

/* ========================================
   Voice Input Button
======================================== */
.voice-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.voice-btn svg {
    width: 20px;
    height: 20px;
    color: var(--text-secondary);
}

.voice-btn:hover {
    background: var(--primary-light);
    border-color: var(--primary-color);
}

.voice-btn:hover svg {
    color: var(--primary-color);
}

.voice-btn.recording {
    background: rgba(239, 68, 68, 0.2);
    border-color: var(--error-color);
    animation: pulse-recording 1s ease-in-out infinite;
}

.voice-btn.recording svg {
    color: var(--error-color);
}

@keyframes pulse-recording {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

.voice-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    color: var(--error-color);
    font-size: 14px;
}

.voice-indicator {
    width: 12px;
    height: 12px;
    background: var(--error-color);
    border-radius: 50%;
    animation: blink 0.5s ease-in-out infinite;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }
}

/* ========================================
   Mobile Menu Button
======================================== */
.mobile-menu-btn {
    display: none;
    width: 40px;
    height: 40px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    padding: 8px;
}

.mobile-menu-btn svg {
    width: 100%;
    height: 100%;
    color: var(--text-primary);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

/* ========================================
   Mobile Responsive Styles
======================================== */
@media (max-width: 768px) {

    /* Sidebar for mobile - hidden by default */
    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        height: 100vh;
        width: 280px;
        z-index: 100;
        transition: left 0.3s ease;
    }

    .sidebar.open {
        left: 0;
    }

    .sidebar-overlay.show {
        display: block;
    }

    /* Chat page takes full screen */
    .chat-page {
        display: flex;
        flex-direction: column;
        height: 100vh;
        height: 100dvh;
        /* Dynamic viewport height for mobile browsers */
    }

    /* Chat main fills available space */
    .chat-main {
        flex: 1;
        display: flex;
        flex-direction: column;
        width: 100%;
        height: 100vh;
        height: 100dvh;
        overflow: hidden;
    }

    /* Header */
    .chat-header {
        flex-shrink: 0;
    }

    /* Messages area scrolls */
    .chat-messages {
        flex: 1;
        overflow-y: auto;
        padding-bottom: 160px;
        /* Increased space for fixed input + stop button to prevent overlap */
    }

    /* Input container fixed at bottom */
    .chat-input-container {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--bg-dark);
        padding: 10px 15px 20px;
        padding-bottom: max(20px, env(safe-area-inset-bottom));
        border-top: 1px solid var(--border-color);
        z-index: 50;
    }

    /* Stop button container fixed above input on mobile */
    .stop-btn-container {
        position: fixed;
        bottom: 80px;
        bottom: calc(80px + env(safe-area-inset-bottom));
        left: 0;
        right: 0;
        z-index: 51;
        background: var(--bg-dark);
        padding: 8px 15px;
    }

    /* Show mobile menu button */
    .mobile-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .chat-header {
        padding: 12px 15px;
        gap: 10px;
    }

    .chat-header h3 {
        font-size: 16px;
    }

    /* Messages container */
    .chat-messages {
        padding: 15px;
    }

    .message {
        max-width: 95%;
        padding: 12px;
    }

    .message-avatar {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }

    .message-content {
        font-size: 14px;
    }

    /* Welcome message */
    .welcome-message {
        padding: 20px;
    }

    .welcome-message h2 {
        font-size: 22px;
    }

    .welcome-message p {
        font-size: 14px;
    }

    /* Quick actions on mobile */
    .quick-actions {
        gap: 8px;
    }

    .quick-action-btn {
        padding: 10px 14px;
        font-size: 13px;
        width: calc(50% - 4px);
        justify-content: center;
        text-align: center;
    }

    /* Input area */
    .chat-input-container {
        padding: 10px 15px 20px;
    }

    .chat-input-wrapper {
        gap: 8px;
    }

    .chat-input {
        padding: 12px 15px;
        font-size: 15px;
    }

    .voice-btn {
        width: 40px;
        height: 40px;
        min-width: 40px;
    }

    .send-btn {
        width: 40px;
        height: 40px;
        min-width: 40px;
    }

    /* Auth pages on mobile */
    .auth-card {
        padding: 25px;
    }

    .auth-header .logo {
        width: 56px;
        height: 56px;
    }

    /* Admin page */
    .admin-page .container {
        padding: 15px;
    }

    .admin-card {
        padding: 20px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .stat-card {
        padding: 15px;
    }

    .stat-card h3 {
        font-size: 20px;
    }

    .user-table {
        font-size: 13px;
    }

    .user-table th,
    .user-table td {
        padding: 10px 8px;
    }
}

@media (max-width: 480px) {
    .quick-action-btn {
        width: 100%;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }
}