﻿/* 全局样式 - 枫叶工坊（移动端优化版） */
/* 注：--bg, --card-bg, --text, --border, --primary, --radius 等基础变量统一在 style.css 中定义 */
:root {
    --text-light: #64748b;
    --accent: #8b5cf6;
    --shadow: 0 10px 25px -5px rgba(0,0,0,0.05);
    --card-hover: rgba(139,92,246,0.1);
    --nav-bg: rgba(255,255,255,0.85);
}

body.dark {
    --bg: #0f172a;
    --card-bg: rgba(30,41,59,0.9);
    --text: #f1f5f9;
    --text-light: #94a3b8;
    --border: rgba(255,255,255,0.1);
    --primary: #60a5fa;
    --accent: #a78bfa;
    --nav-bg: rgba(30,41,59,0.9);
}

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

body {
    background: var(--bg);
    color: var(--text);
    transition: background 0.2s, color 0.2s;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding-top: 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    flex: 1;
    width: 100%;
}

.navbar {
    background: var(--nav-bg);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 10px 24px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: 0;
}

.navbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: flex-start;
}

.menu-toggle {
    display: none;
    font-size: 1.8rem;
    cursor: pointer;
    color: var(--text);
    background: transparent;
    border: none;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background 0.2s;
}
.menu-toggle:hover {
    background: rgba(0,0,0,0.05);
}

.logo-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

.logo-img {
    height: 36px;
    border-radius: 8px;
}

.site-title {
    display: flex;
    flex-direction: column;
}

.site-name {
    font-size: 20px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
    line-height: 1.2;
}

.site-subtitle {
    font-size: 0.7rem;
    color: var(--text-light);
    margin-top: 2px;
    letter-spacing: 0.5px;
}

.nav-links {
    display: flex;
    gap: 24px;
    align-items: center;
    flex-wrap: wrap;
}

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

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

.theme-toggle {
    background: rgba(59,130,246,0.12);
    border: none;
    padding: 8px 18px;
    border-radius: 40px;
    color: var(--primary);
    font-weight: 500;
    cursor: pointer;
    transition: 0.2s;
}

.theme-toggle:hover {
    background: rgba(139,92,246,0.2);
    color: var(--accent);
}

.btn {
    display: inline-block;
    padding: 0.5rem 1.2rem;
    border-radius: 40px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    text-decoration: none;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: opacity 0.2s, transform 0.1s;
}
.btn:hover {
    opacity: 0.9;
}
.btn-outline {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
    background-image: none;
}
.btn-outline:hover {
    background: rgba(59,130,246,0.1);
    opacity: 1;
}
.btn-small {
    display: inline-block;
    padding: 0.4rem 1rem;
    border-radius: 2rem;
    font-size: 0.8rem;
    font-weight: 500;
    text-decoration: none;
    transition: opacity 0.2s;
    cursor: pointer;
}
.btn-small:hover {
    opacity: 0.9;
}

.module-card, .card {
    background: var(--card-bg);
    backdrop-filter: blur(8px);
    border-radius: 28px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
}

.module-card:hover, .card:hover {
    transform: translateY(-6px);
    border-color: var(--accent);
    background: var(--card-hover);
}

.form-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}
.form-row label {
    width: 70px;
    text-align: right;
    font-weight: 500;
    flex-shrink: 0;
}
.input-wrapper {
    flex: 1;
}
.input-wrapper input,
.input-wrapper select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font-size: 0.9rem;
}
.code-row {
    display: flex;
    gap: 8px;
    align-items: center;
}
.code-row input {
    flex: 1;
    min-width: 0;
}
.code-row button {
    flex-shrink: 0;
    white-space: nowrap;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    justify-content: center;
    align-items: center;
    z-index: 1100;
}
.modal-content {
    background: var(--card-bg);
    border-radius: 48px;
    padding: 30px;
    max-width: 450px;
    width: 90%;
    border: 1px solid var(--border);
    text-align: center;
}
.close-modal, .close-qr {
    float: right;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-light);
}
.tab-buttons {
    display: flex;
    gap: 15px;
    margin: 20px 0;
    border-bottom: 1px solid var(--border);
}
.tab {
    padding: 8px 20px;
    cursor: pointer;
    color: var(--text-light);
}
.tab.active {
    color: var(--primary);
    border-bottom: 2px solid var(--primary);
}
.form-pane {
    display: none;
}
.form-pane.active {
    display: block;
}
.error-msg {
    background: #fee;
    color: #c00;
    padding: 8px;
    border-radius: 16px;
    margin-bottom: 15px;
    display: none;
}

