/* AI Chat WebUI - Main Stylesheet */

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #10b981;
    --secondary-dark: #059669;
    --danger: #ef4444;
    --danger-dark: #dc2626;
    --warning: #f59e0b;
    --info: #3b82f6;
    --dark: #1f2937;
    --dark-light: #374151;
    --gray: #6b7280;
    --gray-light: #9ca3af;
    --light: #f3f4f6;
    --white: #ffffff;
    --border: #e5e7eb;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius: 0.5rem;
    --radius-lg: 1rem;
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow-x: hidden;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--dark);
    background-color: var(--light);
}

/* Theme: Neo Terminal */
body[data-theme='neo_terminal'] {
    --primary: #2c9f68;
    --primary-dark: #247f54;
    --primary-light: #57bb87;
    --secondary: #2c8f9f;
    --secondary-dark: #267786;
    --warning: #f59e0b;
    --info: #22d3ee;
    --dark: #05130d;
    --dark-light: #0b2218;
    --gray: #3f5f50;
    --gray-light: #7ea392;
    --light: #edf6f1;
    --white: #f8fbf9;
    --border: #c4d9cd;
    --shadow: 0 10px 22px -14px rgba(22, 52, 37, 0.32);
    --shadow-lg: 0 16px 40px -20px rgba(22, 52, 37, 0.4);
    font-family: 'Consolas', 'Cascadia Code', 'Fira Code', monospace;
    background: radial-gradient(circle at top right, #233d31 0%, #172c23 45%, #13241d 100%);
}

body[data-theme='neo_terminal'] .chat-wrapper,
body[data-theme='neo_terminal'] .admin-wrapper {
    background-image: linear-gradient(rgba(71, 119, 89, 0.14) 1px, transparent 1px), linear-gradient(90deg, rgba(71, 119, 89, 0.12) 1px, transparent 1px);
    background-size: 26px 26px;
}

body[data-theme='neo_terminal'] .auth-card,
body[data-theme='neo_terminal'] .card,
body[data-theme='neo_terminal'] .modal {
    border: 1px solid #a9c5b4;
    border-radius: 0.75rem;
}

body[data-theme='neo_terminal'] .chat-sidebar,
body[data-theme='neo_terminal'] .admin-sidebar {
    border-right: 1px solid rgba(98, 144, 115, 0.45);
}

body[data-theme='neo_terminal'] .message {
    border-radius: 0.45rem;
}

body[data-theme='neo_terminal'] .chat-input,
body[data-theme='neo_terminal'] .form-control,
body[data-theme='neo_terminal'] .form-select {
    border-width: 1px;
    box-shadow: inset 0 0 0 1px rgba(87, 136, 108, 0.08);
}

body[data-theme='neo_terminal'] .chat-main,
body[data-theme='neo_terminal'] .admin-main,
body[data-theme='neo_terminal'] .auth-card,
body[data-theme='neo_terminal'] .card,
body[data-theme='neo_terminal'] .modal,
body[data-theme='neo_terminal'] .chat-header,
body[data-theme='neo_terminal'] .chat-input-wrapper,
body[data-theme='neo_terminal'] .admin-header {
    background: rgba(247, 255, 249, 0.96);
}

body[data-theme='neo_terminal'] .chat-sidebar,
body[data-theme='neo_terminal'] .admin-sidebar {
    background: linear-gradient(180deg, #03160f 0%, #07261a 60%, #0b301f 100%);
}

/* Theme: Hacker Feeling */
body[data-theme='hacker'] {
    --primary: #28b374;
    --primary-dark: #239661;
    --primary-light: #57c792;
    --secondary: #2c9fb5;
    --secondary-dark: #24879a;
    --warning: #facc15;
    --info: #38bdf8;
    --dark: #020507;
    --dark-light: #0a1014;
    --gray: #43606f;
    --gray-light: #7fa2b5;
    --light: #ecf5f7;
    --white: #f8fbfc;
    --border: #b9d4da;
    --shadow: 0 12px 26px -16px rgba(28, 83, 95, 0.32);
    --shadow-lg: 0 20px 45px -22px rgba(28, 83, 95, 0.4);
    font-family: 'Consolas', 'Lucida Console', 'Fira Code', monospace;
    background: radial-gradient(circle at 20% 0%, #1a333d 0%, #14262d 48%, #101f26 100%);
}

body[data-theme='hacker'] .chat-wrapper,
body[data-theme='hacker'] .admin-wrapper {
    background-image: repeating-linear-gradient(0deg, rgba(115, 178, 160, 0.05) 0px, rgba(115, 178, 160, 0.05) 1px, transparent 1px, transparent 3px);
}

body[data-theme='hacker'] .auth-wrapper {
    background: linear-gradient(145deg, #182f38 0%, #15313a 50%, #122a33 100%);
}

body[data-theme='hacker'] .auth-card,
body[data-theme='hacker'] .card,
body[data-theme='hacker'] .modal {
    border: 1px solid #87aeb4;
    border-radius: 0.25rem;
    box-shadow: 0 0 0 1px rgba(46, 100, 111, 0.22), var(--shadow);
}

body[data-theme='hacker'] .chat-sidebar,
body[data-theme='hacker'] .admin-sidebar {
    border-right: 1px solid rgba(110, 160, 168, 0.4);
}

body[data-theme='hacker'] .btn,
body[data-theme='hacker'] .chat-send-btn,
body[data-theme='hacker'] .new-chat-btn {
    border-radius: 0.2rem;
}

body[data-theme='hacker'] .conversation-item,
body[data-theme='hacker'] .admin-nav-item,
body[data-theme='hacker'] .user-nav-link {
    border-radius: 0.25rem;
}

/* Theme: Kali Linux */
body[data-theme='kali_linux'] {
    --primary: #4f7dbd;
    --primary-dark: #3f69a3;
    --primary-light: #7398cf;
    --secondary: #2e5a8a;
    --secondary-dark: #284d76;
    --danger: #d35f6a;
    --danger-dark: #b74f5a;
    --warning: #d1a43f;
    --info: #4f93d1;
    --dark: #0d1520;
    --dark-light: #1b2837;
    --gray: #5f7287;
    --gray-light: #93a2b5;
    --light: #eef2f7;
    --white: #f8fafc;
    --border: #c9d3df;
    --shadow: 0 10px 24px -14px rgba(14, 24, 36, 0.32);
    --shadow-lg: 0 20px 45px -22px rgba(14, 24, 36, 0.4);
    font-family: 'Segoe UI', 'Inter', sans-serif;
    background: radial-gradient(circle at 15% 0%, #24384d 0%, #1b2b3b 45%, #152231 100%);
}

body[data-theme='kali_linux'] .chat-wrapper,
body[data-theme='kali_linux'] .admin-wrapper {
    background-image: radial-gradient(circle at 120% -15%, rgba(133, 163, 204, 0.14) 0%, transparent 42%);
}

body[data-theme='kali_linux'] .auth-wrapper {
    background: linear-gradient(145deg, #1e2f42 0%, #22384d 48%, #162533 100%);
}

body[data-theme='kali_linux'] .chat-main,
body[data-theme='kali_linux'] .admin-main,
body[data-theme='kali_linux'] .auth-card,
body[data-theme='kali_linux'] .card,
body[data-theme='kali_linux'] .modal,
body[data-theme='kali_linux'] .chat-header,
body[data-theme='kali_linux'] .chat-input-wrapper,
body[data-theme='kali_linux'] .admin-header {
    background: rgba(248, 250, 252, 0.97);
}

body[data-theme='kali_linux'] .chat-sidebar,
body[data-theme='kali_linux'] .admin-sidebar {
    background: linear-gradient(180deg, #0c1622 0%, #172738 50%, #1f3348 100%);
}

body[data-theme='kali_linux'] .auth-card,
body[data-theme='kali_linux'] .card,
body[data-theme='kali_linux'] .modal {
    border: 1px solid #c3cedb;
    border-radius: 0.9rem;
}

body[data-theme='kali_linux'] .chat-header,
body[data-theme='kali_linux'] .admin-header {
    border-bottom: 1px solid #d2dce8;
}

body[data-theme='kali_linux'] .chat-input-wrapper {
    border-top: 1px solid #d2dce8;
}

/* Theme: Slate Calm */
body[data-theme='slate_calm'] {
    --primary: #4f7a9a;
    --primary-dark: #426784;
    --primary-light: #7497b2;
    --secondary: #628e8a;
    --secondary-dark: #547975;
    --danger: #c56b75;
    --danger-dark: #ae5964;
    --warning: #c69b56;
    --info: #5f93b3;
    --dark: #19232f;
    --dark-light: #273444;
    --gray: #5f6f7f;
    --gray-light: #8998a7;
    --light: #edf1f4;
    --white: #f9fbfc;
    --border: #cad4dc;
    --shadow: 0 10px 24px -14px rgba(24, 37, 49, 0.28);
    --shadow-lg: 0 18px 38px -20px rgba(24, 37, 49, 0.35);
    font-family: 'Inter', 'Segoe UI', sans-serif;
    background: radial-gradient(circle at top right, #385066 0%, #2f4357 44%, #273847 100%);
}

body[data-theme='slate_calm'] .chat-wrapper,
body[data-theme='slate_calm'] .admin-wrapper {
    background-image: linear-gradient(145deg, rgba(214, 225, 234, 0.17) 0%, transparent 45%);
}

body[data-theme='slate_calm'] .auth-wrapper {
    background: linear-gradient(145deg, #3e5a73 0%, #345166 50%, #2a4457 100%);
}

body[data-theme='slate_calm'] .chat-main,
body[data-theme='slate_calm'] .admin-main,
body[data-theme='slate_calm'] .auth-card,
body[data-theme='slate_calm'] .card,
body[data-theme='slate_calm'] .modal,
body[data-theme='slate_calm'] .chat-header,
body[data-theme='slate_calm'] .chat-input-wrapper,
body[data-theme='slate_calm'] .admin-header {
    background: rgba(249, 251, 252, 0.97);
}

body[data-theme='slate_calm'] .chat-sidebar,
body[data-theme='slate_calm'] .admin-sidebar {
    background: linear-gradient(180deg, #1b2835 0%, #253748 58%, #2b4053 100%);
}

body[data-theme='slate_calm'] .auth-card,
body[data-theme='slate_calm'] .card,
body[data-theme='slate_calm'] .modal {
    border: 1px solid #c7d2db;
    border-radius: 1rem;
}

body[data-theme='slate_calm'] .message {
    border-radius: 0.9rem;
}

/* Theme refinements shared by both custom themes */
body[data-theme='neo_terminal'] .message-assistant,
body[data-theme='hacker'] .message-assistant,
body[data-theme='kali_linux'] .message-assistant,
body[data-theme='slate_calm'] .message-assistant {
    border: 1px solid var(--border);
}

body[data-theme='neo_terminal'] .form-control,
body[data-theme='neo_terminal'] .form-select,
body[data-theme='hacker'] .form-control,
body[data-theme='hacker'] .form-select,
body[data-theme='kali_linux'] .form-control,
body[data-theme='kali_linux'] .form-select,
body[data-theme='slate_calm'] .form-control,
body[data-theme='slate_calm'] .form-select {
    background-color: #fcfffd;
}

body[data-theme='neo_terminal'] .admin-nav-item.active,
body[data-theme='hacker'] .admin-nav-item.active {
    background: rgba(44, 159, 104, 0.15);
    border-left-color: var(--primary);
}

body[data-theme='kali_linux'] .admin-nav-item.active {
    background: rgba(79, 125, 189, 0.16);
    border-left-color: var(--primary);
}

body[data-theme='slate_calm'] .admin-nav-item.active {
    background: rgba(79, 122, 154, 0.16);
    border-left-color: var(--primary);
}

body[data-theme='neo_terminal'] .alert-info,
body[data-theme='hacker'] .alert-info {
    background: #dcf8ff;
    color: #0f4f6b;
    border-color: #a9e5f7;
}

body[data-theme='kali_linux'] .alert-info,
body[data-theme='slate_calm'] .alert-info {
    background: #e7f0fa;
    color: #274a6b;
    border-color: #c7d9ec;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-dark);
}

/* Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

.container-fluid {
    padding: 0 1rem;
}

/* Auth Pages */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    padding: 2rem;
}

.auth-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    padding: 2.5rem;
}

.auth-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-logo h1 {
    font-size: 1.75rem;
    color: var(--dark);
    font-weight: 700;
}

.auth-logo p {
    color: var(--gray);
    margin-top: 0.5rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--dark);
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: var(--transition);
    background: var(--white);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-control.is-invalid {
    border-color: var(--danger);
}

.form-control.is-invalid:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.form-text {
    font-size: 0.875rem;
    color: var(--gray);
    margin-top: 0.25rem;
}

.form-error {
    font-size: 0.875rem;
    color: var(--danger);
    margin-top: 0.25rem;
}

.form-select {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--white);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.75rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
}

.form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

textarea.form-control {
    min-height: 120px;
    resize: vertical;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-check-input {
    width: 1.125rem;
    height: 1.125rem;
    cursor: pointer;
}

.form-check-label {
    font-size: 0.9375rem;
    color: var(--dark);
    cursor: pointer;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.form-col {
    min-width: 0;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    color: var(--white);
}

.btn-secondary {
    background: var(--secondary);
    color: var(--white);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--secondary-dark);
    color: var(--white);
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
}

.btn-danger:hover:not(:disabled) {
    background: var(--danger-dark);
    color: var(--white);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--dark);
}

.btn-outline:hover:not(:disabled) {
    background: var(--light);
    color: var(--dark);
}

.btn-outline-primary {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
}

.btn-outline-primary:hover:not(:disabled) {
    background: var(--primary);
    color: var(--white);
}

.btn-ghost {
    background: transparent;
    color: var(--gray);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--light);
    color: var(--dark);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.125rem;
}

.btn-block {
    width: 100%;
}

.btn-icon {
    padding: 0.5rem;
    border-radius: var(--radius);
}

/* Alerts */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.alert-danger {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

.alert-info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* Chat Layout */
.chat-wrapper {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.chat-sidebar {
    width: 280px;
    background: var(--dark);
    color: var(--white);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.chat-sidebar-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--dark-light);
}

.chat-sidebar-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.chat-sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.chat-sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--dark-light);
}

.new-chat-btn {
    width: 100%;
    padding: 0.75rem;
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: var(--radius);
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.new-chat-btn:hover {
    background: var(--primary-dark);
}

.conversation-list {
    list-style: none;
}

.conversation-item {
    padding: 0.75rem;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.conversation-item:hover {
    background: var(--dark-light);
}

.conversation-item.active {
    background: var(--primary);
}

.conversation-item-title {
    font-size: 0.9375rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.conversation-item-delete {
    opacity: 0;
    padding: 0.25rem;
    background: transparent;
    border: none;
    color: var(--gray-light);
    cursor: pointer;
    transition: var(--transition);
}

.conversation-item:hover .conversation-item-delete {
    opacity: 1;
}

.conversation-item-delete:hover {
    color: var(--danger);
}

/* Chat Main */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--white);
    overflow: hidden;
    min-width: 0;
}

.page-main {
    min-height: 100vh;
}

.page-header {
    position: sticky;
    top: 0;
    z-index: 5;
}

.page-content {
    flex: 1;
    padding: 1.25rem 1.5rem;
    overflow-y: auto;
}

.user-nav {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.user-nav-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.7rem 0.85rem;
    border-radius: var(--radius);
    color: #cbd5e1;
    border: 1px solid transparent;
}

.user-nav-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.user-nav-link.active {
    color: #fff;
    background: rgba(99, 102, 241, 0.32);
    border-color: rgba(129, 140, 248, 0.4);
}

.chat-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--white);
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.chat-header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.model-select {
    padding: 0.5rem 2rem 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9375rem;
    background: var(--white);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.25em 1.25em;
}

.balance-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--light);
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
}

.balance-amount {
    color: var(--secondary);
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.message {
    max-width: 85%;
    padding: 1rem 1.25rem;
    border-radius: var(--radius-lg);
    position: relative;
}

.message-user {
    background: var(--primary);
    color: var(--white);
    margin-left: auto;
    border-bottom-right-radius: 0.25rem;
}

.message-assistant {
    background: var(--light);
    color: var(--dark);
    margin-right: auto;
    border-bottom-left-radius: 0.25rem;
}

.message-content {
    line-height: 1.7;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    text-rendering: optimizeLegibility;
    font-variant-ligatures: common-ligatures;
    font-family: 'Inter', 'Segoe UI', 'Noto Color Emoji', 'Apple Color Emoji', 'Segoe UI Emoji', sans-serif;
}

.message-content p {
    margin: 0 0 0.85rem;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content h2,
.message-content h3 {
    margin: 0.85rem 0 0.55rem;
    line-height: 1.35;
    letter-spacing: -0.01em;
}

.message-content h2 {
    font-size: 1.1rem;
}

.message-content h3 {
    font-size: 1rem;
}

.message-content a {
    color: #2563eb;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.message-content blockquote {
    margin: 0.75rem 0;
    padding: 0.5rem 0.75rem;
    border-left: 3px solid #cbd5e1;
    background: #f8fafc;
    color: #334155;
}

.message-content code {
    background: transparent;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-family: 'Fira Code', monospace;
    font-size: 0.9em;
}

.message-assistant .message-content code {
    background: transparent;
}

.message-content pre {
    background: var(--dark);
    color: var(--light);
    padding: 1rem;
    border-radius: var(--radius-md);
    overflow-x: auto;
    margin: 0.75rem 0;
}

.message-content pre code {
    background: transparent;
    padding: 0;
}

.message-content .code-block {
    position: relative;
    background: #0b1220;
    border: 1px solid #1f2937;
    border-radius: var(--radius-md);
    margin: 0.75rem 0;
    overflow: hidden;
}

.message-content .code-block pre {
    margin: 0;
    background: transparent;
    color: #e5e7eb;
    padding: 1rem;
}

.message-content .code-block pre code {
    color: #93c5fd;
}

.code-copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    border: 1px solid #374151;
    background: #111827;
    color: #e5e7eb;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
}

.code-copy-btn:hover {
    background: #1f2937;
}

.message-reasoning {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px dashed #d6dbe5;
    font-size: 0.875rem;
    color: var(--gray);
}

.message-reasoning-toggle {
    margin-bottom: 0.65rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    background: #f8fafc;
    padding: 0.5rem 0.75rem;
}

.message-reasoning-toggle summary {
    cursor: pointer;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #334155;
    list-style: none;
}

.message-reasoning-toggle summary::-webkit-details-marker {
    display: none;
}

.message-reasoning-toggle summary::before {
    content: '▸';
    display: inline-block;
    margin-right: 0.4rem;
    transition: transform 0.2s ease;
}

.message-reasoning-toggle[open] summary::before {
    transform: rotate(90deg);
}

.message-meta {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--gray-light);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.message-user .message-meta {
    color: rgba(255, 255, 255, 0.7);
}

/* Chat Input */
.chat-input-wrapper {
    padding: 1rem 1.5rem 1.5rem;
    border-top: 1px solid var(--border);
    background: var(--white);
}

.chat-input-container {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    max-width: 900px;
    margin: 0 auto;
}

.chat-input {
    flex: 1;
    padding: 0.875rem 1.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    font-size: 1rem;
    resize: none;
    min-height: 52px;
    max-height: 200px;
    line-height: 1.5;
    transition: var(--transition);
}

.chat-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.chat-send-btn {
    padding: 0.875rem 1.25rem;
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: var(--radius-lg);
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-send-btn:hover:not(:disabled) {
    background: var(--primary-dark);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Empty State */
.chat-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
}

.chat-empty-icon {
    width: 80px;
    height: 80px;
    background: var(--light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.chat-empty h3 {
    font-size: 1.5rem;
    color: var(--dark);
    margin-bottom: 0.5rem;
}

.chat-empty p {
    color: var(--gray);
    max-width: 400px;
}

.admin-wrapper {
    display: flex;
    height: 100vh;
    width: 100%;
    overflow: hidden;
}

.admin-sidebar {
    width: 260px;
    height: 100%;
    background: var(--dark);
    color: var(--white);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
    z-index: 100;
    border-right: 1px solid rgba(255,255,255,0.1);
}

.admin-sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--dark-light);
    flex-shrink: 0;
}

.admin-sidebar-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.admin-sidebar-nav {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
}

.admin-nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    color: var(--gray-light);
    text-decoration: none;
    transition: var(--transition);
}

.admin-nav-item:hover {
    background: var(--dark-light);
    color: var(--white);
}

.admin-nav-item.active {
    background: var(--primary);
    color: var(--white);
}

.admin-nav-item svg {
    width: 20px;
    height: 20px;
}

.admin-main {
    flex: 1;
    height: 100%;
    background: var(--light);
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
    z-index: 1;
}

.admin-header {
    padding: 1rem 1.5rem;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.admin-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.admin-content {
    flex: 1;
    padding: 1.5rem;
    padding-left: 1.5rem;
    background: var(--light);
    overflow-y: auto;
    margin-left: 0;
}

/* Cards */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
}

.card-body {
    padding: 1.5rem;
}

.card-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    background: var(--light);
    border-radius: 0 0 var(--radius) var(--radius);
}

/* Tables */
.table-responsive {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 0.875rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table th {
    background: var(--light);
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    color: var(--gray);
}

.table tbody tr:hover {
    background: var(--light);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 9999px;
}

.badge-success {
    background: #d1fae5;
    color: #065f46;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-info {
    background: #dbeafe;
    color: #1e40af;
}

.badge-primary {
    background: #e0e7ff;
    color: #3730a3;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    margin-left: 0;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.stat-card-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}

.stat-card-icon.primary {
    background: #e0e7ff;
    color: var(--primary);
}

.stat-card-icon.success {
    background: #d1fae5;
    color: var(--secondary);
}

.stat-card-icon.warning {
    background: #fef3c7;
    color: var(--warning);
}

.stat-card-icon.danger {
    background: #fee2e2;
    color: var(--danger);
}

.stat-card-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--dark);
    line-height: 1;
    margin-bottom: 0.25rem;
}

.stat-card-label {
    font-size: 0.875rem;
    color: var(--gray);
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--white);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 500px;
    margin: 1rem;
    max-height: 90vh;
    overflow: hidden;
    transform: scale(0.9);
    transition: var(--transition);
}

.modal.modal-lg {
    max-width: 700px;
}

.modal.modal-xl {
    max-width: 900px;
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-close {
    background: transparent;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--gray);
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--dark);
}

.modal-body {
    padding: 1.5rem;
    max-height: calc(90vh - 140px);
    overflow-y: auto;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    margin-top: 1.5rem;
}

.pagination-item {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    color: var(--dark);
    text-decoration: none;
    transition: var(--transition);
}

.pagination-item:hover {
    background: var(--light);
}

.pagination-item.active {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--white);
}

