/**
 * AI Chat Aggregator Styles
 * Dark theme with orange/cyan accents
 */

/* ===== CSS Variables ===== */
:root {
    /* Colors */
    --bg-primary: #0a0a0b;
    --bg-secondary: #111113;
    --bg-tertiary: #18181b;
    --bg-elevated: #1f1f23;
    --bg-hover: #27272a;

    --accent-orange: #ff6b35;
    --accent-orange-dark: #e55a28;
    --accent-orange-glow: rgba(255, 107, 53, 0.3);
    --accent-cyan: #00d4ff;
    --accent-cyan-dark: #00b8e0;
    --accent-cyan-glow: rgba(0, 212, 255, 0.3);

    --text-primary: #fafafa;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;

    --border-color: #27272a;
    --border-light: #3f3f46;

    --success: #22c55e;
    --error: #ef4444;
    --warning: #f59e0b;

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, var(--accent-orange) 0%, var(--accent-cyan) 100%);
    --gradient-dark: linear-gradient(135deg, rgba(255, 107, 53, 0.1) 0%, rgba(0, 212, 255, 0.1) 100%);

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);
    --shadow-glow-orange: 0 0 20px var(--accent-orange-glow);
    --shadow-glow-cyan: 0 0 20px var(--accent-cyan-glow);

    /* Sizing */
    --sidebar-width: 280px;
    --header-height: 60px;
    --input-height: 52px;
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --border-radius-lg: 16px;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.4s ease;
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--accent-orange) 0%, var(--accent-cyan) 100%);
    border-radius: 4px;
    transition: background var(--transition-normal);
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, var(--accent-orange-dark) 0%, var(--accent-cyan-dark) 100%);
}

::-webkit-scrollbar-corner {
    background: var(--bg-secondary);
}

/* Firefox scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--accent-orange) var(--bg-secondary);
}

/* ===== Typography ===== */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 600;
    line-height: 1.3;
}

h1 {
    font-size: 2rem;
}

h2 {
    font-size: 1.5rem;
}

h3 {
    font-size: 1.25rem;
}

a {
    color: var(--accent-cyan);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--accent-orange);
}

code {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    background: var(--bg-tertiary);
    padding: 0.2em 0.4em;
    border-radius: 4px;
    font-size: 0.9em;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, transparent 50%);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.btn:hover::before {
    opacity: 1;
}

.btn-primary {
    background: var(--accent-orange);
    color: white;
    /* border: 2px solid var(--accent-cyan); */
    box-shadow: var(--shadow-md), 0 0 10px var(--accent-cyan-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    background: var(--accent-orange-dark);
    box-shadow: var(--shadow-lg), var(--shadow-glow-orange), 0 0 15px var(--accent-cyan-glow);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--accent-cyan);
}

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

.btn-danger:hover {
    background: #dc2626;
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.btn svg {
    width: 18px;
    height: 18px;
}

/* ===== Form Elements ===== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="number"],
textarea,
select {
    width: 100%;
    padding: 14px 16px;
    font-family: inherit;
    font-size: 1rem;
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    transition: all var(--transition-fast);
    outline: none;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 3px var(--accent-cyan-glow);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
}

input.disabled,
input:disabled {
    background: var(--bg-secondary);
    color: var(--text-muted);
    cursor: not-allowed;
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 18px;
    padding-right: 44px;
}

textarea {
    resize: vertical;
    min-height: 100px;
}

.input-hint {
    display: block;
    margin-top: 6px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.input-hint.warning {
    color: var(--warning);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.form-divider {
    display: flex;
    align-items: center;
    margin: 24px 0;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.form-divider::before,
.form-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

.form-divider span {
    padding: 0 16px;
}

/* Password wrapper */
.password-wrapper {
    position: relative;
}

.password-wrapper input {
    padding-right: 48px;
}

.toggle-password {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    transition: color var(--transition-fast);
}

.toggle-password:hover,
.toggle-password.active {
    color: var(--accent-cyan);
}

.toggle-password svg {
    width: 20px;
    height: 20px;
}

/* Password strength */
.password-strength {
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    margin-top: 8px;
    overflow: hidden;
}

.strength-bar {
    height: 100%;
    width: 0;
    border-radius: 2px;
    transition: all var(--transition-normal);
}

.strength-bar.strength-weak {
    background: var(--error);
    width: 25%;
}

.strength-bar.strength-medium {
    background: var(--warning);
    width: 50%;
}

.strength-bar.strength-strong {
    background: var(--accent-cyan);
    width: 75%;
}

.strength-bar.strength-very-strong {
    background: var(--success);
    width: 100%;
}

.strength-text {
    font-size: 0.75rem;
    margin-top: 4px;
    display: block;
}

.strength-text.weak {
    color: var(--error);
}

.strength-text.medium {
    color: var(--warning);
}

.strength-text.strong {
    color: var(--accent-cyan);
}

.strength-text.very-strong {
    color: var(--success);
}

/* Secret key */
.secret-key-wrapper {
    display: flex;
    gap: 12px;
}

.secret-key-wrapper input {
    flex: 1;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
}

.btn-generate {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--accent-cyan);
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition-fast);
}

.btn-generate:hover {
    background: var(--bg-hover);
    border-color: var(--accent-cyan);
}

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

