/* ============================================================================
   主样式文件 - CSS 基础框架和布局
   ============================================================================ */

/* ============================================================================
   浅色主题 (Light Theme) - 默认主题
   ============================================================================ */
:root, .light-theme {
    --primary-color: #4f46e5;
    --primary-dark: #4338ca;
    --secondary-color: #0891b2;
    --text-color: #1f2937;
    --text-light: #6b7280;
    --bg-color: #ffffff;
    --bg-secondary: #f9fafb;
    --border-color: #e5e7eb;
    --bg-hover-color: #f3f4f6;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --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);
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --success-color: #10b981;
    --info-color: #3b82f6;
    --radius: 0.5rem;
    --transition: all 0.2s ease;
}

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

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ============================================================================
   容器和布局
   ============================================================================ */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* ============================================================================
   头部/导航栏
   ============================================================================ */
.header {
    background-color: var(--bg-color);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    height: 70px;
}

.logo a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.5rem;
    font-weight: 700;
    text-decoration: none;
    color: var(--primary-color);
    transition: var(--transition);
}

.logo a:hover {
    color: var(--primary-dark);
}

.logo i {
    font-size: 1.75rem;
}

.nav-links {
    display: flex;
    gap: 2rem;
    margin-left: auto;
    margin-right: 2rem;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-color);
    font-weight: 500;
    transition: color 0.2s;
    padding: 0.5rem 0;
    border-bottom: 2px solid transparent;
}

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

.nav-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* ============================================================================
   按钮
   ============================================================================ */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

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

.btn-primary:hover {
    background-color: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

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

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

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

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

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

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

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    background-color: transparent;
    color: var(--text-color);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    transition: var(--transition);
    font-size: 1.25rem;
}

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

/* ============================================================================
   输入元素
   ============================================================================ */
input,
textarea,
select {
    font-family: inherit;
    font-size: 1rem;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: var(--transition);
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-light);
    opacity: 0.7;
}

/* ============================================================================
   标题
   ============================================================================ */
h1, h2, h3, h4, h5, h6 {
    margin-bottom: 1rem;
    color: var(--text-color);
    line-height: 1.3;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.1rem; }
h6 { font-size: 1rem; }

/* ============================================================================
   链接
   ============================================================================ */
a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--primary-dark);
}

/* ============================================================================
   语言切换器
   ============================================================================ */
.language-switcher {
    position: relative;
    display: inline-block;
}

.lang-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    background-color: var(--bg-color);
    box-shadow: var(--shadow-md);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    padding: 0.5rem 0;
    margin-top: 0.5rem;
    min-width: 120px;
    z-index: 10;
}

.lang-menu a {
    display: block;
    padding: 0.5rem 1rem;
    color: var(--text-color);
    text-decoration: none;
    transition: background-color 0.2s;
}

.lang-menu a:hover {
    background-color: var(--bg-hover-color);
    color: var(--primary-color);
}

.language-switcher:hover .lang-menu {
    display: block;
}

/* ============================================================================
   搜索模态框
   ============================================================================ */
.search-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    padding-top: 4rem;
}

.search-modal.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

.search-container {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.search-container input {
    flex: 1;
    padding: 0.75rem 1rem;
}

.search-results {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

/* ============================================================================
   通知系统
   ============================================================================ */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background-color: white;
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    max-width: 400px;
    z-index: 9999;
    animation: slideIn 0.3s ease;
}

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

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

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

.notification.info {
    border-left: 4px solid var(--info-color);
}

.notification-icon {
    font-size: 1.5rem;
}

.notification-icon.success { color: var(--success-color); }
.notification-icon.error { color: var(--error-color); }
.notification-icon.warning { color: var(--warning-color); }
.notification-icon.info { color: var(--info-color); }

.notification-content {
    flex: 1;
}

.notification-title {
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.25rem;
}

.notification-message {
    font-size: 0.9rem;
    color: var(--text-light);
}

.notification-close {
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    font-size: 1.25rem;
    transition: color 0.2s;
}

.notification-close:hover {
    color: var(--text-color);
}

/* ============================================================================
   工具卡片
   ============================================================================ */
.tool-card {
    background: linear-gradient(135deg, var(--bg-color) 0%, rgba(79, 70, 229, 0.02) 100%);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 2rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.tool-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, transparent 0%, rgba(79, 70, 229, 0.05) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.tool-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 20px 25px -5px rgba(79, 70, 229, 0.15), 0 10px 10px -5px rgba(79, 70, 229, 0.04);
    transform: translateY(-8px) scale(1.02);
}

.tool-card:hover::before {
    opacity: 1;
}

.tool-card:hover .tool-card-icon {
    transform: scale(1.15) rotate(-5deg);
}

.tool-card:hover .tool-card-title {
    color: var(--primary-color);
}

.tool-card-icon {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
    transition: transform 0.3s ease;
}

.tool-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    border-radius: 12px;
    font-size: 1.75rem;
    flex-shrink: 0;
    transition: transform 0.3s ease, background-color 0.3s ease;
}