.pagination-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Utilities */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--gray); }
.text-success { color: var(--secondary); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-primary { color: var(--primary); }

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }

.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 1rem; }

.hidden { display: none !important; }

/* Responsive */
@media (max-width: 768px) {
    .auth-wrapper {
        padding: 1rem;
        align-items: flex-start;
    }

    .auth-card {
        max-width: 100%;
        padding: 1.5rem 1rem;
        border-radius: 0.75rem;
    }

    .form-row {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .chat-sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        height: 100%;
        z-index: 100;
        transition: var(--transition);
    }

    .chat-sidebar.open {
        left: 0;
    }

    .admin-sidebar {
        position: fixed;
        left: -260px;
        top: 0;
        height: 100%;
        z-index: 1000;
        transition: var(--transition);
        box-shadow: var(--shadow-lg);
    }

    .admin-sidebar.open {
        left: 0;
    }

    .admin-main {
        width: 100%;
        flex: 1;
    }

    .chat-header {
        padding: 0.85rem 1rem;
        gap: 0.5rem;
    }

    .chat-header h1 {
        font-size: 1.125rem;
    }

    .chat-header-right {
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    .page-content {
        padding: 1rem;
    }

    .chat-messages {
        padding: 1rem;
        gap: 1rem;
    }

    .message {
        max-width: 100%;
    }

    .chat-input-wrapper {
        padding: 0.85rem 1rem 1rem;
    }

    .chat-input-container {
        max-width: 100%;
    }

    .table th,
    .table td {
        white-space: nowrap;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    body {
        font-size: 15px;
    }

    .btn {
        padding: 0.65rem 1rem;
    }

    .chat-send-btn {
        padding: 0.8rem 1rem;
    }

    .balance-badge {
        padding: 0.45rem 0.7rem;
        font-size: 0.8rem;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--light);
}

::-webkit-scrollbar-thumb {
    background: var(--gray-light);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray);
}

/* Loading */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--gray);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-indicator .typing-label {
    margin-left: 0.5rem;
    font-size: 0.8125rem;
    color: var(--gray-light);
}