/* Checkbox */
.checkbox-group {
    margin-top: 24px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.checkbox-label input[type="checkbox"] {
    display: none;
}

.checkmark {
    width: 22px;
    height: 22px;
    min-width: 22px;
    min-height: 22px;
    flex-shrink: 0;
    border: 2px solid var(--border-light);
    border-radius: 6px;
    position: relative;
    transition: all var(--transition-fast);
    display: inline-block;
    box-sizing: border-box;
}

.checkbox-label input:checked+.checkmark {
    /* background: var(--gradient-primary); */
    border-color: transparent;
}

.checkmark::after {
    content: '';
    position: absolute;
    left: 6px;
    top: 2px;
    width: 6px;
    height: 12px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.checkbox-label input:checked+.checkmark::after {
    opacity: 1;
}

.terms-link {
    color: var(--accent-cyan);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.terms-link:hover {
    color: var(--accent-orange);
    text-decoration: underline;
}

/* ===== Alerts ===== */
.alert {
    padding: 14px 18px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    font-size: 0.95rem;
    animation: slideIn 0.3s ease;
}

.alert-success {
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid var(--success);
    color: var(--success);
}

.alert-error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid var(--error);
    color: var(--error);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid var(--warning);
    color: var(--warning);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 14px 24px;
    background: var(--bg-elevated);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    z-index: 10000;
    transform: translateY(100px);
    opacity: 0;
    transition: all var(--transition-normal);
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast-success {
    border-left: 4px solid var(--success);
}

.toast-error {
    border-left: 4px solid var(--error);
}

.toast-warning {
    border-left: 4px solid var(--warning);
}

.toast-info {
    border-left: 4px solid var(--accent-cyan);
}

/* ===== Modal ===== */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

.modal.show {
    opacity: 1;
    visibility: visible;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 28px;
    max-width: 420px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9);
    transition: transform var(--transition-normal);
}

.modal.show .modal-content {
    transform: scale(1);
}

.modal-content h3 {
    margin-bottom: 12px;
    position: sticky;
    top: -28px;
    background: var(--bg-secondary);
    padding: 28px 0 12px 0;
    margin: -28px 0 12px 0;
    z-index: 1;
}

.modal-content p {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.modal-content input {
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    position: sticky;
    bottom: -28px;
    background: var(--bg-secondary);
    padding: 20px 0 28px 0;
    margin: 0 0 -28px 0;
}

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

/* ===== Authentication Pages ===== */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    background: var(--bg-primary);
    padding: 24px;
    position: relative;
    overflow-x: hidden;
    overflow-y: auto;
}

@media (min-height: 800px) {
    .auth-page {
        align-items: center;
    }
}

.auth-page::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 30% 30%, var(--accent-orange-glow) 0%, transparent 50%),
        radial-gradient(circle at 70% 70%, var(--accent-cyan-glow) 0%, transparent 50%);
    opacity: 0.5;
    animation: backgroundPulse 15s ease infinite;
}

@keyframes backgroundPulse {

    0%,
    100% {
        transform: translate(0, 0) rotate(0deg);
    }

    50% {
        transform: translate(2%, 2%) rotate(5deg);
    }
}

.auth-container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 440px;
    margin: auto;
    /* padding: 20px 0; */
}

.auth-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 40px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    animation: cardAppear 0.5s ease;
}

@keyframes cardAppear {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-logo {
    margin-bottom: 20px;
}

.auth-logo svg {
    width: 64px;
    height: 64px;
    animation: logoGlow 3s ease infinite;
}

@keyframes logoGlow {

    0%,
    100% {
        filter: drop-shadow(0 0 10px var(--accent-orange-glow));
    }

    50% {
        filter: drop-shadow(0 0 20px var(--accent-cyan-glow));
    }
}

.auth-header h1 {
    font-size: 1.75rem;
    margin-bottom: 8px;
}

.auth-header p {
    color: var(--text-secondary);
}

.auth-form {
    margin-bottom: 24px;
}

.auth-footer {
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.auth-footer p {
    color: var(--text-secondary);
}

.auth-decoration {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.decoration-circle {
    position: absolute;
    border-radius: 50%;
    opacity: 0.1;
}

.circle-1 {
    width: 300px;
    height: 300px;
    background: var(--accent-orange);
    top: -100px;
    right: -100px;
    animation: float 8s ease-in-out infinite;
}

.circle-2 {
    width: 200px;
    height: 200px;
    background: var(--accent-cyan);
    bottom: -50px;
    left: -50px;
    animation: float 10s ease-in-out infinite reverse;
}

.circle-3 {
    width: 150px;
    height: 150px;
    background: var(--gradient-primary);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation: pulse 5s ease-in-out infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translate(0, 0);
    }

    50% {
        transform: translate(20px, 20px);
    }
}

@keyframes pulse {

    0%,
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.1;
    }

    50% {
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 0.05;
    }
}

/* Highlight animation for secret key */
input.highlight {
    animation: highlightPulse 0.5s ease;
}

@keyframes highlightPulse {

    0%,
    100% {
        box-shadow: 0 0 0 3px var(--accent-cyan-glow);
    }

    50% {
        box-shadow: 0 0 0 6px var(--accent-cyan-glow);
    }
}

/* ===== Chat Page ===== */
.chat-page {
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: all var(--transition-normal);
    z-index: 100;
    flex-shrink: 0;
    overflow: hidden;
}

.sidebar.collapsed {
    width: 0;
    min-width: 0;
    border-right: none;
    padding: 0;
}

.sidebar.collapsed * {
    opacity: 0;
    visibility: hidden;
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.btn-new-chat {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 14px 20px;
    background: var(--accent-orange);
    border: 2px solid #0a0a0b;
    border-radius: var(--border-radius);
    color: white;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-md), 0 0 10px rgb(10 10 11);
}

.btn-new-chat:hover {
    transform: translateY(-2px);
    background: var(--accent-orange-dark);
    border-color: #707071;
    box-shadow: var(--shadow-lg), var(--shadow-glow-orange), 0 0 15px var(--accent-cyan-glow);
}

.btn-new-chat svg {
    width: 18px;
    height: 18px;
}

/* Chat list */
.chat-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px 8px;
}

.chat-list-loading {
    display: flex;
    justify-content: center;
    padding: 40px;
}

.chat-list-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

/* Chat Sections (Pinned / History) */
.chat-section {
    margin-bottom: 8px;
}

.chat-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    cursor: pointer;
    user-select: none;
    transition: all var(--transition-fast);
    border-radius: var(--border-radius-sm);
}

.chat-section-header:hover {
    background: var(--bg-hover);
}

.chat-section-title {
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    opacity: 0.6;
}

.chat-section-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    opacity: 0.4;
    transition: all var(--transition-fast);
}

.chat-section-toggle svg {
    width: 12px;
    height: 12px;
    transition: transform var(--transition-fast);
}

.chat-section-header:hover .chat-section-toggle {
    opacity: 0.7;
}

/* Collapsed state */
.chat-section.collapsed .chat-section-toggle svg {
    transform: rotate(-90deg);
}

.chat-section.collapsed .chat-section-items {
    display: none;
}

.chat-section-items {
    transition: all var(--transition-fast);
}

.chat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    margin-bottom: 4px;
}

.chat-item:hover {
    background: var(--bg-hover);
}

.chat-item.active {
    background: var(--bg-tertiary);
    border-left: 3px solid var(--accent-cyan);
}

.chat-item.pinned {
    background: rgba(255, 107, 53, 0.1);
}