.custom-toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: #4caf50;
    color: white;
    padding: 12px 24px;
    border-radius: 60px;
    font-family: 'Inter', 'Segoe UI Emoji', sans-serif;
    font-size: 0.9rem;
    font-weight: 500;
    z-index: 2000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    animation: fadeInUp 0.2s ease;
}
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.floating-leaf-wrapper {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}
.leaf-bubble {
    background: rgba(255, 255, 255, 0.96);
    border-radius: 28px;
    padding: 8px 18px;
    max-width: 220px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
    position: absolute;
    bottom: 50%;
    right: 100%;
    margin-right: 12px;
    transform: translateY(50%);
    white-space: nowrap;
    backdrop-filter: blur(8px);
    border: 1px solid rgba(0, 0, 0, 0.06);
    font-family: 'Inter', 'Segoe UI Emoji', sans-serif;
    font-size: 14px;
    font-weight: 500;
    color: #2c3e50;
    text-align: center;
}
.bubble-tail {
    position: absolute;
    top: 50%;
    right: -10px;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 10px solid transparent;
    border-bottom: 10px solid transparent;
    border-left: 12px solid rgba(255, 255, 255, 0.96);
    filter: drop-shadow(2px 0 2px rgba(0, 0, 0, 0.08));
}
.floating-leaf {
    width: 100px;
    height: 100px;
    background: linear-gradient(135deg, #ffb347, #ff8c00);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(2px);
    overflow: hidden;
    transition: none;
}
.floating-leaf:hover {
    animation-play-state: paused !important;
    transform: none !important;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}
.leaf-emoji {
    font-size: 60px;
}
.floating-leaf img {
    width: 80%;
    height: 80%;
    object-fit: contain;
}
@keyframes leafFloat {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-12px); }
    100% { transform: translateY(0px); }
}
@keyframes leafRotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
@keyframes leafBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-16px); }
}
.float { animation: leafFloat 3s ease-in-out infinite; }
.rotate { animation: leafRotate 4s linear infinite; }
.bounce { animation: leafBounce 1s ease-in-out infinite; }

.leaf-menu {
    position: absolute;
    bottom: 0;
    right: 100%;
    margin-right: 12px;
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    border-radius: 28px;
    padding: 12px 0;
    min-width: 180px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    display: none;
    flex-direction: column;
    transition: opacity 0.2s;
}
.leaf-menu a {
    display: block;
    padding: 10px 20px;
    color: var(--text);
    text-decoration: none;
    transition: background 0.2s, color 0.2s;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
}
.leaf-menu a:hover {
    background: rgba(139, 92, 246, 0.15);
    color: var(--accent);
}
.leaf-menu hr {
    margin: 6px 0;
    border-color: var(--border);
}

.footer {
    background: var(--card-bg);
    border-top: 1px solid var(--border);
    padding: 1.5rem;
    text-align: center;
    color: var(--text-light);
    margin-top: 0;
    width: 100%;
}

