/* ============================================================
   随机数生成器 - 样式表
   设计风格：Glassmorphism + 渐变背景 + 流畅动效
   ============================================================ */

/* --- CSS 变量 --- */
:root {
    --bg-primary: #0a0a1a;
    --bg-secondary: #111133;
    --glass-bg: rgba(255, 255, 255, 0.04);
    --glass-border: rgba(255, 255, 255, 0.10);
    --glass-hover: rgba(255, 255, 255, 0.08);
    --glass-bg-solid: rgba(20, 20, 50, 0.7);
    --input-bg: rgba(255, 255, 255, 0.05);
    --input-bg-focus: rgba(255, 255, 255, 0.08);
    --text-primary: #e8e8f0;
    --text-secondary: #a0a0c0;
    --text-muted: #6a6a8a;
    --accent-1: #6c5ce7;
    --accent-2: #a855f7;
    --accent-3: #06b6d4;
    --accent-gradient: linear-gradient(135deg, #6c5ce7, #a855f7, #06b6d4);
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --radius-sm: 8px;
    --radius: 14px;
    --radius-lg: 20px;
    --radius-xl: 24px;
    --shadow-glow: 0 0 30px rgba(108, 92, 231, 0.3);
    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.3);
    --transition-fast: 0.15s ease;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    --font-mono: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', 'Consolas', 'Monaco', monospace;
    --particle-color: 250, 70%, 65%;
    --particle-line: rgba(108, 92, 231, 0.06);
    --toast-bg: rgba(30, 30, 60, 0.95);
    --result-bg: rgba(255, 255, 255, 0.04);
    --result-hover-bg: rgba(108, 92, 231, 0.15);
    --stat-bg: rgba(255, 255, 255, 0.03);
    --info-box-bg: rgba(6, 182, 212, 0.08);
    --info-box-border: rgba(6, 182, 212, 0.2);
}

/* --- 明亮模式 --- */
[data-theme="light"] {
    --bg-primary: #f0f2f8;
    --bg-secondary: #e4e7f0;
    --glass-bg: rgba(255, 255, 255, 0.55);
    --glass-border: rgba(0, 0, 0, 0.10);
    --glass-hover: rgba(0, 0, 0, 0.04);
    --glass-bg-solid: rgba(255, 255, 255, 0.8);
    --input-bg: rgba(0, 0, 0, 0.04);
    --input-bg-focus: rgba(0, 0, 0, 0.06);
    --text-primary: #1a1a3e;
    --text-secondary: #5a5a80;
    --text-muted: #9090b0;
    --shadow-glow: 0 0 30px rgba(108, 92, 231, 0.2);
    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.08);
    --particle-color: 250, 50%, 55%;
    --particle-line: rgba(108, 92, 231, 0.08);
    --toast-bg: rgba(255, 255, 255, 0.95);
    --result-bg: rgba(0, 0, 0, 0.03);
    --result-hover-bg: rgba(108, 92, 231, 0.1);
    --stat-bg: rgba(0, 0, 0, 0.03);
    --info-box-bg: rgba(6, 182, 212, 0.06);
    --info-box-border: rgba(6, 182, 212, 0.25);
}

/* --- 全局过渡（主题切换平滑） --- */
body, .card, .mode-tab, .param-group input, .stepper-btn,
.toggle-btn, .btn-sm, .result-item, .toast, .info-box,
.results-stats, .histogram-bar, .theme-toggle {
    transition: background-color 0.4s ease, color 0.4s ease,
                border-color 0.4s ease, box-shadow 0.4s ease;
}

/* --- 全局重置 --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

/* --- 粒子背景 --- */
#particlesCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

/* --- 容器 --- */
.container {
    position: relative;
    z-index: 1;
    max-width: 900px;
    margin: 0 auto;
    padding: 20px 24px 60px;
}

/* --- 头部 --- */
.header {
    position: relative;
    text-align: center;
    padding: 40px 0 30px;
    animation: fadeInDown 0.8s ease;
}

.logo-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    color: var(--accent-2);
    filter: drop-shadow(0 0 12px rgba(168, 85, 247, 0.5));
    animation: floatIcon 3s ease-in-out infinite;
}

.logo-icon svg {
    width: 100%;
    height: 100%;
}

.header h1 {
    font-size: 2.4rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 0.02em;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-top: 6px;
    letter-spacing: 0.04em;
}