.chat-item.streaming {
    position: relative;
}

.chat-item.streaming::after {
    content: '';
    position: absolute;
    right: 40px;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 8px;
    background: var(--accent-cyan);
    border-radius: 50%;
    animation: pulse-streaming 1.5s ease-in-out infinite;
}

@keyframes pulse-streaming {

    0%,
    100% {
        opacity: 0.4;
        transform: translateY(-50%) scale(0.8);
    }

    50% {
        opacity: 1;
        transform: translateY(-50%) scale(1.2);
    }
}

.pin-icon {
    font-size: 0.8rem;
}

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

.chat-menu-btn {
    opacity: 0;
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--text-muted);
    border-radius: 4px;
    transition: all var(--transition-fast);
}

.chat-item:hover .chat-menu-btn {
    opacity: 1;
}

.chat-menu-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.chat-menu-btn svg {
    width: 16px;
    height: 16px;
}

/* Sidebar footer */
.sidebar-footer {
    padding: 16px;
    position: relative;
}

.sidebar-divider {
    height: 1px;
    background: var(--border-color);
    margin-bottom: 16px;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.user-profile:hover {
    background: var(--bg-hover);
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

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

.avatar-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gradient-primary);
    color: white;
    font-weight: 600;
    font-size: 1.1rem;
}

.avatar-placeholder.large {
    width: 100px;
    height: 100px;
    font-size: 2.5rem;
    border-radius: 50%;
}

.user-info {
    flex: 1;
    min-width: 0;
}

.user-name {
    display: block;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-menu-btn {
    background: none;
    border: none;
    padding: 6px;
    cursor: pointer;
    color: var(--text-muted);
    border-radius: 4px;
    transition: all var(--transition-fast);
}

.user-menu-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.user-menu-btn svg {
    width: 18px;
    height: 18px;
}

/* User menu popup */
.user-menu-popup {
    position: absolute;
    bottom: 70px;
    left: 8px;
    right: 8px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 8px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-lg);
    z-index: 200;
}

.user-menu-popup.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: background var(--transition-fast);
}

.menu-item:hover {
    background: var(--bg-hover);
}

.menu-item svg {
    width: 18px;
    height: 18px;
    color: var(--text-secondary);
}

.menu-item-danger {
    color: var(--error);
}

.menu-item-danger svg {
    color: var(--error);
}

/* Context menu */
.context-menu {
    position: fixed;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 8px;
    min-width: 180px;
    opacity: 0;
    visibility: hidden;
    transform: scale(0.95);
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
}

.context-menu.show {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
}

.context-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 14px;
    background: none;
    border: none;
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background var(--transition-fast);
    text-align: left;
}

.context-item:hover {
    background: var(--bg-hover);
}

.context-item svg {
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
}

.context-item-danger {
    color: var(--error);
}

.context-item-danger svg {
    color: var(--error);
}

/* Main chat area */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    transition: all var(--transition-normal);
    min-width: 0;
    position: relative;
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 16px;
    height: var(--header-height);
    padding: 0 20px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.btn-toggle-sidebar {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: var(--text-secondary);
    border-radius: var(--border-radius-sm);
    transition: all var(--transition-fast);
}

.btn-toggle-sidebar:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-toggle-sidebar svg {
    width: 22px;
    height: 22px;
}

.chat-title {
    font-size: 1.1rem;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Messages container */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.messages-wrapper {
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
}

/* Empty state */
.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--text-muted);
    padding: 40px;
}

.empty-state-icon {
    margin-bottom: 24px;
}

.empty-state-icon svg {
    width: 80px;
    height: 80px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: 8px;
}

/* Messages */
.message {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    animation: messageAppear 0.3s ease;
}

@keyframes messageAppear {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

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

.message-content {
    flex: 1;
    min-width: 0;
}

.message-header {
    margin-bottom: 6px;
}

.message-author {
    font-weight: 600;
    font-size: 0.95rem;
}

.message-user .message-author {
    color: var(--accent-orange);
}

.message-assistant .message-author {
    color: var(--accent-cyan);
}

.message-text {
    font-size: 0.95rem;
    line-height: 1.7;
    word-wrap: break-word;
}

.message-text p {
    margin-bottom: 12px;
}

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

/* Code blocks */
.code-block {
    margin: 16px 0;
    border-radius: var(--border-radius);
    overflow: hidden;
    background: #1e1e2e;
    border: 1px solid var(--border-color);
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: #181825;
    border-bottom: 1px solid var(--border-color);
}

.code-lang {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--accent-cyan);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.code-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.copy-btn,
.download-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.download-btn {
    padding: 4px 8px;
}

.copy-btn:hover,
.download-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--accent-cyan);
}

.copy-btn.copied,
.download-btn.downloaded {
    background: rgba(34, 197, 94, 0.2);
    border-color: var(--success);
    color: var(--success);
}

.copy-btn svg,
.download-btn svg {
    width: 14px;
    height: 14px;
}

.code-block pre {
    margin: 0;
    padding: 16px;
    overflow-x: auto;
    background: transparent;
}

.code-block code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    background: transparent;
    padding: 0;
}

.code-body {
    display: flex;
    position: relative;
}

.line-numbers {
    display: flex;
    flex-direction: column;
    padding: 42px 12px 16px 16px;
    border-right: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.2);
    user-select: none;
    text-align: right;
    min-width: 2.5em;
}

.line-numbers span {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--text-muted);
    opacity: 0.7;
}

.code-block pre {
    margin: 0;
    padding: 16px;
    overflow-x: auto;
    background: transparent;
    flex: 1;
}

/* Inline code */
.message-text code:not([class*="language-"]) {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--accent-orange);
}

.message-text pre {
    background: var(--bg-tertiary);
    border-radius: var(--border-radius-sm);
    padding: 16px;
    overflow-x: auto;
    margin: 12px 0;
}

.message-text pre code {
    background: none;
    padding: 0;
    color: inherit;
}

.message-text ul,
.message-text ol {
    margin: 12px 0;
    padding-left: 24px;
}

.message-text li {
    margin-bottom: 4px;
}

.message-text blockquote {
    border-left: 3px solid var(--accent-cyan);
    padding-left: 16px;
    margin: 12px 0;
    color: var(--text-secondary);
}

.error-text {
    color: var(--error);
    padding: 8px 12px;
    background: rgba(239, 68, 68, 0.1);
    border-radius: var(--border-radius-sm);
    border-left: 3px solid var(--error);
}