/* ========== 移动端全局美化 ========== */
@media (max-width: 768px) {
    body {
        padding-top: 60px;
    }
    .navbar {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 8px 16px;
    }
    .navbar-left {
        justify-content: flex-start;
    }
    .menu-toggle {
        display: flex;
    }
    .logo-img {
        height: 28px;
    }
    .site-name {
        font-size: 16px;
    }
    .site-subtitle {
        font-size: 0.6rem;
    }
    .nav-links {
        position: absolute;
        top: 100%;
        left: 0;
        width: 50%;
        background: var(--nav-bg);
        backdrop-filter: blur(12px);
        border-radius: 0 0 1rem 1rem;
        padding: 0.5rem;
        margin-top: 0;
        gap: 8px;
        border: 1px solid var(--border);
        border-top: none;
        z-index: 999;
        display: none;
        flex-direction: column;
    }
    .nav-links.open {
        display: flex;
    }
    .nav-links a,
    .nav-links button {
        width: 100%;
        text-align: center;
        padding: 0.6rem 0.5rem;
        border-radius: 2rem;
        background: transparent;
        justify-content: center;
        font-size: 0.8rem;
    }
    .floating-leaf-wrapper {
        display: none !important;
    }
    .container {
        padding: 1rem;
    }
    .module-card, .card {
        padding: 1rem;
        border-radius: 20px;
    }
    .form-row {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }
    .form-row label {
        width: auto;
        text-align: left;
    }
    .modal-content {
        padding: 20px;
        border-radius: 32px;
    }
    /* 修复搜索框溢出问题 */
    .search-wrapper {
        width: 100%;
        max-width: 100%;
        margin: 0 auto 1rem;
    }
    .search-container {
        display: flex;
        flex-wrap: nowrap;
        align-items: center;
        background: var(--card-bg);
        border-radius: 3rem;
        padding: 0.2rem 0.2rem 0.2rem 1rem;
        box-shadow: 0 2px 8px rgba(0,0,0,0.08);
        border: 1px solid var(--border);
        width: 100%;
        overflow: hidden;
    }
    .search-engine-select {
        flex-shrink: 0;
        padding-right: 0.5rem;
        border-right: 1px solid var(--border);
    }
    .engine-dropdown {
        font-size: 0.8rem;
        padding: 0.3rem 0.1rem;
    }
    .search-input {
        flex: 1;
        min-width: 0;
        padding: 0.6rem 0.3rem;
        font-size: 0.9rem;
    }
    .search-btn {
        flex-shrink: 0;
        padding: 0.3rem 0.8rem;
        font-size: 0.8rem;
        white-space: nowrap;
    }
    /* 移动端首页卡片强制 60x60 正方形 */
    .dashboard-card-wrapper {
        width: 60px;
        margin: 0 auto;
    }
    .dashboard-card-wrapper .dashboard-item {
        width: 60px;
        height: 60px !important;
        aspect-ratio: 1 / 1;
    }
    .dashboard-card-wrapper .item-icon {
        width: 36px;
        height: 36px;
    }
    .dashboard-card-wrapper .icon-placeholder {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }
    .dashboard-card-wrapper .item-title-outside {
        font-size: 0.6rem;
        margin-top: 0.2rem;
    }
    .dashboard-grid {
        grid-template-columns: repeat(auto-fill, 60px) !important;
        justify-content: center;
        gap: 12px;
    }
    .modules-grid, .tools-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }
    .datetime-time {
        font-size: 2.2rem !important;
    }
    table, thead, tbody, th, td, tr {
        display: block;
    }
    thead {
        display: none;
    }
    tr {
        margin-bottom: 0.8rem;
        border: 1px solid var(--border);
        border-radius: 1rem;
        padding: 0.5rem;
    }
    td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.5rem;
        border-bottom: 1px dashed var(--border);
    }
    td:before {
        content: attr(data-label);
        font-weight: 600;
        width: 35%;
        font-size: 0.8rem;
        color: var(--text-light);
    }
}

/* 桌面端保持原有样式 */
@media (min-width: 769px) {
    .menu-toggle {
        display: none;
    }
    .nav-links {
        display: flex !important;
        flex-direction: row;
    }
}