/* --- 主题切换按钮 --- */
.theme-toggle {
    position: absolute;
    top: 16px;
    right: 0;
    width: 44px;
    height: 44px;
    border: 1px solid var(--glass-border);
    border-radius: 50%;
    background: var(--glass-bg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 10;
}

.theme-toggle:hover {
    border-color: var(--accent-1);
    box-shadow: 0 0 16px rgba(108, 92, 231, 0.25);
    transform: rotate(20deg);
}

.theme-toggle .theme-icon-dark,
.theme-toggle .theme-icon-light {
    transition: opacity 0.3s ease, transform 0.4s ease;
}

/* 黑暗模式：显示月亮，隐藏太阳 */
[data-theme="light"] .theme-icon-dark,
.theme-icon-light {
    display: none;
}

/* 明亮模式：显示太阳，隐藏月亮 */
[data-theme="light"] .theme-icon-light,
.theme-icon-dark {
    display: inline;
}

/* --- 卡片 --- */
.card {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-card);
    transition: border-color var(--transition), box-shadow var(--transition);
    animation: fadeInUp 0.6s ease both;
    overflow: hidden;
}

.card:hover {
    border-color: rgba(128, 128, 160, 0.2);
}

/* --- 模式选择器 --- */
.mode-selector {
    padding: 8px;
    overflow-x: auto;
}

.mode-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: nowrap;
}

.mode-tab {
    flex: 1;
    min-width: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 14px 10px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
    white-space: nowrap;
}

.mode-tab:hover {
    background: var(--glass-hover);
    color: var(--text-primary);
    transform: translateY(-2px);
}

.mode-tab.active {
    background: rgba(108, 92, 231, 0.15);
    border-color: rgba(108, 92, 231, 0.5);
    color: var(--text-primary);
    box-shadow: 0 0 20px rgba(108, 92, 231, 0.2);
}

.mode-tab .tab-icon {
    font-size: 1.6rem;
    transition: transform var(--transition);
}

.mode-tab.active .tab-icon {
    transform: scale(1.1);
}

.mode-tab .tab-label {
    font-size: 0.95rem;
    font-weight: 600;
}

