/* ============================================
   On老师命题助手
   Style B — Vibrant Gradient / 活力渐变扁平化
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Noto+Sans+SC:wght@400;500;600;700&display=swap');

:root {
    /* 主色 */
    --primary: #6366F1;
    --primary-hover: #4F46E5;
    --primary-light: #EEF2FF;
    --primary-50: rgba(99,102,241,0.08);

    /* 渐变 */
    --gradient: linear-gradient(135deg, #6366F1, #8B5CF6);
    --gradient-hover: linear-gradient(135deg, #4F46E5, #7C3AED);
    --gradient-soft: linear-gradient(135deg, rgba(99,102,241,0.08), rgba(139,92,246,0.08));
    --gradient-hero: linear-gradient(135deg, #1E1B4B 0%, #312E81 50%, #4338CA 100%);

    /* 中性色 */
    --bg: #F8FAFC;
    --white: #FFFFFF;
    --gray-50: #F8FAFC;
    --gray-100: #F1F5F9;
    --gray-200: #E2E8F0;
    --gray-300: #CBD5E1;
    --gray-400: #94A3B8;
    --gray-500: #64748B;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1E293B;
    --gray-900: #0F172A;

    /* 语义色 */
    --success: #10B981;
    --success-light: #D1FAE5;
    --danger: #EF4444;
    --danger-light: #FEE2E2;
    --warning: #F59E0B;
    --warning-light: #FEF3C7;
    --info: #3B82F6;

    /* 侧边栏 */
    --sidebar-bg: #1E1B4B;
    --sidebar-hover: rgba(255,255,255,0.08);
    --sidebar-active: rgba(139,92,246,0.25);
    --sidebar-text: rgba(255,255,255,0.65);
    --sidebar-text-active: #FFFFFF;
    --sidebar-border: rgba(255,255,255,0.06);

    /* 字体 */
    --font: 'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;

    /* 尺寸 */
    --sidebar-width: 272px;
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;

    /* 阴影 */
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 25px -5px rgba(0,0,0,0.08), 0 4px 10px rgba(0,0,0,0.04);
    --shadow-xl: 0 20px 50px -12px rgba(0,0,0,0.12);
    --shadow-primary: 0 4px 14px rgba(99,102,241,0.35);

    /* 过渡 */
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html, body {
    height: 100%;
    font-family: var(--font);
    background: var(--bg);
    color: var(--gray-800);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

h1, h2, h3, h4 { font-weight: 700; color: var(--gray-900); letter-spacing: -0.01em; }

::selection { background: var(--primary-light); color: var(--primary-hover); }

/* ========================
   BUTTONS
   ======================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background: var(--gradient);
    color: #fff;
    box-shadow: var(--shadow-primary);
}
.btn-primary:hover {
    background: var(--gradient-hover);
    box-shadow: 0 6px 20px rgba(99,102,241,0.4);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--white);
    color: var(--gray-700);
    border: 1.5px solid var(--gray-200);
}
.btn-secondary:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-50);
}

.btn-ghost {
    background: transparent;
    color: var(--gray-600);
}
.btn-ghost:hover {
    background: var(--gray-100);
    color: var(--gray-800);
}

.btn-danger {
    background: var(--white);
    color: var(--danger);
    border: 1.5px solid var(--danger-light);
}
.btn-danger:hover {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}

.btn-sm { padding: 6px 14px; font-size: 13px; border-radius: var(--radius-sm); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none !important; }

/* ========================
   INPUTS
   ======================== */
.input-group { margin-bottom: 20px; }

.input-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-600);
}

.input-group input,
.input-group textarea,
.input-group select {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 14px;
    color: var(--gray-800);
    background: var(--white);
    transition: all var(--transition);
    outline: none;
}

.input-group input:focus,
.input-group textarea:focus,
.input-group select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}

.input-group input::placeholder,
.input-group textarea::placeholder {
    color: var(--gray-400);
}

.input-group textarea {
    resize: vertical;
    min-height: 100px;
    line-height: 1.7;
}

/* ========================
   AUTH PAGE — 登录/注册
   ======================== */
.auth-page {
    min-height: 100vh;
    display: flex;
}

/* 左侧渐变色块 */
.auth-hero {
    flex: 1;
    background: var(--gradient-hero);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px;
    position: relative;
    overflow: hidden;
}

.auth-hero::before {
    content: '';
    position: absolute;
    width: 500px; height: 500px;
    border-radius: 50%;
    background: rgba(139,92,246,0.15);
    top: -100px; right: -100px;
    filter: blur(80px);
}

.auth-hero::after {
    content: '';
    position: absolute;
    width: 400px; height: 400px;
    border-radius: 50%;
    background: rgba(99,102,241,0.12);
    bottom: -80px; left: -80px;
    filter: blur(60px);
}

.auth-hero-content {
    position: relative;
    z-index: 1;
    text-align: center;
    color: #fff;
    max-width: 400px;
}

.auth-hero-content .hero-icon {
    font-size: 56px;
    margin-bottom: 24px;
    display: block;
}

.auth-hero-content h2 {
    font-size: 32px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 12px;
    letter-spacing: -0.02em;
}

.auth-hero-content p {
    font-size: 16px;
    color: rgba(255,255,255,0.7);
    line-height: 1.7;
}

.hero-features {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 40px;
    text-align: left;
}

.hero-feature {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: rgba(255,255,255,0.85);
}

.hero-feature-icon {
    width: 36px; height: 36px;
    border-radius: 10px;
    background: rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

/* 右侧表单 */
.auth-form-side {
    width: 480px;
    min-width: 480px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    background: var(--white);
}

.auth-container {
    width: 100%;
    max-width: 380px;
}

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

.auth-header .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 24px;
}

.auth-header .brand-icon {
    width: 40px; height: 40px;
    border-radius: 12px;
    background: var(--gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #fff;
    box-shadow: var(--shadow-primary);
}

.auth-header .brand-text {
    font-size: 18px;
    font-weight: 700;
    color: var(--gray-900);
}

.auth-header h1 {
    font-size: 24px;
    margin-bottom: 6px;
}

.auth-header p {
    font-size: 14px;
    color: var(--gray-500);
}

.auth-tabs {
    display: flex;
    background: var(--gray-100);
    border-radius: var(--radius);
    padding: 4px;
    margin-bottom: 24px;
}

.auth-tab {
    flex: 1;
    padding: 10px;
    text-align: center;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-500);
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.auth-tab.active {
    background: var(--white);
    color: var(--gray-900);
    box-shadow: var(--shadow-sm);
}

.auth-tab:hover:not(.active) { color: var(--gray-700); }

.auth-form { display: none; }
.auth-form.active { display: block; }

.auth-form .btn {
    width: 100%;
    padding: 12px;
    font-size: 15px;
    margin-top: 4px;
}

/* 消息提示 */
.message {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 13px;
    font-weight: 500;
    display: none;
}
.message.error {
    display: block;
    background: var(--danger-light);
    color: var(--danger);
}
.message.success {
    display: block;
    background: var(--success-light);
    color: #065F46;
}

/* ========================
   APP LAYOUT — 主布局
   ======================== */
.app-layout {
    display: flex;
    height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

.sidebar-header .logo {
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-header .logo-icon {
    width: 32px; height: 32px;
    border-radius: 10px;
    background: var(--gradient);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.sidebar-header .logo-sub {
    font-size: 11px;
    color: var(--sidebar-text);
    display: block;
    margin-top: 4px;
    letter-spacing: 0.08em;
    font-weight: 500;
}

.sidebar-section { padding: 16px 12px 4px; }

.sidebar-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255,255,255,0.3);
    padding: 0 8px;
    margin-bottom: 8px;
}

.sidebar-menu { list-style: none; }
.sidebar-menu li { margin-bottom: 2px; }

.sidebar-menu a,
.sidebar-menu button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-weight: 500;
    color: var(--sidebar-text);
    cursor: pointer;
    transition: all var(--transition);
    border: none;
    background: none;
    font-family: var(--font);
    text-align: left;
}

.sidebar-menu a:hover,
.sidebar-menu button:hover {
    background: var(--sidebar-hover);
    color: rgba(255,255,255,0.9);
}

.sidebar-menu a.active,
.sidebar-menu button.active {
    background: var(--sidebar-active);
    color: var(--sidebar-text-active);
}

.sidebar-menu .icon {
    width: 20px;
    text-align: center;
    font-size: 15px;
    opacity: 0.8;
}

/* New Chat Button */
.new-chat-btn {
    margin: 12px;
    padding: 11px;
    border: 1.5px dashed rgba(139,92,246,0.35);
    border-radius: var(--radius);
    background: transparent;
    color: rgba(255,255,255,0.8);
    font-family: var(--font);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.new-chat-btn:hover {
    border-color: var(--primary);
    background: rgba(99,102,241,0.12);
    color: #fff;
}

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

.chat-list::-webkit-scrollbar { width: 4px; }
.chat-list::-webkit-scrollbar-track { background: transparent; }
.chat-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

.chat-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    margin-bottom: 2px;
}
.chat-item:hover { background: var(--sidebar-hover); }
.chat-item.active { background: var(--sidebar-active); }

.chat-item .chat-title {
    flex: 1;
    font-size: 13px;
    font-weight: 500;
    color: var(--sidebar-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-item.active .chat-title { color: #fff; }

.chat-item .chat-delete {
    opacity: 0;
    transition: opacity var(--transition);
    background: none;
    border: none;
    color: rgba(255,255,255,0.35);
    cursor: pointer;
    padding: 2px 4px;
    font-size: 14px;
}
.chat-item:hover .chat-delete { opacity: 1; }
.chat-item .chat-delete:hover { color: var(--danger); }

/* Sidebar Footer */
.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--sidebar-border);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
}

.user-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    color: #fff;
}

.user-name {
    flex: 1;
    font-size: 13px;
    font-weight: 500;
    color: rgba(255,255,255,0.8);
}

.logout-btn {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.5);
    cursor: pointer;
    padding: 4px 10px;
    font-size: 12px;
    font-family: var(--font);
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}
.logout-btn:hover {
    background: rgba(239,68,68,0.15);
    border-color: rgba(239,68,68,0.3);
    color: var(--danger);
}

/* ========================
   MAIN CONTENT
   ======================== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #F3F0FF;
}

/* ---- Welcome View ---- */
.welcome-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    text-align: center;
}

