/* 基础样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* v0 风格配色 */
    --primary: oklch(0.55 0.08 200);
    --primary-foreground: oklch(0.98 0 0);
    --secondary: oklch(0.96 0.01 200);
    --secondary-foreground: oklch(0.35 0.02 200);
    --muted: oklch(0.95 0.005 200);
    --muted-foreground: oklch(0.5 0.02 250);
    --accent: oklch(0.92 0.02 180);
    --accent-foreground: oklch(0.35 0.05 200);
    --destructive: oklch(0.577 0.245 27.325);
    --destructive-foreground: oklch(0.98 0 0);
    --background: oklch(0.98 0.003 90);
    --foreground: oklch(0.25 0.02 250);
    --card: oklch(1 0 0);
    --card-foreground: oklch(0.25 0.02 250);
    --border: oklch(0.9 0.01 200);
    --input: oklch(0.95 0.005 200);
    --ring: oklch(0.55 0.08 200);
    --radius: 0.75rem;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background-color: var(--background);
    color: var(--foreground);
    line-height: 1.6;
}

/* 顶部导航栏 */
.header-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background-color: var(--card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 100;
    backdrop-filter: blur(8px);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-menu-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.header-menu-btn:hover {
    background-color: var(--accent);
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-logo-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-logo-icon svg {
    width: 20px;
    height: 20px;
    color: white;
}

.header-title {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.header-title-main {
    font-size: 15px;
    font-weight: 600;
    color: var(--foreground);
}

.header-title-sub {
    font-size: 10px;
    color: var(--muted-foreground);
    display: none;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-link {
    display: none;
    padding: 6px 12px;
    border: none;
    background: transparent;
    border-radius: 6px;
    font-size: 13px;
    color: var(--muted-foreground);
    cursor: pointer;
    transition: all 0.2s;
    align-items: center;
    gap: 6px;
}

.header-link:hover {
    background: var(--accent);
    color: var(--foreground);
}

.header-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

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

.header-btn-primary:hover {
    opacity: 0.9;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.user-menu:hover {
    background: var(--accent);
}

/* 应用容器 */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding-top: 56px;
    min-height: 0;
}

.app-content {
    display: flex;
    flex: 1;
    position: relative;
    min-height: 0;
    overflow: hidden;
}

/* 侧边栏遮罩 */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    top: 56px;
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(4px);
    z-index: 40;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.sidebar-open .sidebar-overlay {
    opacity: 1;
    visibility: visible;
}

/* 侧边栏 */
.sidebar {
    position: fixed;
    left: -280px;
    top: 56px;
    bottom: 0;
    width: 280px;
    background: var(--card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 50;
    transition: transform 0.3s ease;
    height: calc(100vh - 56px);
    min-height: 0;
}

.sidebar-open .sidebar {
    transform: translateX(280px);
}

.sidebar-header-mobile {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar-header-mobile-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--foreground);
}

.sidebar-header-mobile-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.sidebar-header-mobile-close:hover {
    background: var(--accent);
}

.sidebar-header {
    display: none;
    flex-shrink: 0;
}

.new-chat-btn {
    margin: 16px;
    padding: 12px 16px;
    background: var(--primary);
    color: var(--primary-foreground);
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.new-chat-btn:hover {
    opacity: 0.9;
}

.sessions-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 16px;
    min-height: 0;
}

.session-item {
    padding: 12px 16px;
    margin-bottom: 4px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.session-item:hover {
    background-color: var(--accent);
}

.session-item.active {
    background-color: rgba(0, 112, 243, 0.1);
    border-left: 3px solid var(--primary);
}

.session-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--foreground);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.session-summary {
    font-size: 12px;
    color: var(--muted-foreground);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.session-time {
    font-size: 11px;
    color: var(--muted-foreground);
}

/* 侧边栏信息区域 */
.sidebar-info {
    padding: 16px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    overflow-y: auto;
    min-height: 0;
}

.sidebar-info-card {
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--accent);
    padding: 16px;
    margin-bottom: 16px;
}

.sidebar-info-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.sidebar-info-title-icon {
    width: 20px;
    height: 20px;
    border-radius: 9999px;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
}

.sidebar-info-title-text {
    font-size: 14px;
    font-weight: 500;
    color: var(--foreground);
}

.sidebar-info-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sidebar-info-section-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--foreground);
}

.sidebar-info-text {
    font-size: 12px;
    color: var(--muted-foreground);
    line-height: 1.5;
}

.sidebar-info-note {
    padding: 8px 12px;
    border-radius: 8px;
    background: var(--secondary);
}

.sidebar-info-note-text {
    font-size: 12px;
    color: var(--secondary-foreground);
}

.sidebar-footer {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}

.sidebar-footer-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border: none;
    background: transparent;
    border-radius: 8px;
    font-size: 13px;
    color: var(--muted-foreground);
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.sidebar-footer-btn:hover {
    background: var(--accent);
    color: var(--foreground);
}

/* 主内容区 */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    width: 100%;
    min-height: 0;
    height: 100%;
}

/* 欢迎页面 */
.welcome-screen {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
    overflow-y: auto;
    min-height: 0;
}

.welcome-content {
    max-width: 512px;
    width: 100%;
}

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

.welcome-icon {
    position: relative;
    display: inline-flex;
    margin-bottom: 24px;
}

.welcome-icon-main {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.welcome-icon-main svg {
    width: 40px;
    height: 40px;
    color: white;
}

.welcome-icon-dot1 {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 12px;
    height: 12px;
    border-radius: 9999px;
    background: var(--accent);
}

.welcome-icon-dot2 {
    position: absolute;
    bottom: -4px;
    left: -4px;
    width: 8px;
    height: 8px;
    border-radius: 9999px;
    background: var(--primary);
    opacity: 0.3;
}

.welcome-title {
    font-size: 28px;
    font-weight: 600;
    color: var(--foreground);
    margin-bottom: 12px;
}

.welcome-subtitle {
    font-size: 16px;
    color: var(--muted-foreground);
    line-height: 1.6;
}

/* 提示卡片 */
.welcome-prompts {
    display: grid;
    gap: 12px;
    margin-bottom: 24px;
}

.prompt-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.prompt-card:hover:not(:disabled) {
    border-color: rgba(0, 112, 243, 0.3);
    background: var(--accent);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.prompt-card:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.prompt-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.prompt-text {
    font-size: 14px;
    color: var(--foreground);
}

.welcome-start-btn {
    display: block;
    width: 100%;
    max-width: 200px;
    margin: 0 auto;
    padding: 12px 24px;
    background: var(--primary);
    color: var(--primary-foreground);
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.welcome-start-btn:hover:not(:disabled) {
    opacity: 0.9;
}

.welcome-start-btn:disabled {
    background: var(--muted);
    color: var(--muted-foreground);
    cursor: not-allowed;
}

.welcome-footer {
    margin-top: 24px;
    text-align: center;
}

.welcome-footer-text {
    font-size: 12px;
    color: var(--muted-foreground);
}

/* 聊天容器 */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
    height: 100%;
}

.chat-header {
    padding: 16px 24px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.chat-header-title {
    font-size: 15px;
    font-weight: 500;
    color: var(--foreground);
}

.delete-btn {
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.delete-btn:hover {
    opacity: 1;
    background: var(--accent);
}

/* 消息容器 */
.messages-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    scroll-behavior: smooth;
    min-height: 0;
}

.messages-container::-webkit-scrollbar {
    width: 6px;
}

.messages-container::-webkit-scrollbar-track {
    background: transparent;
}

.messages-container::-webkit-scrollbar-thumb {
    background-color: var(--border);
    border-radius: 3px;
}

.messages-container::-webkit-scrollbar-thumb:hover {
    background-color: var(--muted-foreground);
}

.message {
    display: flex;
    gap: 12px;
    animation: fadeIn 0.3s ease;
}

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

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

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: var(--primary);
    color: var(--primary-foreground);
}

.message.ai .message-avatar {
    background: var(--accent);
    color: var(--accent-foreground);
}

.message-content-wrapper {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-width: 85%;
}

.message-label {
    font-size: 10px;
    color: var(--muted-foreground);
}

.message-content {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.6;
}

.message.user .message-content {
    background: var(--primary);
    color: var(--primary-foreground);
    border-bottom-right-radius: 4px;
}

.message.ai .message-content {
    background: var(--card);
    color: var(--card-foreground);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* 打字动画 */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background: var(--primary);
    opacity: 0.4;
    border-radius: 9999px;
    animation: bounce 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

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

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

/* 输入区域 */
.input-area {
    padding: 16px;
    background: var(--card);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.input-inner {
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

.input-round-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.input-round-count {
    font-size: 12px;
    color: var(--muted-foreground);
}

.input-round-warning {
    font-size: 12px;
    color: #d97706;
}

.input-wrapper {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--background);
    transition: all 0.2s;
}

.input-wrapper:focus-within {
    border-color: rgba(0, 112, 243, 0.4);
    box-shadow: 0 0 0 2px rgba(0, 112, 243, 0.1);
}

.input-wrapper.disabled {
    opacity: 0.6;
}

#messageInput {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    max-height: 160px;
    min-height: 24px;
    outline: none;
    font-family: inherit;
    color: var(--foreground);
}

#messageInput::placeholder {
    color: var(--muted-foreground);
}

#messageInput:disabled {
    cursor: not-allowed;
}

.input-actions {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    gap: 8px;
}

.input-count {
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    color: var(--muted-foreground);
}

.input-count.warning {
    color: #d97706;
}

.send-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: var(--primary);
    color: var(--primary-foreground);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

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

.send-btn:disabled {
    background: var(--muted);
    color: var(--muted-foreground);
    cursor: not-allowed;
}

.disclaimer {
    margin-top: 12px;
    text-align: center;
    font-size: 11px;
    line-height: 1.6;
    color: var(--muted-foreground);
}

/* 模态框 */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(4px);
    z-index: 100;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--card);
    border-radius: 16px;
    border: 1px solid var(--border);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    padding: 24px;
    width: 100%;
    max-width: 400px;
    position: relative;
    animation: slideUp 0.3s ease;
}

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