.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(-4px); }
}

/* ============================================================
   Final Theme Overrides (placed last to win cascade)
   ============================================================ */

/* Neo Terminal: dense, squared, grid-console feel */
body[data-theme='neo_terminal'] .chat-header,
body[data-theme='neo_terminal'] .admin-header,
body[data-theme='neo_terminal'] .chat-input-wrapper,
body[data-theme='neo_terminal'] .card,
body[data-theme='neo_terminal'] .modal,
body[data-theme='neo_terminal'] .auth-card {
    border-radius: 0.35rem !important;
    border: 1px solid #a7c2b0 !important;
}

body[data-theme='neo_terminal'] .chat-messages,
body[data-theme='neo_terminal'] .admin-content,
body[data-theme='neo_terminal'] .page-content {
    letter-spacing: 0.01em;
    line-height: 1.5;
}

body[data-theme='neo_terminal'] .message-user,
body[data-theme='neo_terminal'] .message-assistant {
    border-radius: 0.25rem !important;
}

body[data-theme='neo_terminal'] .chat-wrapper,
body[data-theme='neo_terminal'] .admin-wrapper {
    background-size: 22px 22px !important;
}

/* Hacker: sharp paneling + CRT-ish look */
body[data-theme='hacker'] .chat-main,
body[data-theme='hacker'] .admin-main {
    position: relative;
}

