/* ============================================
   HTML智存系统 - 全局样式
   HTML Smart Vault - Global Styles
   ============================================ */

/* ========== CSS变量 ========== */
:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #818cf8;
    --primary-bg: #eef2ff;
    --secondary: #0f172a;
    --accent: #06b6d4;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    
    --bg-light: #f8fafc;
    --bg-white: #ffffff;
    --bg-dark: #0f172a;
    
    --text-dark: #0f172a;
    --text-gray: #64748b;
    --text-light: #94a3b8;
    --text-white: #ffffff;
    
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 20px rgba(0,0,0,0.08);
    --shadow-lg: 0 20px 60px rgba(79,70,229,0.15);
    
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 20px;
    
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

body {
    font-family: var(--font-family);
    background: var(--bg-light);
    color: var(--text-dark);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    text-decoration: none;
    color: inherit;
}

/* ========== 导航栏 ========== */
.navbar {
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
    height: 64px;
    display: flex;
    align-items: center;
}

.nav-container {
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 1.2rem;
    color: var(--text-dark);
    flex-shrink: 0;
}

.brand-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 0.9rem;
}

.nav-search {
    flex: 1;
    max-width: 400px;
    margin: 0 20px;
    position: relative;
}

.nav-search input {
    width: 100%;
    padding: 8px 16px 8px 40px;
    border: 1px solid var(--border-color);
    border-radius: 50px;
    background: var(--bg-light);
    font-size: 0.9rem;
    transition: var(--transition);
    outline: none;
}

.nav-search input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-bg);
}

.nav-search i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 8px;
    list-style: none;
}

.nav-links a {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-gray);
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--primary);
    background: var(--primary-bg);
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.lang-toggle-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: 50px;
    background: transparent;
    cursor: pointer;
    font-size: 0.85rem;
    transition: var(--transition);
    color: var(--text-gray);
}

.lang-toggle-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.user-menu {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px 6px 6px;
    border-radius: 50px;
    cursor: pointer;
    transition: var(--transition);
}

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

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
}

.user-name {
    font-weight: 500;
    font-size: 0.9rem;
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    min-width: 200px;
    padding: 8px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: var(--transition);
}

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

.user-dropdown a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-gray);
    font-size: 0.9rem;
    transition: var(--transition);
}

.user-dropdown a:hover {
    background: var(--bg-light);
    color: var(--text-dark);
}

.user-dropdown hr {
    margin: 8px 0;
    border: none;
    border-top: 1px solid var(--border-color);
}

/* ========== 按钮 ========== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 4px 15px rgba(79, 70, 229, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(79, 70, 229, 0.4);
}

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

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

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

.btn-danger:hover {
    background: #dc2626;
    transform: translateY(-2px);
}

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

.btn-success:hover {
    background: #059669;
    transform: translateY(-2px);
}

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

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 14px 36px;
    font-size: 1rem;
}

.btn-block {
    width: 100%;
    justify-content: center;
}

.btn-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-gray);
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: var(--bg-light);
    color: var(--primary);
}

.btn-icon.danger:hover {
    background: #fef2f2;
    color: var(--danger);
}

/* ========== 表单 ========== */
.form-group {
    margin-bottom: 18px;
}

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

.form-group label i {
    color: var(--text-gray);
    margin-right: 6px;
}

.form-group .required {
    color: var(--danger);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: var(--font-family);
    transition: var(--transition);
    background: var(--bg-white);
    color: var(--text-dark);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-bg);
}

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

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

.half {
    grid-column: span 1;
}

.password-wrapper {
    position: relative;
}

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

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

.toggle-password:hover {
    color: var(--text-dark);
}

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

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

.form-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

/* ========== 认证页面 ========== */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #f8fafc, #eef2ff);
}

.auth-container {
    width: 100%;
    max-width: 440px;
    padding: 20px;
}

.auth-card {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 40px 36px;
    box-shadow: var(--shadow-lg);
}

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

.auth-logo {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 1.3rem;
    font-weight: 800;
    margin-bottom: 20px;
}

.auth-logo .logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
}

.auth-header h1 {
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 6px;
}

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

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

.link {
    color: var(--primary);
    font-weight: 600;
}

.link:hover {
    text-decoration: underline;
}

/* ========== 仪表盘 ========== */
.dashboard {
    padding: 24px;
    min-height: calc(100vh - 64px);
}