.close-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    color: var(--muted-foreground);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.close-btn:hover {
    background: var(--accent);
    color: var(--foreground);
}

.auth-tabs {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.tab-btn {
    padding: 12px 0;
    border: none;
    background: none;
    font-size: 15px;
    color: var(--muted-foreground);
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.tab-btn.active {
    color: var(--foreground);
    font-weight: 500;
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary);
}

/* 内测说明 */
.register-notice {
    background: #fef3c7;
    border: 1px solid #fcd34d;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 20px;
}

.register-notice-title {
    font-size: 13px;
    font-weight: 500;
    color: #92400e;
    margin-bottom: 8px;
}

.register-notice-list {
    list-style: disc;
    padding-left: 20px;
    color: #b45309;
    font-size: 12px;
}

.register-notice-list li {
    margin-bottom: 4px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 13px;
    color: var(--muted-foreground);
}

.form-group input {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
    background: var(--background);
    color: var(--foreground);
}

.form-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(0, 112, 243, 0.1);
}

.error-msg {
    color: var(--destructive);
    font-size: 13px;
    text-align: center;
}

.submit-btn {
    padding: 10px 16px;
    background: var(--primary);
    color: var(--primary-foreground);
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.submit-btn:hover {
    opacity: 0.9;
}

/* 隐私说明 */
.privacy-notice {
    max-height: 400px;
    overflow-y: auto;
}

.privacy-section {
    margin-bottom: 20px;
}

.privacy-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--foreground);
    margin-bottom: 8px;
}