body[data-theme='hacker'] .chat-main::before,
body[data-theme='hacker'] .admin-main::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: repeating-linear-gradient(
        0deg,
        rgba(84, 132, 139, 0.06) 0,
        rgba(84, 132, 139, 0.06) 1px,
        transparent 1px,
        transparent 4px
    );
    opacity: 0.45;
}

body[data-theme='hacker'] .chat-header,
body[data-theme='hacker'] .admin-header,
body[data-theme='hacker'] .chat-input-wrapper,
body[data-theme='hacker'] .card,
body[data-theme='hacker'] .modal,
body[data-theme='hacker'] .auth-card,
body[data-theme='hacker'] .btn,
body[data-theme='hacker'] .conversation-item,
body[data-theme='hacker'] .admin-nav-item,
body[data-theme='hacker'] .user-nav-link {
    border-radius: 0.2rem !important;
}

body[data-theme='hacker'] .chat-sidebar,
body[data-theme='hacker'] .admin-sidebar {
    width: 300px;
}

/* Kali Linux: premium navy dashboard look */
body[data-theme='kali_linux'] .chat-header,
body[data-theme='kali_linux'] .admin-header {
    backdrop-filter: blur(8px);
    border-bottom: 1px solid #cdd8e5 !important;
}

body[data-theme='kali_linux'] .card,
body[data-theme='kali_linux'] .modal,
body[data-theme='kali_linux'] .auth-card,
body[data-theme='kali_linux'] .stat-card {
    border-radius: 1.1rem !important;
    border: 1px solid #c4d0dd !important;
    box-shadow: 0 16px 30px -24px rgba(15, 35, 61, 0.45);
}