/* Message actions (copy button) */
.message-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.message:hover .message-actions {
    opacity: 1;
}

.message-copy-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.message-copy-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
}

.message-copy-btn.copied {
    background: rgba(34, 197, 94, 0.15);
    border-color: var(--success);
    color: var(--success);
}

.message-copy-btn svg {
    width: 16px;
    height: 16px;
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--accent-cyan);
    border-radius: 50%;
    animation: typingBounce 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 typingBounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* Skeleton Loader */
.skeleton-loader {
    padding: 20px;
    max-width: 800px;
    margin: 0 auto;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.skeleton-message {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    animation: skeletonFadeIn 0.3s ease;
}

.skeleton-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(90deg,
            rgba(255, 255, 255, 0.03) 0%,
            rgba(255, 255, 255, 0.08) 50%,
            rgba(255, 255, 255, 0.03) 100%);
    background-size: 200% 100%;
    animation: skeletonShimmer 1.5s ease-in-out infinite;
    flex-shrink: 0;
}

.skeleton-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.skeleton-line {
    height: 14px;
    border-radius: 4px;
    background: linear-gradient(90deg,
            rgba(255, 255, 255, 0.03) 0%,
            rgba(255, 255, 255, 0.08) 50%,
            rgba(255, 255, 255, 0.03) 100%);
    background-size: 200% 100%;
    animation: skeletonShimmer 1.5s ease-in-out infinite;
}

.skeleton-line:nth-child(1) {
    width: 30%;
    animation-delay: 0s;
}

.skeleton-line:nth-child(2) {
    width: 95%;
    animation-delay: 0.1s;
}

.skeleton-line:nth-child(3) {
    width: 85%;
    animation-delay: 0.2s;
}

.skeleton-line:nth-child(4) {
    width: 70%;
    animation-delay: 0.3s;
}

@keyframes skeletonShimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

@keyframes skeletonFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* Input container */
.input-container {
    padding: 20px;
    background: linear-gradient(to top, var(--bg-primary) 0%, transparent 100%);
    transition: all var(--transition-normal);
}

.input-container.centered {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: calc(100% - 40px);
    max-width: 700px;
    padding: 20px;
    background: transparent;
}

.input-wrapper {
    max-width: 800px;
    margin: 0 auto;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    position: relative;
}

.input-wrapper:focus-within {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 3px var(--accent-cyan-glow);
}

/* Model selector */
.model-selector {
    position: relative;
    border-bottom: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
    background: var(--bg-secondary);
}

.model-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 16px;
    background: none;
    border: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.model-btn:hover {
    background: var(--bg-hover);
}

.model-btn .model-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: none;
}

.model-btn .model-avatar[src] {
    display: block;
}

.model-btn .model-name {
    flex: 1;
    text-align: left;
}

.model-btn svg {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    transition: transform var(--transition-fast);
}

.model-dropdown.show+.model-btn svg,
.model-btn:focus svg {
    transform: rotate(180deg);
}

.model-dropdown {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    max-height: 300px;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    pointer-events: none;
}

.model-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

.model-option {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 16px;
    background: none;
    border: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background var(--transition-fast);
    text-align: left;
}

.model-option:hover {
    background: var(--bg-hover);
}

.model-option.active {
    background: rgba(0, 212, 255, 0.1);
}

.model-option .model-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

/* Message input */
.message-input-wrapper {
    display: flex;
    align-items: flex-start;
    padding: 12px;
    gap: 12px;
    border-radius: 0 0 var(--border-radius-lg) var(--border-radius-lg);
    background: var(--bg-secondary);
}

.message-input-wrapper textarea {
    flex: 1;
    padding: 10px 0;
    background: none;
    border: none;
    font-size: 0.95rem;
    resize: none;
    max-height: 200px;
    line-height: 1.5;
}

.message-input-wrapper textarea:focus {
    outline: none;
    box-shadow: none;
}

.btn-send {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gradient-primary);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all var(--transition-normal);
    flex-shrink: 0;
}

.btn-send:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: var(--shadow-glow-orange);
}

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

.btn-send svg {
    width: 20px;
    height: 20px;
    color: white;
}

/* Attach button */
.btn-attach {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
    color: var(--text-muted);
}

.btn-attach:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-attach svg {
    width: 20px;
    height: 20px;
}

/* Input left buttons (attach + settings) */
.input-left-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

/* Input Settings Button & Panel */
.input-settings-wrapper {
    position: relative;
}

.btn-input-settings {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
    color: var(--text-muted);
}

.btn-input-settings:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-input-settings.active {
    background: var(--bg-hover);
    color: var(--accent-cyan);
}

.btn-input-settings svg {
    width: 18px;
    height: 18px;
    transition: transform 0.3s ease;
}

.btn-input-settings.active svg {
    transform: rotate(45deg);
}

/* Settings Panel */
.input-settings-panel {
    position: absolute;
    bottom: 100%;
    left: 0;
    transform: scale(0.95);
    transform-origin: bottom left;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 12px;
    min-width: 180px;
    margin-bottom: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.05);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: all 0.2s ease;
    z-index: 100;
}

.input-settings-panel.visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: scale(1);
}

/* Arrow/triangle pointing down */
.input-settings-panel::before {
    content: '';
    position: absolute;
    bottom: -7px;
    left: 14px;
    transform: rotate(45deg);
    width: 12px;
    height: 12px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.input-settings-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.input-settings-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--text-primary);
    white-space: nowrap;
}

.input-settings-label svg {
    width: 16px;
    height: 16px;
    color: var(--accent-cyan);
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    transition: all 0.3s ease;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: all 0.3s ease;
}

.toggle-switch input:checked+.toggle-slider {
    background: linear-gradient(267deg, #ff6b3500, var(--accent-cyan))
}

.toggle-switch input:checked+.toggle-slider::before {
    transform: translateX(20px);
    background: white;
}

.toggle-switch input:focus+.toggle-slider {
    box-shadow: 0 0 0 2px var(--accent-cyan-glow);
}

/* Attachments Preview */
.attachments-preview {
    display: none;
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    max-height: 200px;
    overflow-y: auto;
}

.attachments-preview.has-files {
    display: flex;
}

/* When attachments preview is visible, adjust model-selector border-radius */
.attachments-preview.has-files+.message-input-wrapper .model-selector,
.attachments-preview.has-files~.model-selector {
    border-radius: 0;
}

.attachment-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    max-width: 200px;
    transition: all var(--transition-fast);
}