.privacy-list {
    list-style: disc;
    padding-left: 20px;
    color: var(--muted-foreground);
    font-size: 13px;
}

.privacy-list li {
    margin-bottom: 6px;
}

/* 侧边栏用户信息 */
.sidebar-footer-user {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    font-size: 13px;
}

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

#userStatus {
    color: var(--muted-foreground);
}

.trial-badge {
    background: #fef3c7;
    color: #92400e;
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 11px;
}

.login-btn, .logout-btn {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--primary);
    background: transparent;
    color: var(--primary);
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.login-btn:hover, .logout-btn:hover {
    background: var(--primary);
    color: var(--primary-foreground);
}

.privacy-link {
    display: block;
    text-align: center;
    font-size: 11px;
    color: var(--muted-foreground);
    margin-top: 8px;
    text-decoration: none;
}

.privacy-link:hover {
    color: var(--foreground);
}

/* 响应式设计 */
@media (min-width: 768px) {
    .header-title-sub {
        display: block;
    }

    .header-link {
        display: flex;
    }

    .app-content {
        margin-left: 0;
    }

    .sidebar {
        position: relative;
        left: 0;
        top: 0;
        transform: none !important;
        z-index: 1;
        width: 280px;
        flex-shrink: 0;
        height: 100%;
    }

    .sidebar-header-mobile {
        display: none;
    }

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

    .sidebar-overlay {
        display: none;
    }

    .welcome-title {
        font-size: 32px;
    }

    .welcome-prompts {
        grid-template-columns: repeat(2, 1fr);
    }

    .messages-container {
        padding: 32px 24px;
    }

    .input-area {
        padding: 16px 24px 24px;
    }
}