body[data-theme='kali_linux'] .chat-sidebar,
body[data-theme='kali_linux'] .admin-sidebar {
    width: 290px;
}

body[data-theme='kali_linux'] .btn {
    border-radius: 0.65rem;
}

/* Slate Calm: airy spacing + soft rounded surfaces */
body[data-theme='slate_calm'] .chat-header,
body[data-theme='slate_calm'] .admin-header,
body[data-theme='slate_calm'] .chat-input-wrapper,
body[data-theme='slate_calm'] .card,
body[data-theme='slate_calm'] .modal,
body[data-theme='slate_calm'] .auth-card {
    border-radius: 1.15rem !important;
}

body[data-theme='slate_calm'] .chat-messages,
body[data-theme='slate_calm'] .admin-content,
body[data-theme='slate_calm'] .page-content {
    padding: 1.75rem !important;
}

body[data-theme='slate_calm'] .chat-sidebar,
body[data-theme='slate_calm'] .admin-sidebar {
    width: 270px;
}

body[data-theme='slate_calm'] .message-user,
body[data-theme='slate_calm'] .message-assistant {
    border-radius: 1rem !important;
}

/* Public marketing pages */
.marketing-page {
    min-height: 100vh;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.88) 0%, rgba(243, 244, 246, 0.92) 100%);
}

