/*
 * 统一工具页主题 - Liquid Glass 特效版
 * ================================
 * 供所有工具子页面使用，与首页 index.html 视觉统一
 *
 * 设计语言：
 * 1. 全局动态背景光斑
 * 2. 玻璃态卡片
 * 3. 全局动效系统
 * 4. 统一顶部导航
 */

/* ========================================
   工具页主题变量
   ======================================== */

body {
    /* 核心色板 */
    --tool-bg: #09090b;
    --tool-bg-alt: #18181b;
    --tool-bg-elevated: #27272a;
    --tool-surface: rgba(255, 255, 255, 0.03);
    --tool-surface-hover: rgba(255, 255, 255, 0.06);
    --tool-border: rgba(255, 255, 255, 0.08);
    --tool-border-hover: rgba(255, 255, 255, 0.15);
    --tool-fg: #fafafa;
    --tool-fg-dim: #a1a1aa;
    --tool-fg-muted: #71717a;

    /* 强调色 */
    --tool-accent: #a78bfa;
    --tool-accent-glow: rgba(167, 139, 250, 0.4);
    --tool-accent-2: #22d3ee;
    --tool-accent-2-glow: rgba(34, 211, 238, 0.4);
    --tool-accent-3: #f472b6;
    --tool-accent-3-glow: rgba(244, 114, 182, 0.4);

    /* 玻璃效果 */
    --tool-glass-bg: rgba(255, 255, 255, 0.02);
    --tool-glass-border: rgba(255, 255, 255, 0.06);
    --tool-glass-blur: 20px;

    /* 动效参数 */
    --tool-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --tool-ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --tool-duration-fast: 150ms;
    --tool-duration-normal: 250ms;
    --tool-duration-slow: 400ms;
}

/* ========================================
   基础布局
   ======================================== */

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif;
    font-size: 14px;
    line-height: 1.5;
    background: var(--tool-bg);
    color: var(--tool-fg);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    position: relative;
    overflow-x: hidden;
}

/* 全局动态背景 */
body {
    background:
        radial-gradient(ellipse 80% 50% at 20% 40%, rgba(167, 139, 250, 0.12) 0%, transparent 50%),
        radial-gradient(ellipse 60% 40% at 80% 60%, rgba(34, 211, 238, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse 50% 30% at 50% 80%, rgba(244, 114, 182, 0.06) 0%, transparent 50%),
        var(--tool-bg);
}

/* 动态光斑容器 */
.bg-orbs {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.5;
    animation: orb-float 20s ease-in-out infinite;
}

.orb-1 {
    width: 400px;
    height: 400px;
    background: var(--tool-accent-glow);
    top: -100px;
    left: -100px;
    animation-delay: 0s;
}

.orb-2 {
    width: 300px;
    height: 300px;
    background: var(--tool-accent-2-glow);
    top: 50%;
    right: -50px;
    animation-delay: -5s;
}

.orb-3 {
    width: 350px;
    height: 350px;
    background: rgba(244, 114, 182, 0.3);
    bottom: -100px;
    left: 30%;
    animation-delay: -10s;
}

@keyframes orb-float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(30px, -30px) scale(1.05); }
    50% { transform: translate(-20px, 20px) scale(0.95); }
    75% { transform: translate(20px, 30px) scale(1.02); }
}

/* 网格纹理 */
.grid-pattern {
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    background-size: 60px 60px;
    pointer-events: none;
    z-index: 0;
}

/* ========================================
   顶部导航
   ======================================== */

body .top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5vw 2vw;
    position: relative;
    z-index: 10;
}

body .back-btn {
    display: flex;
    align-items: center;
    gap: 0.5vw;
    color: var(--tool-fg-dim);
    text-decoration: none;
    font-size: 0.9rem;
    padding: 0.6vw 1.2vw;
    border-radius: 10px;
    background: var(--tool-glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--tool-border);
    transition: all var(--tool-duration-fast) ease;
    cursor: pointer;
}