.attachment-item:hover {
    border-color: var(--accent-cyan);
}

.attachment-item.image-attachment {
    padding: 4px;
    flex-direction: column;
    max-width: 120px;
}

.attachment-item.image-attachment img {
    width: 100%;
    max-width: 112px;
    max-height: 80px;
    object-fit: cover;
    border-radius: var(--border-radius-sm);
}

.attachment-item.image-attachment .attachment-name {
    font-size: 0.75rem;
    max-width: 100px;
    padding: 4px 0;
}

.attachment-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border-radius: var(--border-radius-sm);
    flex-shrink: 0;
}

.attachment-icon svg {
    width: 18px;
    height: 18px;
    color: var(--accent-cyan);
}

.attachment-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.attachment-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.attachment-size {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.attachment-remove {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--error);
    border: 2px solid var(--bg-primary);
    border-radius: 50%;
    cursor: pointer;
    transition: all var(--transition-fast);
    color: white;
}

.attachment-remove:hover {
    transform: scale(1.1);
    background: #ff4444;
}

.attachment-remove svg {
    width: 12px;
    height: 12px;
}

/* Loading state for attachments */
.attachment-item.uploading {
    opacity: 0.7;
}

.attachment-item.uploading::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg,
            transparent,
            rgba(255, 255, 255, 0.1),
            transparent);
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(100%);
    }
}

/* Message attachments display */
.message-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.message-attachment {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    max-width: 250px;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    color: inherit;
}

.message-attachment:hover,
.message-attachment:active {
    border-color: var(--accent-cyan);
    background: var(--bg-hover);
}

.message-attachment.image-attachment {
    padding: 4px;
    flex-direction: column;
    max-width: none;
}

.message-attachment.image-attachment img {
    max-width: 300px;
    max-height: 200px;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
}

.message-attachment.image-attachment:hover img {
    opacity: 0.9;
}

/* Drag & drop state */
.input-container.drag-over .input-wrapper {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 3px var(--accent-cyan-glow), inset 0 0 20px rgba(0, 212, 255, 0.1);
}

.input-container.drag-over .input-wrapper::after {
    content: 'Перетащите файлы сюда';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.8);
    color: var(--accent-cyan);
    font-size: 1rem;
    font-weight: 500;
    border-radius: var(--border-radius-lg);
    z-index: 10;
}

/* ===== Settings Page ===== */
.settings-page {
    min-height: 100vh;
    background: var(--bg-primary);
}

.settings-container {
    max-width: 700px;
    margin: 0 auto;
    padding: 40px 20px;
}

.settings-header {
    margin-bottom: 40px;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 20px;
    transition: color var(--transition-fast);
}

.back-link:hover {
    color: var(--accent-cyan);
}

.back-link svg {
    width: 18px;
    height: 18px;
}

.settings-header h1 {
    font-size: 2rem;
}

.settings-content {
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.settings-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 28px;
}

.settings-section h2 {
    font-size: 1.2rem;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.settings-form {
    max-width: 400px;
}

.hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 6px;
}

/* Avatar upload */
.avatar-upload {
    display: flex;
    align-items: center;
    gap: 24px;
}

.current-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid var(--border-color);
}

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

.avatar-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Info grid */
.info-grid {
    display: grid;
    gap: 16px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

.info-item:last-child {
    border-bottom: none;
}

.info-label {
    color: var(--text-secondary);
}

.info-value {
    font-weight: 500;
}

/* ===== Admin Page ===== */
.admin-page {
    min-height: 100vh;
    background: var(--bg-primary);
}

.admin-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
}

/* Admin login */
.admin-login {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.admin-login-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 40px;
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.admin-logo {
    margin-bottom: 20px;
}

.admin-logo svg {
    width: 64px;
    height: 64px;
}

.admin-login-card h1 {
    margin-bottom: 24px;
}

.admin-login-form {
    text-align: left;
}

.attempts-info {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 16px;
}

.blocked-notice {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    color: var(--error);
    padding: 24px;
}

.blocked-notice svg {
    width: 48px;
    height: 48px;
}

/* Admin panel */
.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.admin-content {
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.admin-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 28px;
}

.admin-section h2 {
    font-size: 1.2rem;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.system-prompt-textarea {
    width: 100%;
    min-height: 120px;
    padding: 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    resize: vertical;
    transition: border-color var(--transition-fast);
}

.system-prompt-textarea:focus {
    outline: none;
    border-color: var(--accent-cyan);
}

.system-prompt-textarea::placeholder {
    color: var(--text-muted);
}

.admin-form {
    max-width: 100%;
}

/* Models table */
.models-table-wrapper {
    overflow-x: auto;
}

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

.models-table th,
.models-table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.models-table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.models-table tr.inactive {
    opacity: 0.5;
}

.model-avatar-small {
    width: 36px;
    height: 36px;
    border-radius: 50%;
}

.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.status-badge.active {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}

.status-badge.inactive {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
}

/* Provider badges */
.provider-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.provider-badge.openrouter {
    background: rgba(0, 212, 255, 0.15);
    color: var(--accent-cyan);
}

.provider-badge.polza {
    background: rgba(139, 92, 246, 0.15);
    color: #a78bfa;
}

.inline-form {
    display: inline;
}

/* ===== Spinner ===== */
.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-cyan);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ===== Responsive ===== */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 100%;
    }

    /* Сайдбар - скрыт по умолчанию на мобильных */
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 280px;
        transform: translateX(-100%);
        z-index: 1001;
        transition: transform var(--transition-normal);
    }

    /* Сайдбар открыт */
    .sidebar.mobile-open {
        transform: translateX(0);
    }

    /* Оверлей для закрытия сайдбара */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.6);
        z-index: 1000;
        opacity: 0;
        transition: opacity var(--transition-normal);
    }

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

    /* Кнопка меню всегда видна */
    .toggle-sidebar {
        display: flex !important;
    }

    .chat-main {
        width: 100%;
    }

    /* Строка ввода ВСЕГДА внизу на мобильных */
    .input-container {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        transform: none !important;
        max-width: 100% !important;
        padding: 12px 16px !important;
        padding-bottom: calc(12px + env(safe-area-inset-bottom)) !important;
        background: var(--bg-primary);
        border-top: 1px solid var(--border-color);
        z-index: 100;
    }

    .input-container.centered {
        position: fixed !important;
        top: auto !important;
        transform: none !important;
    }

    /* Контейнер сообщений - отступ снизу для input */
    .messages-container {
        padding-bottom: calc(240px + env(safe-area-inset-bottom, 0px)) !important;
    }

    /* Attachments preview на мобильных */
    .attachments-preview {
        max-height: 150px;
        padding: 10px;
        gap: 8px;
    }

    .attachment-item {
        padding: 6px 10px;
        max-width: 160px;
    }

    .attachment-item.image-attachment {
        max-width: 100px;
    }

    .attachment-item.image-attachment img {
        max-height: 60px;
    }

    .message-attachment.image-attachment img {
        max-width: 100%;
        max-height: 150px;
    }

    /* Empty state на мобильных */
    .empty-state {
        padding-bottom: calc(140px + env(safe-area-inset-bottom, 0px));
    }

    .auth-card {
        padding: 28px;
    }

    .secret-key-wrapper {
        flex-direction: column;
    }

    .settings-container,
    .admin-container {
        padding: 20px 16px;
    }

    .avatar-upload {
        flex-direction: column;
        text-align: center;
    }

    .models-table th,
    .models-table td {
        padding: 10px 12px;
    }

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

    /* Заголовок чата */
    .chat-header {
        padding: 12px 16px;
    }

    .chat-title {
        font-size: 1rem;
    }
}