.welcome-icon {
    width: 72px; height: 72px;
    border-radius: 20px;
    background: var(--gradient-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    margin: 0 auto 20px;
}

.welcome-view h2 {
    font-size: 26px;
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}

.welcome-view p {
    font-size: 15px;
    color: var(--gray-500);
    max-width: 460px;
    line-height: 1.7;
}

.welcome-steps {
    display: flex;
    gap: 16px;
    margin-top: 40px;
    flex-wrap: wrap;
    justify-content: center;
}

.welcome-step {
    background: rgba(255,255,255,0.8);
    border: 1.5px solid rgba(99,102,241,0.1);
    border-radius: var(--radius-lg);
    padding: 24px 20px;
    width: 160px;
    text-align: center;
    transition: all var(--transition);
}
.welcome-step:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}
.welcome-step .step-icon {
    font-size: 28px;
    margin-bottom: 10px;
    display: block;
}
.welcome-step .step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px; height: 22px;
    border-radius: 50%;
    background: var(--gradient);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    margin-bottom: 8px;
}
.welcome-step .step-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
}

/* ---- New Chat View — centered title + compose bar ---- */
.new-chat-view {
    flex: 1;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 40px 24px;
    gap: 24px;
}
.new-chat-view.active { display: flex; }

.new-chat-center {
    text-align: center;
}