.mode-tab .tab-desc {
    font-size: 0.72rem;
    opacity: 0.6;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* --- 参数面板 --- */
.params-panel {
    animation-delay: 0.15s;
}

.params-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.params-row:last-child {
    margin-bottom: 0;
}

.common-params {
    padding-bottom: 16px;
    border-bottom: 1px solid var(--glass-border);
    margin-bottom: 16px;
}

.param-group {
    flex: 1;
    min-width: 140px;
}

.param-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.param-hint {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: none;
}

.param-group input[type="number"] {
    width: 100%;
    padding: 10px 14px;
    background: var(--input-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: var(--font-mono);
    transition: all var(--transition-fast);
    outline: none;
}

.param-group input[type="number"]:focus {
    border-color: var(--accent-1);
    box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.15);
    background: var(--input-bg-focus);
}

.param-group input[type="number"]::placeholder {
    color: var(--text-muted);
    font-family: inherit;
}

/* --- 步进器 --- */
.input-stepper {
    display: flex;
    align-items: center;
    gap: 0;
}

.input-stepper input {
    text-align: center;
    border-radius: 0 !important;
    flex: 1;
    min-width: 0;
    -moz-appearance: textfield;
}

.input-stepper input::-webkit-outer-spin-button,
.input-stepper input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.stepper-btn {
    width: 36px;
    height: 42px;
    border: 1px solid var(--glass-border);
    background: var(--input-bg);
    color: var(--text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stepper-btn:first-child {
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.stepper-btn:last-child {
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.stepper-btn:hover {
    background: rgba(108, 92, 231, 0.2);
    color: var(--accent-2);
    border-color: var(--accent-1);
}

.stepper-btn:active {
    background: rgba(108, 92, 231, 0.35);
}

/* --- 切换组 --- */
.toggle-group {
    display: flex;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--glass-border);
}

.toggle-btn {
    flex: 1;
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    font-family: inherit;
    transition: all var(--transition-fast);
    font-weight: 500;
}

.toggle-btn:first-child {
    border-right: 1px solid var(--glass-border);
}

.toggle-btn.active {
    background: rgba(108, 92, 231, 0.3);
    color: var(--text-primary);
    font-weight: 600;
}

.toggle-btn:hover:not(.active) {
    background: var(--glass-hover);
}

/* --- 模式参数显示控制 --- */
.mode-params {
    display: none;
    animation: fadeIn 0.3s ease;
}

.mode-params.active {
    display: block;
}

/* --- 信息框 --- */
.info-box {
    background: var(--info-box-bg);
    border: 1px solid var(--info-box-border);
    border-radius: var(--radius);
    padding: 16px 20px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.7;
}

.info-box strong {
    color: var(--accent-3);
}

.formula {
    font-family: var(--font-mono);
    font-size: 1.05rem;
    color: var(--accent-2);
    text-align: center;
    padding: 8px 0;
    font-weight: 600;
}

/* --- 生成按钮 --- */
.generate-section {
    text-align: center;
    padding: 10px 0;
    animation: fadeInUp 0.6s ease 0.25s both;
}

.btn-generate {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 16px 48px;
    font-size: 1.15rem;
    font-weight: 700;
    font-family: inherit;
    color: #fff;
    background: var(--accent-gradient);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: var(--shadow-glow);
    transition: all var(--transition);
    overflow: hidden;
    letter-spacing: 0.02em;
}

.btn-generate:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 40px rgba(108, 92, 231, 0.5);
}

.btn-generate:active {
    transform: scale(0.97);
}

.btn-generate .btn-icon {
    font-size: 1.3rem;
}

/* 波纹效果 */
.btn-ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: scale(0);
    animation: ripple 0.6s linear;
    pointer-events: none;
}

@keyframes ripple {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* --- 小按钮 --- */
.btn-sm {
    padding: 7px 14px;
    font-size: 0.82rem;
    font-family: inherit;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    background: var(--glass-bg);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-weight: 500;
}

.btn-sm:hover {
    background: var(--glass-hover);
    color: var(--text-primary);
    border-color: rgba(128, 128, 160, 0.3);
}

/* --- 结果面板 --- */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}

.results-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.results-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.results-stats {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 14px;
    padding: 10px 14px;
    background: var(--stat-bg);
    border-radius: var(--radius-sm);
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.results-stats span {
    white-space: nowrap;
}

.results-stats strong {
    color: var(--accent-2);
}

/* --- 结果网格 --- */
.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 4px;
}

.results-grid::-webkit-scrollbar {
    width: 4px;
}

.results-grid::-webkit-scrollbar-track {
    background: transparent;
}

.results-grid::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

.result-item {
    background: var(--result-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 12px 10px;
    text-align: center;
    font-family: var(--font-mono);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    transition: all var(--transition);
    cursor: pointer;
    position: relative;
    animation: popIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
    user-select: all;
}

.result-item:hover {
    background: var(--result-hover-bg);
    border-color: rgba(108, 92, 231, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.result-item:active {
    transform: scale(0.95);
}

.result-item.copied::after {
    content: '已复制!';
    position: absolute;
    top: -28px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--success);
    color: #fff;
    font-size: 0.7rem;
    padding: 3px 10px;
    border-radius: 20px;
    font-family: inherit;
    animation: fadeInOut 1.2s ease forwards;
    pointer-events: none;
    white-space: nowrap;
}

/* --- 直方图 --- */
.histogram-container {
    height: 250px;
    display: flex;
    align-items: flex-end;
    gap: 2px;
    padding: 20px 0 0;
    position: relative;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(128, 128, 160, 0.3) transparent;
}

.histogram-container::-webkit-scrollbar {
    height: 4px;
}

.histogram-container::-webkit-scrollbar-track {
    background: transparent;
}

.histogram-container::-webkit-scrollbar-thumb {
    background: rgba(128, 128, 160, 0.3);
    border-radius: 2px;
}

.histogram-bar-wrap {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    justify-content: flex-end;
    min-width: 28px;
    max-width: 48px;
}

.histogram-bar {
    width: 100%;
    background: var(--accent-gradient);
    border-radius: 4px 4px 0 0;
    transition: height var(--transition);
    min-height: 2px;
    position: relative;
}

.histogram-bar-label {
    font-size: 0.6rem;
    color: var(--text-muted);
    margin-top: 4px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    line-height: 1.2;
}

/* --- 动画关键帧 --- */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInOut {
    0% { opacity: 0; transform: translateX(-50%) translateY(5px); }
    20% { opacity: 1; transform: translateX(-50%) translateY(0); }
    80% { opacity: 1; transform: translateX(-50%) translateY(0); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-5px); }
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: scale(0.5);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes floatIcon {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 20px rgba(108, 92, 231, 0.3); }
    50% { box-shadow: 0 0 35px rgba(108, 92, 231, 0.5); }
}

/* --- Toast 提示 --- */
.toast {
    display: none;
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--toast-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 12px 28px;
    border-radius: 50px;
    font-size: 0.9rem;
    z-index: 999;
    font-weight: 500;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    pointer-events: none;
    white-space: nowrap;
    animation: fadeInOut 2.5s ease forwards;
}

/* --- 响应式 --- */
@media (max-width: 768px) {
    .container {
        padding: 12px 12px 40px;
    }

    .header h1 {
        font-size: 1.6rem;
    }

    .mode-tabs {
        flex-wrap: wrap;
    }

    .mode-tab {
        flex: 1 0 calc(33.33% - 6px);
        min-width: 90px;
        padding: 12px 6px;
    }

    .params-row {
        flex-direction: column;
        gap: 10px;
    }

    .param-group {
        min-width: 100%;
    }

    .btn-generate {
        padding: 14px 36px;
        font-size: 1rem;
    }

    .results-grid {
        grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
        gap: 6px;
    }

    .results-stats {
        flex-direction: column;
        gap: 4px;
    }
}

@media (max-width: 480px) {
    .mode-tab {
        flex: 1 0 calc(50% - 4px);
        min-width: 0;
    }

    .results-actions {
        width: 100%;
    }

    .results-actions .btn-sm {
        flex: 1;
        text-align: center;
    }
}