body .back-btn:hover {
    color: var(--tool-fg);
    background: var(--tool-surface-hover);
    border-color: var(--tool-accent);
    box-shadow: 0 0 20px var(--tool-accent-glow);
    transform: translateX(-2px);
}

body .back-btn svg {
    width: 18px;
    height: 18px;
}

body .nav-brand {
    display: flex;
    align-items: center;
    gap: 0.8vw;
}

body .brand-icon {
    font-size: 1.5rem;
    filter: drop-shadow(0 0 10px var(--tool-accent-glow));
}

body .brand-text {
    font-size: 1.1rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--tool-accent), var(--tool-accent-2));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ========================================
   主内容区
   ======================================== */

body .tool-main {
    position: relative;
    z-index: 1;
    padding: 2vw;
    max-width: 1200px;
    margin: 0 auto;
}

/* ========================================
   工具容器
   ======================================== */

body .tool-container {
    background: var(--tool-glass-bg);
    backdrop-filter: blur(var(--tool-glass-blur));
    -webkit-backdrop-filter: blur(var(--tool-glass-blur));
    border: 1px solid var(--tool-glass-border);
    border-radius: 20px;
    padding: 2vw;
    animation: container-enter var(--tool-duration-slow) var(--tool-ease-out) forwards;
    opacity: 0;
    transform: translateY(20px);
}