.new-chat-qt-name {
    font-size: 30px;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.01em;
    margin-bottom: 10px;
}

.new-chat-hint {
    font-size: 15px;
    color: var(--gray-400);
    font-weight: 400;
}

/* Compose bar — centered */
.new-chat-input-bar {
    width: 100%;
    max-width: 680px;
}

.compose-box {
    display: flex;
    align-items: flex-end;
    gap: 0;
    background: var(--white);
    border: 1.5px solid var(--gray-200);
    border-radius: 28px;
    padding: 6px 6px 6px 8px;
    box-shadow: var(--shadow-md);
    transition: border-color var(--transition), box-shadow var(--transition);
}
.compose-box:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.1), var(--shadow-md);
}

.compose-attach {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: none;
    border: none;
    color: var(--gray-400);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--transition);
}
.compose-attach:hover {
    background: var(--gray-100);
    color: var(--primary);
}

.compose-box textarea {
    flex: 1;
    border: none;
    outline: none;
    resize: none;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--gray-800);
    background: transparent;
    padding: 8px 8px;
    max-height: 160px;
    min-height: 24px;
}
.compose-box textarea::placeholder {
    color: var(--gray-400);
}

.compose-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--gray-200);
    border: none;
    color: var(--white);
    cursor: not-allowed;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--transition);
}
.compose-send.active {
    background: var(--primary);
    cursor: pointer;
    box-shadow: var(--shadow-primary);
}
.compose-send.active:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}
.compose-send:disabled {
    background: var(--gray-200);
    color: var(--white);
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.compose-hint {
    text-align: center;
    font-size: 12px;
    margin-top: 8px;
    font-weight: 500;
}

/* ---- Chat View ---- */
.chat-view {
    flex: 1;
    display: none;
    flex-direction: column;
    overflow: hidden;
}
.chat-view.active { display: flex; }

.chat-header {
    padding: 14px 24px;
    border-bottom: 1px solid var(--gray-200);
    background: rgba(255,255,255,0.8);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-header h3 {
    flex: 1;
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-header .article-preview-btn {
    background: none;
    border: 1.5px solid var(--gray-200);
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-500);
    cursor: pointer;
    font-family: var(--font);
    transition: all var(--transition);
}
.chat-header .article-preview-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-50);
}

.messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.messages-area::-webkit-scrollbar { width: 5px; }
.messages-area::-webkit-scrollbar-track { background: transparent; }
.messages-area::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 6px; }

.message-bubble {
    margin-bottom: 20px;
    display: flex;
    gap: 12px;
    animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.message-bubble .avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
    font-weight: 700;
}

.message-bubble.user .avatar {
    background: var(--gray-200);
    color: var(--gray-600);
}

.message-bubble.assistant .avatar {
    background: var(--gradient);
    color: #fff;
}

.message-content {
    flex: 1;
    max-width: 78%;
}

.message-content .msg-text {
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    font-size: 14px;
    line-height: 1.75;
}

.message-bubble.user .msg-text {
    background: var(--primary-light);
    color: var(--gray-800);
}

.message-bubble.assistant .msg-text {
    background: var(--white);
    border: 1px solid var(--gray-200);
    color: var(--gray-800);
}

/* Markdown in assistant messages */
.message-bubble.assistant .msg-text pre {
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    overflow-x: auto;
    margin: 10px 0;
    font-size: 13px;
    line-height: 1.6;
    font-family: 'Menlo', 'Consolas', monospace;
}

.message-bubble.assistant .msg-text code {
    background: var(--gray-100);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
    font-family: 'Menlo', 'Consolas', monospace;
}

.message-bubble.assistant .msg-text h1,
.message-bubble.assistant .msg-text h2,
.message-bubble.assistant .msg-text h3 {
    margin: 16px 0 8px;
}

.message-bubble.assistant .msg-text ul,
.message-bubble.assistant .msg-text ol {
    margin: 8px 0;
    padding-left: 22px;
}

.message-bubble.assistant .msg-text p { margin: 6px 0; }

/* Typing Indicator */
.typing-indicator {
    display: inline-flex;
    gap: 5px;
    padding: 6px 2px;
}
.typing-indicator span {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--gray-400);
    animation: blink 1.2s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.15s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.3s; }

@keyframes blink {
    0%, 80%, 100% { opacity: 0.25; transform: scale(0.85); }
    40% { opacity: 1; transform: scale(1); }
}

/* Input Area */
.input-area {
    padding: 14px 24px;
    border-top: 1px solid var(--gray-200);
    background: rgba(255,255,255,0.8);
    backdrop-filter: blur(12px);
}

.input-wrapper {
    display: flex;
    gap: 0;
    align-items: flex-end;
    max-width: 800px;
    margin: 0 auto;
    background: var(--white);
    border: 1.5px solid var(--gray-200);
    border-radius: 26px;
    padding: 4px 4px 4px 6px;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.input-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}

.compose-attach-sm {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: none;
    border: none;
    color: var(--gray-400);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--transition);
}
.compose-attach-sm:hover {
    background: var(--gray-100);
    color: var(--primary);
}

.input-wrapper textarea {
    flex: 1;
    padding: 8px 8px;
    border: none;
    outline: none;
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--gray-800);
    background: transparent;
    resize: none;
    max-height: 120px;
}
.input-wrapper textarea::placeholder {
    color: var(--gray-400);
}
}

.send-btn {
    width: 42px; height: 42px;
    border-radius: 50%;
    background: var(--gradient);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 17px;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: var(--shadow-primary);
}
.send-btn:hover {
    background: var(--gradient-hover);
    box-shadow: 0 6px 20px rgba(99,102,241,0.4);
    transform: translateY(-1px);
}
.send-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none;
}

