/* ==========================================
   CSS变量与设计系统
   ========================================== */
:root {
    /* 主色调 - 蓝色和绿色 */
    --primary-blue: #0ea5e9;
    --primary-blue-dark: #0284c7;
    --primary-blue-light: #38bdf8;
    --primary-green: #10b981;
    --primary-green-dark: #059669;
    --primary-green-light: #34d399;

    /* 渐变色 */
    --gradient-primary: linear-gradient(135deg, var(--primary-blue) 0%, var(--primary-green) 100%);
    --gradient-soft: linear-gradient(135deg, rgba(14, 165, 233, 0.1) 0%, rgba(16, 185, 129, 0.1) 100%);

    /* 中性色 */
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;

    /* 间距系统 */
    --space-xs: 0.5rem;
    --space-sm: 0.75rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;

    /* 圆角 */
    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;

    /* 阴影 */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

    /* 过渡 */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================
   全局样式
   ========================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(to bottom right, #f0f9ff, #f0fdf4);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ==========================================
   背景装饰
   ========================================== */
.bg-decoration {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.bg-decoration::before,
.bg-decoration::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.3;
    animation: float 20s ease-in-out infinite;
}

.bg-decoration::before {
    width: 600px;
    height: 600px;
    background: var(--primary-blue);
    top: -200px;
    right: -200px;
    animation-delay: 0s;
}

.bg-decoration::after {
    width: 500px;
    height: 500px;
    background: var(--primary-green);
    bottom: -150px;
    left: -150px;
    animation-delay: 2s;
}

@keyframes float {

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

    33% {
        transform: translate(30px, -40px) scale(1.1);
    }

    66% {
        transform: translate(-20px, 30px) scale(0.9);
    }
}

/* ==========================================
   容器
   ========================================== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--space-xl) var(--space-lg);
}

/* ==========================================
   头部样式
   ========================================== */
.header {
    text-align: center;
    margin-bottom: var(--space-2xl);
    animation: fadeInDown 0.6s ease-out;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

.logo svg {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    font-size: 1.125rem;
    color: var(--gray-600);
    font-weight: 400;
}

/* ==========================================
   主要内容区域
   ========================================== */
.main-content {
    display: grid;
    gap: var(--space-xl);
}

/* ==========================================
   区域样式
   ========================================== */
.input-section,
.results-section {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    box-shadow: var(--shadow-xl);
    border: 1px solid rgba(255, 255, 255, 0.5);
    animation: fadeInUp 0.6s ease-out;
}

.section-header {
    margin-bottom: var(--space-lg);
}

.section-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: var(--space-xs);
}

.section-header p {
    color: var(--gray-600);
    font-size: 0.95rem;
}

/* ==========================================
   输入框样式
   ========================================== */
.email-input {
    width: 100%;
    padding: var(--space-lg);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-lg);
    font-family: inherit;
    font-size: 1rem;
    color: var(--gray-800);
    background: white;
    resize: vertical;
    transition: all var(--transition-base);
    margin-bottom: var(--space-lg);
}

.email-input:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
}

.email-input::placeholder {
    color: var(--gray-400);
}

/* ==========================================
   选项区域
   ========================================== */
.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--space-lg);
    margin-bottom: var(--space-xl);
}

.option-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.option-label {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-weight: 600;
    color: var(--gray-700);
    font-size: 0.95rem;
}

.option-label svg {
    color: var(--primary-blue);
}

.style-chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.chip {
    padding: var(--space-sm) var(--space-lg);
    border: 2px solid var(--gray-200);
    background: white;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-700);
    cursor: pointer;
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

.chip::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--gradient-primary);
    opacity: 0;
    transition: opacity var(--transition-base);
}

.chip:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.chip.active {
    border-color: transparent;
    color: white;
}

.chip.active::before {
    opacity: 1;
}

.chip span {
    position: relative;
    z-index: 1;
}

/* ==========================================
   改写按钮
   ========================================== */
.rewrite-btn {
    width: 100%;
    padding: var(--space-lg);
    background: var(--gradient-primary);
    border: none;
    border-radius: var(--radius-lg);
    color: white;
    font-size: 1.125rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    transition: all var(--transition-base);
    box-shadow: var(--shadow-lg);
}

.rewrite-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl);
}

.rewrite-btn:active {
    transform: translateY(0);
}

.rewrite-btn svg {
    animation: rotate 2s linear infinite;
    animation-play-state: paused;
}

.rewrite-btn:hover svg {
    animation-play-state: running;
}

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

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

/* ==========================================
   加载状态
   ========================================== */
.loading-state {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-2xl);
    gap: var(--space-lg);
}

.loading-state.active {
    display: flex;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--gray-200);
    border-top-color: var(--primary-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-state p {
    color: var(--gray-600);
    font-size: 1rem;
}

/* ==========================================
   结果卡片
   ========================================== */
.result-cards {
    display: grid;
    gap: var(--space-lg);
}

.result-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    border: 2px solid var(--gray-200);
    transition: all var(--transition-base);
    animation: slideIn 0.4s ease-out;
}

.result-card:hover {
    border-color: var(--primary-blue-light);
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

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

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

.result-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--gray-200);
}

.result-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-md);
    background: var(--gradient-soft);
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--primary-blue);
}

.copy-btn {
    padding: var(--space-sm) var(--space-md);
    background: var(--gray-100);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--gray-700);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

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

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

.result-content {
    color: var(--gray-700);
    line-height: 1.8;
    font-size: 1rem;
    white-space: pre-wrap;
}

/* ==========================================
   页脚
   ========================================== */