@keyframes container-enter {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
   工具头部
   ======================================== */

body .tool-header {
    margin-bottom: 2vw;
    padding-bottom: 1.5vw;
    border-bottom: 1px solid var(--tool-border);
}

body .tool-header h1 {
    font-size: 1.8rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin: 0 0 0.5vw 0;
    background: linear-gradient(135deg, var(--tool-fg), var(--tool-fg-dim));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

body .tool-header p {
    color: var(--tool-fg-dim);
    margin: 0;
    font-size: 0.95rem;
}

/* ========================================
   输入输出面板
   ======================================== */

body .input-output-container {
    display: flex;
    gap: 1.5vw;
    margin: 2vw 0;
}

body .panel {
    flex: 1;
    background: var(--tool-surface);
    border: 1px solid var(--tool-border);
    border-radius: 16px;
    padding: 1.5vw;
    transition: all var(--tool-duration-fast) ease;
}

body .panel:hover {
    border-color: var(--tool-border-hover);
}

body .panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1vw;
    padding-bottom: 1vw;
    border-bottom: 1px solid var(--tool-border);
}

body .panel-title {
    color: var(--tool-fg-dim);
    font-size: 0.85rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

body textarea {
    width: 100%;
    min-height: 25vw;
    resize: vertical;
    background: transparent;
    border: none;
    color: var(--tool-fg);
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.6;
}

body textarea:focus {
    outline: none;
}

/* ========================================
   按钮
   ======================================== */

body .btn,
body button,
body input[type="submit"],
body input[type="button"] {
    position: relative;
    background: var(--tool-glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--tool-glass-border);
    color: var(--tool-fg);
    padding: 0.7vw 1.8vw;
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    border-radius: 10px;
    transition: all var(--tool-duration-normal) var(--tool-ease-out);
    overflow: hidden;
}

/* 按钮光效 */
body .btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: left 0.5s ease;
}

body .btn:hover::before {
    left: 100%;
}

body .btn:hover,
body button:hover {
    background: var(--tool-surface-hover);
    border-color: var(--tool-accent);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

body .btn:active,
body button:active {
    transform: translateY(0) scale(0.98);
}

body .btn-primary {
    background: linear-gradient(135deg, var(--tool-accent), #8b5cf6);
    border-color: transparent;
    color: white;
}

body .btn-primary:hover {
    background: linear-gradient(135deg, #8b5cf6, var(--tool-accent));
    box-shadow: 0 8px 30px var(--tool-accent-glow);
}

/* ========================================
   表单元素
   ======================================== */

body input[type="text"],
body input[type="number"],
body input[type="password"],
body input[type="email"],
body input[type="url"],
body input[type="search"],
body input[type="date"],
body input[type="datetime-local"],
body select {
    background: var(--tool-glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--tool-glass-border);
    color: var(--tool-fg);
    font-family: inherit;
    font-size: inherit;
    padding: 0.8vw 1vw;
    width: 100%;
    border-radius: 10px;
    transition: all var(--tool-duration-fast) ease;
}

body input:focus,
body select:focus {
    outline: none;
    border-color: var(--tool-accent);
    box-shadow: 0 0 0 3px var(--tool-accent-glow);
}

body input::placeholder {
    color: var(--tool-fg-muted);
}

body select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' viewBox='0 0 24 24' stroke='%23a1a1aa'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1vw center;
    padding-right: 3vw;
}

body select option {
    background: var(--tool-bg-alt);
    color: var(--tool-fg);
}

/* ========================================
   消息提示
   ======================================== */

body .message {
    background: var(--tool-glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--tool-glass-border);
    color: var(--tool-fg);
    padding: 1vw 1.5vw;
    margin: 1.5vw 0;
    font-family: inherit;
    border-radius: 10px;
    animation: message-enter var(--tool-duration-normal) var(--tool-ease-out);
}

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

body .message-success {
    border-color: rgba(34, 197, 94, 0.3);
    background: rgba(34, 197, 94, 0.1);
}

body .message-error {
    border-color: rgba(239, 68, 68, 0.3);
    background: rgba(239, 68, 68, 0.1);
}

body .message-info {
    border-color: rgba(59, 130, 246, 0.3);
    background: rgba(59, 130, 246, 0.1);
}

/* ========================================
   结果显示
   ======================================== */

body .result {
    background: var(--tool-glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--tool-accent);
    padding: 1.5vw;
    margin: 1.5vw 0;
    border-radius: 12px;
    box-shadow: 0 0 30px var(--tool-accent-glow);
}

/* ========================================
   页脚
   ======================================== */

body footer {
    background: transparent;
    color: var(--tool-fg-muted);
    border-top: 1px solid var(--tool-border);
    padding: 2.5vw 0;
    margin-top: 3vw;
    font-size: 0.8rem;
    position: relative;
    z-index: 1;
}

body .footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1vw;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2vw;
}

body .footer-content p {
    margin: 0;
    opacity: 0.6;
}

/* ========================================
   滚动条
   ======================================== */

body ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

body ::-webkit-scrollbar-track {
    background: transparent;
}

body ::-webkit-scrollbar-thumb {
    background: var(--tool-border-hover);
    border-radius: 4px;
}

body ::-webkit-scrollbar-thumb:hover {
    background: var(--tool-fg-muted);
}

/* ========================================
   文本选择
   ======================================== */

body ::selection {
    background: var(--tool-accent);
    color: white;
}

/* ========================================
   减少动画
   ======================================== */

@media (prefers-reduced-motion: reduce) {
    body *,
    body *::before,
    body *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ========================================
   统一工具页顶栏
   ======================================== */

body .tool-header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.2vw 2vw;
    background: var(--tool-glass-bg);
    backdrop-filter: blur(var(--tool-glass-blur));
    -webkit-backdrop-filter: blur(var(--tool-glass-blur));
    border: 1px solid var(--tool-glass-border);
    border-radius: 14px;
    margin-bottom: 1.5vw;
    position: relative;
    z-index: 10;
}

body .tool-header-bar .back-btn {
    display: flex;
    align-items: center;
    gap: 0.5vw;
    color: var(--tool-fg-dim);
    text-decoration: none;
    font-size: 0.9rem;
    padding: 0.5vw 1vw;
    border-radius: 8px;
    background: var(--tool-surface);
    border: 1px solid var(--tool-border);
    transition: all var(--tool-duration-fast) ease;
    cursor: pointer;
}

body .tool-header-bar .back-btn:hover {
    color: var(--tool-fg);
    background: var(--tool-surface-hover);
    border-color: var(--tool-accent);
    box-shadow: 0 0 15px var(--tool-accent-glow);
}

body .tool-header-bar .back-btn svg {
    width: 18px;
    height: 18px;
}

body .tool-header-bar .tool-title {
    display: flex;
    align-items: center;
    gap: 0.8vw;
}

body .tool-header-bar .tool-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--tool-accent), var(--tool-accent-2));
    border-radius: 8px;
    filter: drop-shadow(0 0 8px var(--tool-accent-glow));
}