/* ===== Thinking Block ===== */
.thinking-block {
    margin-bottom: 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: rgba(139, 92, 246, 0.05);
    overflow: hidden;
    transition: all var(--transition-normal);
}

.thinking-block[open] {
    background: rgba(139, 92, 246, 0.08);
}

.thinking-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    cursor: pointer;
    user-select: none;
    transition: background var(--transition-fast);
    list-style: none;
}

.thinking-header::-webkit-details-marker {
    display: none;
}

.thinking-header:hover {
    background: rgba(139, 92, 246, 0.1);
}

.thinking-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.thinking-icon svg {
    width: 18px;
    height: 18px;
    color: #a78bfa;
}

/* Анимация вращения звёзд при стриминге */
.thinking-block.streaming .thinking-icon svg {
    animation: sparkleRotate 2s linear infinite;
}

@keyframes sparkleRotate {
    0% {
        transform: rotate(0deg) scale(1);
    }

    25% {
        transform: rotate(90deg) scale(1.1);
    }

    50% {
        transform: rotate(180deg) scale(1);
    }

    75% {
        transform: rotate(270deg) scale(1.1);
    }

    100% {
        transform: rotate(360deg) scale(1);
    }
}

.thinking-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: #a78bfa;
    flex-shrink: 0;
}

.thinking-preview {
    flex: 1;
    font-size: 0.85rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    opacity: 0.7;
}

.thinking-block[open] .thinking-preview {
    display: none;
}

.thinking-toggle {
    flex-shrink: 0;
    color: var(--text-muted);
    transition: transform var(--transition-fast);
}

.thinking-toggle svg {
    width: 16px;
    height: 16px;
    display: block;
}

.thinking-block[open] .thinking-toggle {
    transform: rotate(180deg);
}

.thinking-content {
    padding: 0 16px 16px;
    border-top: 1px solid var(--border-color);
    animation: thinkingExpand 0.3s ease;
}

.thinking-content-header {
    display: flex;
    justify-content: flex-end;
    padding: 8px 0 0;
}

.thinking-copy-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
    opacity: 0.6;
}

.thinking-copy-btn:hover {
    opacity: 1;
    background: var(--bg-hover);
    border-color: #a78bfa;
    color: #a78bfa;
}

.thinking-copy-btn.copied {
    opacity: 1;
    background: rgba(34, 197, 94, 0.15);
    border-color: var(--success);
    color: var(--success);
}

.thinking-copy-btn svg {
    width: 14px;
    height: 14px;
}

@keyframes thinkingExpand {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.thinking-content pre {
    margin: 12px 0 0;
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: var(--border-radius-sm);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    line-height: 1.7;
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-break: break-word;
    height: 300px;
    max-height: 300px;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
}

/* Wrapper для текста */
.thinking-text-wrapper {
    display: block;
}

/* Thinking block при стриминге - пульсация границы */
.thinking-block.streaming {
    border-color: rgba(167, 139, 250, 0.5);
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.2);
}

.thinking-block.streaming .thinking-title::after {
    content: '...';
    animation: thinkingDots 1.5s infinite;
}

@keyframes thinkingDots {

    0%,
    20% {
        content: '.';
    }

    40% {
        content: '..';
    }

    60%,
    100% {
        content: '...';
    }
}

/* Mobile styles for thinking block */
@media (max-width: 768px) {
    .thinking-header {
        padding: 10px 12px;
        gap: 8px;
    }

    .thinking-preview {
        max-width: 150px;
    }

    .thinking-content {
        padding: 0 12px 12px;
    }

    .thinking-content pre {
        height: 250px;
        max-height: 250px;
        font-size: 0.8rem;
        padding: 12px;
    }

    /* На мобильных кнопки копирования всегда видны */
    .message-actions {
        opacity: 1;
    }

    .thinking-copy-btn {
        opacity: 1;
    }
}

/* ===== VPN Notification ===== */
.vpn-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    max-width: 420px;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.15) 0%, rgba(255, 107, 53, 0.1) 100%);
    border: 1px solid var(--warning);
    border-radius: var(--border-radius);
    padding: 16px 48px 16px 16px;
    z-index: 10001;
    box-shadow: var(--shadow-lg), 0 0 20px rgba(245, 158, 11, 0.2);
    animation: vpnSlideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    backdrop-filter: blur(10px);
}

.vpn-notification.hiding {
    animation: vpnSlideOut 0.3s ease forwards;
}

@keyframes vpnSlideIn {
    from {
        opacity: 0;
        transform: translateX(100px) scale(0.9);
    }

    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes vpnSlideOut {
    from {
        opacity: 1;
        transform: translateX(0) scale(1);
    }

    to {
        opacity: 0;
        transform: translateX(100px) scale(0.9);
    }
}

.vpn-notification-content {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.vpn-notification-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(245, 158, 11, 0.2);
    border-radius: 50%;
    animation: vpnIconPulse 2s ease-in-out infinite;
}

@keyframes vpnIconPulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4);
    }

    50% {
        box-shadow: 0 0 0 8px rgba(245, 158, 11, 0);
    }
}