/* ========================
   ADMIN
   ======================== */
.admin-content {
    flex: 1;
    overflow-y: auto;
    padding: 28px 32px;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.admin-header h2 { font-size: 20px; }

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

.stat-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all var(--transition);
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.stat-icon {
    width: 46px; height: 46px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}
.stat-icon.purple { background: #EEF2FF; }
.stat-icon.gold { background: #FEF3C7; }
.stat-icon.sage { background: #D1FAE5; }
.stat-icon.blue { background: #DBEAFE; }

.stat-info .stat-value {
    font-size: 26px;
    font-weight: 700;
    color: var(--gray-900);
}
.stat-info .stat-label {
    font-size: 13px;
    color: var(--gray-500);
}

/* Tables */
.data-table {
    width: 100%;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border-collapse: collapse;
}

.data-table th {
    background: var(--gray-50);
    padding: 12px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--gray-200);
}

.data-table td {
    padding: 12px 16px;
    font-size: 14px;
    border-bottom: 1px solid var(--gray-100);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--gray-50); }

/* Badges */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}
.badge-active { background: var(--success-light); color: #065F46; }
.badge-inactive { background: var(--gray-100); color: var(--gray-500); }
.badge-used { background: var(--danger-light); color: var(--danger); }
.badge-available { background: var(--success-light); color: #065F46; }

/* ========================
   MODALS
   ======================== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15,23,42,0.45);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}
.modal-overlay.active { display: flex; }

.modal {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 520px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    animation: modalSlide 0.25s ease;
}

@keyframes modalSlide {
    from { opacity: 0; transform: scale(0.96) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 { font-size: 17px; }

.modal-close {
    background: none;
    border: none;
    font-size: 22px;
    color: var(--gray-400);
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color var(--transition);
}
.modal-close:hover { color: var(--gray-700); }

.modal-body { padding: 24px; }

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Article Preview */
.article-modal .modal { max-width: 640px; }
.article-preview-content {
    padding: 16px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    white-space: pre-wrap;
    line-height: 1.8;
    font-size: 14px;
    max-height: 400px;
    overflow-y: auto;
}

/* ========================
   UTILITIES
   ======================== */
.hidden { display: none !important; }

.loading-spinner {
    display: inline-block;
    width: 22px; height: 22px;
    border: 2.5px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--gray-400);
}
.empty-state .empty-icon {
    font-size: 42px;
    margin-bottom: 12px;
    opacity: 0.5;
}
.empty-state p { font-size: 14px; }

.ornament { display: none; }

/* ========================
   MODEL SELECT
   ======================== */
.model-select {
    width: 100%;
    padding: 8px 12px;
    border: 1.5px solid rgba(255,255,255,0.1);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 500;
    color: rgba(255,255,255,0.85);
    background: rgba(255,255,255,0.06);
    outline: none;
    cursor: pointer;
    transition: all var(--transition);
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='rgba(255,255,255,0.5)' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 28px;
}
.model-select:focus {
    border-color: rgba(139,92,246,0.5);
    background: rgba(255,255,255,0.1);
}
.model-select option {
    background: var(--sidebar-bg);
    color: #fff;
}

/* Admin link in sidebar footer */
.admin-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    font-size: 16px;
    color: rgba(255,255,255,0.4);
    text-decoration: none;
    transition: all var(--transition);
}
.admin-link:hover {
    background: var(--sidebar-hover);
    color: rgba(255,255,255,0.8);
}

/* ========================
   RESPONSIVE
   ======================== */
@media (max-width: 900px) {
    .auth-page { flex-direction: column; }
    .auth-hero { min-height: 200px; padding: 40px 24px; }
    .auth-hero-content h2 { font-size: 24px; }
    .hero-features { display: none; }
    .auth-form-side {
        width: 100%; min-width: 0;
        padding: 32px 24px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -280px;
        top: 0; bottom: 0;
        z-index: 100;
        transition: left 0.25s ease;
    }
    .sidebar.open { left: 0; }

    .mobile-overlay {
        display: none;
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(0,0,0,0.35);
        z-index: 99;
    }
    .mobile-overlay.active { display: block; }

    .mobile-menu-btn { display: flex !important; }

    .welcome-steps { flex-direction: column; align-items: center; }

    .question-type-grid { grid-template-columns: 1fr; }
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 22px;
    color: var(--gray-700);
    cursor: pointer;
    padding: 4px;
}