body .tool-header-bar .tool-icon svg {
    width: 18px;
    height: 18px;
    color: white;
}

body .tool-header-bar .tool-name {
    font-size: 1.1rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--tool-fg), var(--tool-fg-dim));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

body .tool-header-bar .tool-desc {
    color: var(--tool-fg-muted);
    font-size: 0.85rem;
    margin-left: auto;
    margin-right: 1vw;
}

/* ========================================
   面板切换动画
   ======================================== */

body .panel {
    transition: all var(--tool-duration-normal) var(--tool-ease-out);
}

body .panel.fade-out {
    opacity: 0;
    transform: translateY(10px);
}

body .panel.fade-in {
    animation: panel-enter var(--tool-duration-normal) var(--tool-ease-out) forwards;
}

@keyframes panel-enter {
    from {
        opacity: 0;
        transform: translateY(15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
   折叠面板
   ======================================== */

body .collapsible-panel {
    overflow: hidden;
    transition: all var(--tool-duration-normal) var(--tool-ease-out);
}

body .collapsible-panel.collapsed {
    max-height: 0 !important;
    opacity: 0;
    margin: 0;
    padding: 0;
}

body .collapsible-panel.expanded {
    max-height: 500px;
    opacity: 1;
}

/* ========================================
   操作栏
   ======================================== */

body .action-bar {
    display: flex;
    gap: 0.8vw;
    padding: 1vw 0;
    margin-top: 1vw;
    border-top: 1px solid var(--tool-border);
    flex-wrap: wrap;
}

body .action-bar .btn {
    flex: 1;
    min-width: 120px;
    justify-content: center;
}

/* ========================================
   响应式
   ======================================== */

@media (max-width: 768px) {
    body {
        font-size: 14px;
    }

    body .tool-header-bar {
        padding: 12px 16px;
        border-radius: 12px;
        margin-bottom: 16px;
    }

    body .tool-header-bar .back-btn {
        padding: 8px 12px;
        font-size: 0.85rem;
    }

    body .tool-header-bar .tool-desc {
        display: none;
    }

    body .tool-main {
        padding: 16px;
    }

    body .tool-container {
        padding: 16px;
        border-radius: 16px;
    }

    body .tool-header h1 {
        font-size: 1.4rem;
    }

    body .input-output-container {
        flex-direction: column;
        gap: 16px;
    }

    body textarea {
        min-height: 200px;
    }

    body .panel {
        padding: 12px;
    }

    body .action-bar {
        flex-direction: column;
    }

    body .action-bar .btn {
        width: 100%;
    }

    body .footer-content {
        flex-direction: column;
        text-align: center;
        padding: 0 16px;
    }
}

/* ========================================
   Light Mode 变量覆盖
   ======================================== */

body[data-theme="light"] {
    --tool-bg: #f8f9fc;
    --tool-bg-alt: #eef0f5;
    --tool-bg-elevated: #ffffff;
    --tool-surface: rgba(255, 255, 255, 0.7);
    --tool-surface-hover: rgba(167, 139, 250, 0.08);
    --tool-border: rgba(0, 0, 0, 0.08);
    --tool-border-hover: rgba(167, 139, 250, 0.3);
    --tool-fg: #1a1a2e;
    --tool-fg-dim: #4a4a6a;
    --tool-fg-muted: #8888aa;

    --tool-accent: #7c5bf5;
    --tool-accent-glow: rgba(124, 91, 245, 0.3);
    --tool-accent-2: #06b6d4;
    --tool-accent-2-glow: rgba(6, 182, 212, 0.3);
    --tool-accent-3: #ec4899;
    --tool-accent-3-glow: rgba(236, 72, 153, 0.3);

    --tool-glass-bg: rgba(255, 255, 255, 0.5);
    --tool-glass-border: rgba(167, 139, 250, 0.2);
    --tool-glass-blur: 16px;
}