.vpn-notification-icon svg {
    width: 22px;
    height: 22px;
    color: var(--warning);
}

.vpn-notification-text {
    flex: 1;
}

.vpn-notification-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--warning);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.vpn-notification-message {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.vpn-notification-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-muted);
    transition: all var(--transition-fast);
}

.vpn-notification-close:hover {
    background: rgba(245, 158, 11, 0.2);
    border-color: var(--warning);
    color: var(--warning);
    transform: rotate(90deg);
}

.vpn-notification-close svg {
    width: 16px;
    height: 16px;
}

.vpn-notification-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: rgba(245, 158, 11, 0.2);
    border-radius: 0 0 var(--border-radius) var(--border-radius);
    overflow: hidden;
}

.vpn-notification-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--warning), var(--accent-orange));
    animation: vpnProgressShrink 5s linear forwards;
}

@keyframes vpnProgressShrink {
    from {
        width: 100%;
    }

    to {
        width: 0%;
    }
}

/* Mobile VPN notification */
@media (max-width: 768px) {
    .vpn-notification {
        top: auto;
        bottom: calc(100px + env(safe-area-inset-bottom));
        right: 16px;
        left: 16px;
        max-width: none;
    }
}

/* ===== Stop Generation Button ===== */
.btn-send.btn-stop {
    background: linear-gradient(135deg, var(--error) 0%, #dc2626 100%);
    animation: stopBtnPulse 1.5s ease-in-out infinite;
}

.btn-send.btn-stop:hover:not(:disabled) {
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.5);
    animation: none;
}

@keyframes stopBtnPulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }

    50% {
        box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
    }
}

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

/* Transition for button icon change */
.btn-send svg {
    transition: transform var(--transition-fast), opacity var(--transition-fast);
}

.btn-send.btn-stop svg {
    transform: scale(1.1);
}

/* ===== Loading Button State ===== */
.btn-send.btn-loading {
    background: var(--bg-elevated);
    cursor: wait;
}

.btn-send.btn-loading svg.spinner {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* ===== Print ===== */
@media print {

    .sidebar,
    .input-container,
    .chat-header,
    .vpn-notification {
        display: none;
    }

    .chat-main {
        width: 100%;
    }

    .messages-container {
        overflow: visible;
    }
}

/* ===== Model File Support Badges (Admin Panel) ===== */
.file-support-badges {
    display: flex;
    gap: 6px;
    align-items: center;
    justify-content: center;
}

.file-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: var(--bg-elevated);
    transition: var(--transition-fast);
}

.file-badge svg {
    width: 16px;
    height: 16px;
    stroke: var(--text-secondary);
}

.file-badge.images {
    background: rgba(16, 185, 129, 0.15);
}

.file-badge.images svg {
    stroke: #10b981;
}

.file-badge.files {
    background: rgba(59, 130, 246, 0.15);
}

.file-badge.files svg {
    stroke: #3b82f6;
}

.file-badge.none {
    color: var(--text-secondary);
    font-size: 14px;
    background: transparent;
}

.file-badge.thinking {
    background: rgba(249, 115, 22, 0.15);
}

.file-badge.thinking svg {
    stroke: #f97316;
}

/* Checkbox Group Styles (Admin Panel) */
.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 8px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    display: none;
}

.checkbox-label .checkmark {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-radius: 5px;
    background: var(--bg-elevated);
    position: relative;
    transition: var(--transition-fast);
    flex-shrink: 0;
}

.checkbox-label input[type="checkbox"]:checked+.checkmark {
    background: var(--primary);
    border-color: var(--primary);
}

.checkbox-label input[type="checkbox"]:checked+.checkmark::after {
    content: '';
    position: absolute;
    left: 6px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.checkbox-label .checkbox-text {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-primary);
    font-size: 14px;
}

.checkbox-label .checkbox-icon {
    width: 18px;
    height: 18px;
    stroke: var(--text-secondary);
}

.checkbox-label input[type="checkbox"]:checked~.checkbox-text .checkbox-icon {
    stroke: var(--primary);
}

/* Model Capabilities in Dropdown */
.model-option {
    position: relative;
}

.model-capabilities {
    display: flex;
    gap: 4px;
    margin-left: auto;
    padding-left: 10px;
}

.capability-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 4px;
    opacity: 0.7;
    transition: opacity var(--transition-fast);
}

.capability-icon svg {
    width: 14px;
    height: 14px;
}

.capability-icon.images svg {
    stroke: #10b981;
}

.capability-icon.files svg {
    stroke: #3b82f6;
}

.model-option:hover .capability-icon {
    opacity: 1;
}

/* ===== Thinking Badge (Brain Icon) ===== */
.thinking-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    margin-left: 6px;
    flex-shrink: 0;
}

.thinking-badge svg {
    width: 16px;
    height: 16px;
    stroke: #f97316;
    filter: drop-shadow(0 0 3px rgba(249, 115, 22, 0.4));
    animation: thinkingPulse 2s ease-in-out infinite;
}

@keyframes thinkingPulse {

    0%,
    100% {
        filter: drop-shadow(0 0 3px rgba(249, 115, 22, 0.4));
    }

    50% {
        filter: drop-shadow(0 0 8px rgba(249, 115, 22, 0.7));
    }
}

.thinking-badge.selected {
    margin-left: 8px;
}

.thinking-badge.selected svg {
    width: 18px;
    height: 18px;
}

/* Thinking icon in checkbox */
.checkbox-icon.thinking-icon {
    stroke: #f97316;
}

.checkbox-label input[type="checkbox"]:checked~.checkbox-text .thinking-icon {
    stroke: #f97316;
}

/* Attach button disabled state */
.btn-attach[style*="display: none"]+.message-input-wrapper textarea {
    padding-left: 16px;
}

/* Admin Form Label */
.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
}

/* Responsive adjustments for admin panel */
@media (max-width: 768px) {
    .checkbox-group {
        flex-direction: column;
        gap: 12px;
    }

    .file-support-badges {
        flex-wrap: wrap;
    }

    .models-table th:nth-child(6),
    .models-table td:nth-child(6) {
        min-width: 70px;
    }
}