.dashboard-container {
    max-width: 1400px;
    margin: 0 auto;
}

.welcome-banner {
    background: linear-gradient(135deg, var(--secondary), #1e293b);
    color: white;
    padding: 32px 36px;
    border-radius: var(--radius);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
}

.welcome-banner h1 {
    font-size: 1.6rem;
    font-weight: 700;
}

.welcome-banner p {
    opacity: 0.8;
    margin-top: 4px;
}

.welcome-banner .btn {
    background: white;
    color: var(--secondary);
    flex-shrink: 0;
}

.welcome-banner .btn:hover {
    background: var(--bg-light);
    transform: translateY(-2px);
}

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

.stat-card {
    background: var(--bg-white);
    padding: 20px 24px;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition);
}

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

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.stat-info {
    flex: 1;
}

.stat-number {
    font-size: 1.5rem;
    font-weight: 800;
    display: block;
    line-height: 1.2;
}

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

.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
}

.card {
    background: var(--bg-white);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

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

.card-header h3 {
    font-size: 1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.html-list {
    padding: 8px 0;
}

.html-item {
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #f1f5f9;
    transition: var(--transition);
}

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

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

.html-title {
    font-weight: 600;
}

.html-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.8rem;
    color: var(--text-gray);
}

.html-meta .badge {
    padding: 2px 10px;
    border-radius: 50px;
    font-weight: 600;
    font-size: 0.75rem;
}

.html-actions {
    display: flex;
    gap: 4px;
}

.empty-state {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-gray);
}

.empty-state i {
    font-size: 3rem;
    color: var(--text-light);
    margin-bottom: 12px;
}

.empty-state p {
    margin-bottom: 16px;
}

/* ========== 分类小工具 ========== */
.category-list {
    list-style: none;
    padding: 8px 0;
}

.category-list li {
    padding: 8px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    color: var(--text-gray);
}

.category-list li:hover {
    background: var(--bg-light);
}

.category-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.add-category {
    color: var(--primary);
    font-weight: 500;
}

.tag-cloud {
    padding: 16px 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    background: var(--bg-light);
    border-radius: 50px;
    font-size: 0.85rem;
    color: var(--text-gray);
    transition: var(--transition);
    cursor: default;
}

.tag:hover {
    background: var(--primary-bg);
    color: var(--primary);
}

.tag-count {
    font-size: 0.7rem;
    background: var(--border-color);
    padding: 0 6px;
    border-radius: 50px;
    color: var(--text-gray);
}

.tag-sm {
    display: inline-block;
    padding: 2px 10px;
    background: var(--bg-light);
    border-radius: 50px;
    font-size: 0.75rem;
    color: var(--text-gray);
    margin: 2px;
}

/* ========== 保存页面 ========== */
.save-html {
    padding: 32px 24px;
}

.save-html .container {
    max-width: 1000px;
    margin: 0 auto;
}

.page-header {
    margin-bottom: 28px;
}

.page-header h1 {
    font-size: 1.8rem;
    font-weight: 800;
}

.page-header p {
    color: var(--text-gray);
}

.save-form {
    background: var(--bg-white);
    padding: 32px;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
}

/* ========== 提醒 ========== */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-error {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.alert-success {
    background: #f0fdf4;
    color: #16a34a;
    border: 1px solid #bbf7d0;
}

.alert-warning {
    background: #fffbeb;
    color: #d97706;
    border: 1px solid #fde68a;
}

.alert-link {
    font-weight: 600;
    text-decoration: underline;
    margin-left: auto;
}

/* ========== 响应式 ========== */
@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .nav-search {
        display: none;
    }
    
    .nav-links a span {
        display: none;
    }
    
    .user-name {
        display: none;
    }
    
    .welcome-banner {
        flex-direction: column;
        text-align: center;
        gap: 16px;
        padding: 24px;
    }
    
    .welcome-banner h1 {
        font-size: 1.3rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .half {
        grid-column: span 1;
    }
    
    .auth-card {
        padding: 28px 20px;
    }
    
    .save-form {
        padding: 20px;
    }
    
    .html-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .html-actions {
        width: 100%;
        justify-content: flex-end;
    }
}

@media (max-width: 480px) {
    .navbar {
        padding: 0 12px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    
    .stat-card {
        padding: 14px 16px;
    }
    
    .stat-number {
        font-size: 1.2rem;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .form-actions .btn {
        justify-content: center;
    }
}