.footer {
    text-align: center;
    margin-top: var(--space-2xl);
    padding-top: var(--space-xl);
    color: var(--gray-600);
    font-size: 0.95rem;
}

/* ==========================================
   动画
   ========================================== */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

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

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

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

/* ==========================================
   响应式设计
   ========================================== */
@media (max-width: 768px) {
    .container {
        padding: var(--space-lg) var(--space-md);
    }

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

    .tagline {
        font-size: 1rem;
    }

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

    .input-section,
    .results-section {
        padding: var(--space-lg);
    }
}

/* ==========================================
   结果区域隐藏状态
   ========================================== */
.results-section.hidden {
    display: none;
}

/* ==========================================
   辅助类
   ========================================== */
.hidden {
    display: none !important;
}

/* ==========================================
   认证界面
   ========================================== */
.auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.auth-container {
    width: 100%;
    max-width: 450px;
    padding: var(--space-lg);
}

.auth-form {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-xl);
    padding: var(--space-2xl);
    box-shadow: var(--shadow-xl);
    border: 1px solid rgba(255, 255, 255, 0.8);
    animation: slideInUp 0.4s ease-out;
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

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

.auth-header {
    text-align: center;
    margin-bottom: var(--space-xl);
}

.auth-header svg {
    margin-bottom: var(--space-md);
}

.auth-header h2 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: var(--space-xs);
}

.auth-header p {
    color: var(--gray-600);
    font-size: 0.95rem;
}

.form-group {
    margin-bottom: var(--space-lg);
}

.form-group label {
    display: block;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: var(--space-xs);
    font-size: 0.875rem;
}

.form-group input {
    width: 100%;
    padding: var(--space-md);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 1rem;
    color: var(--gray-800);
    background: white;
    transition: all var(--transition-base);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
}

.auth-error {
    color: #ef4444;
    font-size: 0.875rem;
    margin-bottom: var(--space-md);
    min-height: 20px;
}

.auth-btn {
    width: 100%;
    padding: var(--space-md) var(--space-lg);
    background: var(--gradient-primary);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    box-shadow: var(--shadow-md);
}

.auth-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.auth-btn:active {
    transform: translateY(0);
}

.auth-switch {
    text-align: center;
    margin-top: var(--space-lg);
    color: var(--gray-600);
    font-size: 0.875rem;
}

.auth-switch a {
    color: var(--primary-blue);
    font-weight: 600;
    text-decoration: none;
    transition: color var(--transition-fast);
}

.auth-switch a:hover {
    color: var(--primary-blue-dark);
}

/* ==========================================
   用户导航栏
   ========================================== */
.user-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--gray-200);
    box-shadow: var(--shadow-sm);
    z-index: 100;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-100%);
    }

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

.user-nav-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--space-md) var(--space-lg);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-info {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.user-name {
    font-weight: 600;
    color: var(--gray-800);
}

.user-actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.icon-btn {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-sm) var(--space-md);
    background: transparent;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    color: var(--gray-700);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.icon-btn:hover {
    background: var(--gray-100);
    border-color: var(--gray-300);
}

.icon-btn svg {
    color: var(--primary-blue);
}

/* ==========================================
   历史记录面板
   ========================================== */
.history-panel {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: 450px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-xl);
    border-left: 1px solid var(--gray-200);
    z-index: 200;
    animation: slideInRight 0.3s ease-out;
    display: flex;
    flex-direction: column;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }

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

.history-header {
    padding: var(--space-lg);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: white;
}

.history-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--gray-800);
}

.close-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    border: none;
    background: transparent;
    color: var(--gray-600);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

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

.history-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-lg);
}

.history-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-2xl);
    text-align: center;
    color: var(--gray-400);
}

.history-empty svg {
    margin-bottom: var(--space-lg);
}

.history-empty p {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--gray-600);
    margin-bottom: var(--space-xs);
}

.history-empty span {
    font-size: 0.875rem;
}

.history-item {
    background: white;
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    margin-bottom: var(--space-md);
    border: 2px solid var(--gray-200);
    transition: all var(--transition-base);
    cursor: pointer;
}

.history-item:hover {
    border-color: var(--primary-blue-light);
    box-shadow: var(--shadow-md);
    transform: translateX(-4px);
}

.history-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-sm);
}

.history-time {
    font-size: 0.75rem;
    color: var(--gray-500);
}

.history-meta {
    display: flex;
    gap: var(--space-xs);
    margin-bottom: var(--space-sm);
}

.history-tag {
    padding: 2px var(--space-xs);
    background: var(--gradient-soft);
    border-radius: 4px;
    font-size: 0.75rem;
    color: var(--primary-blue);
    font-weight: 500;
}

.history-preview {
    font-size: 0.875rem;
    color: var(--gray-600);
    line-height: 1.5;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.history-delete {
    padding: 4px var(--space-sm);
    background: transparent;
    border: 1px solid var(--gray-300);
    border-radius: 4px;
    color: var(--gray-600);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.history-delete:hover {
    background: #fee2e2;
    border-color: #ef4444;
    color: #ef4444;
}

/* ==========================================
   响应式设计（用户系统）
   ========================================== */
@media (max-width: 768px) {
    .user-nav-content {
        padding: var(--space-sm) var(--space-md);
    }

    .user-name {
        font-size: 0.875rem;
    }

    .icon-btn span {
        display: none;
    }

    .history-panel {
        width: 100%;
        max-width: 100%;
    }

    .auth-container {
        padding: var(--space-md);
    }

    .auth-form {
        padding: var(--space-lg);
    }
}

/* ==========================================
   容器登录后显示（调整padding）
   ========================================== */
.container {
    padding-top: calc(var(--space-xl) + 60px);
    /* 为导航栏留出空间 */
}