/* ===== Context Usage Indicator ===== */
.context-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
    padding: 6px 12px;
    background: var(--bg-elevated);
    border-radius: 20px;
    border: 1px solid var(--border);
    transition: var(--transition-fast);
}

.context-indicator:hover {
    border-color: var(--primary);
    box-shadow: 0 0 12px rgba(var(--primary-rgb), 0.15);
}

.context-info {
    display: flex;
    align-items: baseline;
    gap: 2px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
}

.context-used {
    color: var(--text-primary);
    font-weight: 600;
}

.context-separator {
    color: var(--text-secondary);
    opacity: 0.5;
}

.context-max {
    color: var(--text-secondary);
    font-size: 11px;
}

/* Circular Progress Ring */
.context-ring {
    position: relative;
    width: 36px;
    height: 36px;
}

.context-ring svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.context-ring-bg {
    stroke: var(--bg-secondary);
}

.context-ring-progress {
    stroke: var(--primary);
    stroke-linecap: round;
    transition: stroke-dasharray 0.5s ease, stroke 0.3s ease;
}

/* Color states based on usage */
.context-ring.low .context-ring-progress {
    stroke: #10b981;
    /* Green */
}

.context-ring.medium .context-ring-progress {
    stroke: #f59e0b;
    /* Orange */
}

.context-ring.high .context-ring-progress {
    stroke: #ef4444;
    /* Red */
}

.context-ring.critical .context-ring-progress {
    stroke: #dc2626;
    animation: contextPulse 1s ease-in-out infinite;
}

@keyframes contextPulse {

    0%,
    100% {
        filter: drop-shadow(0 0 2px rgba(220, 38, 38, 0.5));
    }

    50% {
        filter: drop-shadow(0 0 6px rgba(220, 38, 38, 0.8));
    }
}

.context-percent {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 9px;
    font-weight: 700;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
}

/* Text color based on usage */
.context-indicator.low .context-used {
    color: #10b981;
}

.context-indicator.medium .context-used {
    color: #f59e0b;
}

.context-indicator.high .context-used {
    color: #ef4444;
}

.context-indicator.critical .context-used {
    color: #dc2626;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .context-indicator {
        padding: 4px 8px;
        gap: 8px;
    }

    .context-info {
        font-size: 10px;
    }

    .context-max {
        font-size: 9px;
    }

    .context-ring {
        width: 30px;
        height: 30px;
    }

    .context-percent {
        font-size: 7px;
    }
}

@media (max-width: 480px) {
    .context-info {
        display: none;
    }

    .context-indicator {
        padding: 4px 6px;
    }
}

/* ===== File Preview Modal ===== */
.file-preview-modal .modal-content {
    max-width: 90vw;
    max-height: 90vh;
    width: auto;
    min-width: 400px;
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.file-preview-content {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.file-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

.file-preview-title {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.file-preview-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-preview-size {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.file-preview-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    min-width: 36px;
    background: var(--bg-hover);
    border: none;
    border-radius: 50%;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    margin-left: 16px;
}

.file-preview-close:hover {
    background: var(--error);
    color: white;
}

.file-preview-close svg {
    width: 20px;
    height: 20px;
}

.file-preview-body {
    flex: 1;
    overflow: auto;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    min-height: 200px;
    max-height: calc(90vh - 140px);
}

/* Image preview */
.file-preview-body img.preview-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
}

/* Text preview */
.file-preview-body .text-preview {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.file-preview-body .text-content {
    width: 100%;
    max-height: 100%;
    overflow: auto;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-primary);
}

.file-preview-body .text-content pre {
    margin: 0;
    padding: 16px;
    white-space: pre-wrap;
    word-wrap: break-word;
    background: transparent;
}

/* Loading state */
.file-preview-body .preview-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: var(--text-secondary);
}

.file-preview-body .preview-loading .spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-cyan);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Error state */
.file-preview-body .preview-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: var(--text-muted);
    text-align: center;
}

.file-preview-body .preview-error svg {
    width: 48px;
    height: 48px;
    color: var(--text-muted);
}

.file-preview-body .preview-error span {
    font-size: 0.95rem;
}

/* Unsupported file type */
.file-preview-body .preview-unsupported {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    color: var(--text-secondary);
    text-align: center;
    padding: 40px;
}

.file-preview-body .preview-unsupported .file-icon {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border-radius: var(--border-radius);
}

.file-preview-body .preview-unsupported .file-icon svg {
    width: 32px;
    height: 32px;
    color: var(--accent-cyan);
}

.file-preview-body .preview-unsupported p {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.file-preview-actions {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    justify-content: flex-end;
}

.file-preview-actions .btn {
    min-width: 120px;
}

.file-preview-actions .btn svg {
    width: 18px;
    height: 18px;
}

/* Toast for copy success */
.copy-toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--success);
    color: white;
    padding: 12px 24px;
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    font-weight: 500;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
    z-index: 10001;
    box-shadow: var(--shadow-lg);
}

.copy-toast.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* Make attachments clickable */
.attachment-item {
    cursor: pointer;
}

.attachment-item:hover {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 10px var(--accent-cyan-glow);
}

.message-attachment {
    cursor: pointer;
}

.message-attachment:hover {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 10px var(--accent-cyan-glow);
}

/* Mobile styles for file preview */
@media (max-width: 768px) {
    .file-preview-modal .modal-content {
        max-width: 100vw;
        max-height: 100vh;
        width: 100%;
        min-width: unset;
        border-radius: 0;
        margin: 0;
    }

    .file-preview-body {
        max-height: calc(100vh - 140px);
    }

    .file-preview-header {
        padding: 12px 16px;
    }

    .file-preview-name {
        font-size: 0.9rem;
    }

    .file-preview-actions {
        flex-direction: column;
        padding: 12px 16px;
    }

    .file-preview-actions .btn {
        min-width: unset;
        width: 100%;
    }
}

/* ===== Load More Messages Button ===== */
.load-more-container {
    display: flex;
    justify-content: center;
    padding: 16px 0 24px 0;
    margin-bottom: 8px;
}

.btn-load-more {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-load-more:hover {
    background: var(--bg-hover);
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
}

.btn-load-more:hover svg {
    transform: translateY(-2px);
}

.btn-load-more svg {
    width: 18px;
    height: 18px;
    transition: transform var(--transition-fast);
}

.btn-load-more.loading {
    pointer-events: none;
    opacity: 0.7;
}

/* Small spinner for load more button */
.spinner-small {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-cyan);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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