.tool-card:hover .tool-icon {
    transform: scale(1.1) rotate(-3deg);
}

.tool-card-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 0.75rem;
    transition: color 0.3s ease;
    line-height: 1.4;
}

.tool-card-description {
    color: var(--text-light);
    font-size: 0.9rem;
    line-height: 1.5;
}

/* ============================================================================
   动画
   ============================================================================ */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

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

/* ============================================================================
   工具 - 文字大小写转换
   ============================================================================ */
.conversion-controls {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin: 1rem 0;
}

/* ============================================================================
   主内容区域
   ============================================================================ */
.main-content {
    min-height: calc(100vh - 70px - 200px);
    padding: 3rem 0;
}

.tools-section {
    margin-bottom: 3rem;
}

.tools-section {
    padding: 3rem 0;
}

.tools-header {
    text-align: center;
    margin-bottom: 3.5rem;
}

.tools-header h2 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--primary-color), #667eea);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.tools-header p {
    font-size: 1.1rem;
    color: var(--text-light);
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.6;
}

.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2.5rem;
}

/* ============================================================================
   分类卡片
   ============================================================================ */
.category-card {
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    transition: var(--transition);
    cursor: pointer;
}

.category-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
    transform: translateY(-4px);
}

.category-card-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.category-card-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-color);
}

/* ============================================================================
   页脚
   ============================================================================ */
.footer {
    background-color: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 3rem 0 1rem;
    margin-top: 3rem;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.footer-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.footer-section h3,
.footer-section h4 {
    color: var(--text-color);
    margin-bottom: 0.5rem;
}

.footer-section a {
    color: var(--text-light);
    text-decoration: none;
    transition: color 0.2s;
}

.footer-section a:hover {
    color: var(--primary-color);
}

.footer-section p {
    color: var(--text-light);
}

.footer-bottom {
    border-top: 1px solid var(--border-color);
    padding-top: 1.5rem;
    text-align: center;
    color: var(--text-light);
    font-size: 0.9rem;
}

/* ============================================================================
   标签页导航
   ============================================================================ */
.tabs {
    display: flex;
    gap: 0.5rem;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 2rem;
}

.tab-button {
    padding: 0.75rem 1.5rem;
    border: none;
    background-color: transparent;
    color: var(--text-light);
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
}

.tab-button:hover {
    color: var(--primary-color);
}

.tab-button.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

/* ============================================================================
   网格布局工具类
   ============================================================================ */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

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

/* ============================================================================
   间距工具类
   ============================================================================ */
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.p-1 { padding: 0.5rem; }
.p-2 { padding: 1rem; }
.p-3 { padding: 1.5rem; }
.p-4 { padding: 2rem; }

/* ============================================================================
   文本对齐工具类
   ============================================================================ */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

/* ============================================================================
   显示和隐藏
   ============================================================================ */
.hidden {
    display: none !important;
}

.visible {
    display: block !important;
}

.invisible {
    visibility: hidden;
}

/* ============================================================================
   响应式设计
   ============================================================================ */
@media (max-width: 1024px) {
    .tools-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }

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

@media (max-width: 768px) {
    .nav {
        flex-wrap: wrap;
        height: auto;
        padding: 1rem 0;
    }

    .nav-links {
        margin: 0;
        gap: 1rem;
        margin-left: 0;
    }

    h1 { font-size: 2rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }

    .search-results {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }

    .notification {
        right: 10px;
        left: 10px;
        max-width: none;
        top: 10px;
    }

    .tools-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }

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

    .footer-content {
        grid-template-columns: 1fr;
    }

    .tabs {
        gap: 0;
        overflow-x: auto;
    }

    .tab-button {
        white-space: nowrap;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 0.75rem;
    }

    .nav-controls {
        gap: 0.5rem;
    }

    .btn-icon {
        width: 36px;
        height: 36px;
    }

    input,
    textarea,
    select {
        font-size: 16px; /* 防止iOS放大 */
    }

    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.25rem; }
    h3 { font-size: 1rem; }

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

    .tool-card {
        padding: 1rem;
    }

    .btn {
        width: 100%;
    }

    .notification {
        font-size: 0.9rem;
        padding: 1rem;
    }

    .main-content {
        padding: 1.5rem 0;
    }

    .footer {
        padding: 1.5rem 0 0.5rem;
    }
}