.marketing-nav {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(8px);
}

.marketing-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--dark);
    font-weight: 700;
}

.marketing-links {
    display: flex;
    gap: 1rem;
}

.marketing-links a {
    color: var(--gray);
    font-weight: 500;
}

.marketing-actions {
    display: flex;
    gap: 0.75rem;
}

.hero-section {
    padding: 3rem 1rem 1rem;
}

.hero-grid {
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    gap: 1.5rem;
    align-items: center;
}

.hero-title {
    font-size: clamp(1.8rem, 4vw, 3rem);
    line-height: 1.15;
    margin: 0.85rem 0;
}

.hero-text {
    color: var(--gray);
    font-size: 1.05rem;
    max-width: 62ch;
}

.hero-actions {
    margin-top: 1.25rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.hero-art img {
    width: 100%;
    height: auto;
    border-radius: 1rem;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    background: var(--white);
}

.marketing-badge {
    display: inline-block;
    padding: 0.35rem 0.7rem;
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: 999px;
    background: rgba(99, 102, 241, 0.08);
    color: var(--primary-dark);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.feature-strip {
    padding: 1.25rem 1rem 3rem;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
}

.feature-strip.two-col {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.feature-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 0.9rem;
    padding: 1.1rem;
    box-shadow: var(--shadow);
}

.feature-card h2 {
    margin-bottom: 0.5rem;
}

.feature-card p {
    color: var(--gray);
}

.subpage-hero {
    padding: 2.25rem 1rem 0.5rem;
}

.subpage-hero h1 {
    margin: 0.75rem 0;
    font-size: clamp(1.6rem, 3.6vw, 2.4rem);
}

.contact-wrap {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 1rem;
    padding: 0.5rem 1rem 2.5rem;
}

.marketing-footer {
    margin: 1rem;
    padding: 1rem;
    border-top: 1px solid var(--border);
    color: var(--gray);
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
}

@media (max-width: 992px) {
    .marketing-links {
        display: none;
    }

    .hero-grid,
    .feature-strip,
    .feature-strip.two-col,
    .contact-wrap {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .marketing-nav {
        padding: 0.75rem;
    }

    .marketing-actions .btn {
        padding: 0.55rem 0.8rem;
        font-size: 0.9rem;
    }

    .hero-section {
        padding-top: 1.6rem;
    }
}
