/* 葫芦侠工具箱 V3.1 - 重构版样式 */

:root {
    --primary: #0ea5e9;
    --primary-light: #38bdf8;
    --primary-soft: rgba(14, 165, 233, 0.1);
    --secondary: #64748b;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --bg-body: #f1f5f9;
    --bg-card: #ffffff;
    --bg-sidebar: #0f172a;
    --bg-sidebar-hover: #1e293b;
    --text-main: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-sidebar: #cbd5e1;
    --text-sidebar-active: #ffffff;
    --sidebar-width: 240px;
    --radius-lg: 12px;
    --radius-md: 8px;
    --shadow-soft: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-card: 0 1px 8px rgba(0,0,0,0.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg-body);
    color: var(--text-main);
    line-height: 1.6;
    display: flex;
    min-height: 100vh;
}

/* ========== 侧边栏 ========== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    color: var(--text-sidebar);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: #fff;
}

.brand-icon {
    width: 36px;
    height: 36px;
    background: var(--primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.brand-name {
    font-weight: 700;
    font-size: 1rem;
    display: block;
    line-height: 1.2;
}

.brand-version {
    font-size: 0.7rem;
    color: var(--text-muted);
    background: rgba(255,255,255,0.08);
    padding: 1px 6px;
    border-radius: 4px;
}

/* 导航区 */
.sidebar-nav {
    flex: 1;
    padding: 12px 0;
}

.nav-section {
    padding: 0 12px;
    margin-bottom: 8px;
}

.nav-section-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    padding: 12px 12px 6px;
    font-weight: 600;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-sidebar);
    font-size: 0.88rem;
    transition: all 0.15s;
    margin-bottom: 2px;
}

.nav-link:hover {
    background: var(--bg-sidebar-hover);
    color: #fff;
}

.nav-link.active {
    background: var(--primary);
    color: var(--text-sidebar-active);
    box-shadow: 0 2px 8px rgba(14, 165, 233, 0.3);
}

.nav-link i {
    width: 18px;
    text-align: center;
    font-size: 0.9rem;
    opacity: 0.8;
}

.nav-link.active i { opacity: 1; }

.nav-badge {
    margin-left: auto;
    font-size: 0.65rem;
    padding: 1px 6px;
    border-radius: 4px;
    background: rgba(245, 158, 11, 0.2);
    color: var(--warning);
    font-weight: 600;
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid rgba(255,255,255,0.06);
}

/* ========== 主内容区 ========== */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 24px 32px;
    min-width: 0;
}

.main-footer {
    text-align: center;
    color: var(--text-muted);
    margin-top: 40px;
    padding: 20px 0;
    font-size: 0.8rem;
    border-top: 1px solid #e2e8f0;
}

/* ========== 移动端 ========== */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 90;
    background: var(--bg-sidebar);
    color: #fff;
    height: 52px;
    align-items: center;
    padding: 0 16px;
    gap: 12px;
}

.mobile-brand {
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    font-size: 1rem;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 99;
}

@media (max-width: 768px) {
    .mobile-header { display: flex; }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
    }
    .sidebar.open { transform: translateX(0); }

    .sidebar-overlay.open { display: block; }

    .main-content {
        margin-left: 0;
        padding: 68px 16px 16px;
    }
}

/* ========== 通用卡片 ========== */
.glass-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-card);
    border: 1px solid #e2e8f0;
}

.page-header {
    margin-bottom: 24px;
}
.page-header h1 {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 4px;
}
.page-header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* ========== 首页特定 ========== */
.home-header {
    text-align: center;
    margin: 20px 0 30px;
}
.home-header h1 {
    font-size: 2rem;
    letter-spacing: -1px;
    margin-bottom: 6px;
}
.time-big {
    font-size: 2.8rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1;
    margin-bottom: 6px;
    font-variant-numeric: tabular-nums;
}
.date-line {
    color: var(--text-secondary);
    font-size: 0.9rem;
    display: flex;
    gap: 10px;
    justify-content: center;
}

.search-bar-wrapper {
    position: relative;
    max-width: 460px;
    margin: 0 auto 24px;
}
.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}
.search-input {
    padding-left: 42px !important;
    border-radius: 50px !important;
    border: 1px solid #e2e8f0;
    box-shadow: var(--shadow-soft);
}

.category-header {
    font-size: 1rem;
    font-weight: 700;
    margin: 24px 0 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-main);
}
.category-header i { color: var(--primary); opacity: 0.8; }

.tool-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 14px;
}

.tool-card {
    display: flex;
    align-items: center;
    padding: 16px;
    background: var(--bg-card);
    border: 1px solid #f1f5f9;
    border-radius: var(--radius-lg);
    text-decoration: none;
    transition: all 0.2s;
}
.tool-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.06);
    border-color: var(--primary-soft);
}
.tool-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: #f0f9ff;
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    margin-right: 12px;
    flex-shrink: 0;
    transition: all 0.2s;
}
.tool-card:hover .tool-icon {
    background: var(--primary);
    color: #fff;
    transform: scale(1.05);
}
.tool-title { font-weight: 700; font-size: 0.95rem; margin-bottom: 2px; }
.tool-desc { font-size: 0.8rem; color: var(--text-muted); }

/* ========== 表单元素 ========== */
input, select, textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    color: var(--text-main);
    background: #fff;
    outline: none;
    transition: border 0.2s, box-shadow 0.2s;
    font-family: inherit;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 6px;
    color: var(--text-secondary);
}

.form-group { margin-bottom: 16px; }

.select-wrapper { position: relative; }
select {
    appearance: none;
    padding-right: 35px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
}

/* ========== 表格 ========== */
.table-responsive {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid #e2e8f0;
}
.result-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    font-size: 0.88rem;
}
.result-table th {
    background: #f8fafc;
    color: var(--text-secondary);
    font-weight: 600;
    padding: 10px 14px;
    text-align: left;
    white-space: nowrap;
    border-bottom: 1px solid #e2e8f0;
}
.result-table td {
    padding: 10px 14px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}
.result-table tr:hover { background: #f8fafc; }

.col-title { max-width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.col-id { font-family: 'Consolas', monospace; color: var(--text-muted); font-size: 0.85rem; }

/* ========== 统计面板 ========== */
.stats-dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin: 16px 0;
}
.stat-box {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-lg);
    padding: 16px;
    text-align: center;
}
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 0.85rem; color: var(--text-muted); margin-top: 4px; }
.stat-sub { font-size: 0.75rem; background: #f1f5f9; padding: 2px 8px; border-radius: 10px; display: inline-block; margin-top: 4px; color: var(--text-secondary); }

/* ========== 进度条 ========== */
.progress-container {
    background: #e2e8f0;
    border-radius: 20px;
    height: 8px;
    overflow: hidden;
    margin: 12px 0;
}
.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    border-radius: 20px;
    transition: width 0.3s;
    min-width: 0;
}

/* ========== 按钮 ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
    font-family: inherit;
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-primary { background: var(--text-main); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #334155; }
.btn-secondary { background: #fff; border: 1px solid #cbd5e1; color: var(--text-main); }
.btn-secondary:hover:not(:disabled) { background: #f8fafc; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #059669; }
.btn-danger { background: var(--error); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #dc2626; }

.btn-outline-xs {
    background: transparent;
    border: 1px solid #cbd5e1;
    color: var(--text-secondary);
    padding: 4px 10px;
    font-size: 0.78rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}
.btn-outline-xs:hover { border-color: var(--text-main); color: var(--text-main); }

/* ========== 状态标签 ========== */
.tag-success { background: rgba(16,185,129,0.1); color: #059669; padding: 3px 8px; border-radius: 6px; font-size: 0.78rem; font-weight: 600; }
.tag-error { background: rgba(239,68,68,0.1); color: #dc2626; padding: 3px 8px; border-radius: 6px; font-size: 0.78rem; font-weight: 600; }
.tag-pill { background: var(--primary-soft); color: var(--primary); padding: 2px 8px; border-radius: 10px; font-size: 0.8rem; font-weight: 600; }

/* ========== 日志容器 ========== */
.log-box {
    height: 250px;
    overflow-y: auto;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-md);
    padding: 12px;
    font-family: 'Consolas', monospace;
    font-size: 0.82rem;
    color: var(--text-secondary);
    scroll-behavior: smooth;
}

/* ========== 操作按钮组 ========== */
.action-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.action-buttons .btn { flex: 1; min-width: 100px; }

/* ========== 版主/标签卡片 ========== */
.moderator-list { display: flex; flex-wrap: wrap; gap: 8px; }
.moderator-card {
    display: flex;
    align-items: center;
    background: #f8fafc;
    padding: 6px 12px;
    border-radius: 24px;
    border: 1px solid #e2e8f0;
}
.mod-avatar { width: 28px; height: 28px; border-radius: 50%; margin-right: 8px; }
.mod-name { font-weight: 600; font-size: 0.85rem; }
.mod-id { font-size: 0.7rem; color: var(--text-muted); }

.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }

/* ========== 排行榜 ========== */
.ranking-item {
    display: flex;
    align-items: center;
    padding: 14px;
    margin-bottom: 10px;
    background: #fff;
    border: 1px solid #f1f5f9;
    border-radius: var(--radius-lg);
    transition: transform 0.2s;
    cursor: pointer;
}
.ranking-item:hover { transform: translateX(4px); border-color: var(--primary-soft); }

/* ========== 图表区域 ========== */
.chart-table-wrapper {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 16px;
    margin-top: 16px;
    align-items: start;
}
.detail-table-container {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-lg);
    overflow: hidden;
    max-height: 420px;
    overflow-y: auto;
}
.detail-chart-container {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-lg);
    padding-bottom: 12px;
    height: 420px;
    display: flex;
    flex-direction: column;
}
.detail-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.detail-table th { position: sticky; top: 0; background: #f8fafc; z-index: 10; padding: 8px 12px; text-align: left; border-bottom: 1px solid #e2e8f0; }
.detail-table td { padding: 8px 12px; border-bottom: 1px solid #f1f5f9; }

/* ========== 输入组 ========== */
.input-group-modern {
    display: flex;
    gap: 8px;
    padding: 4px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-lg);
}
.modern-select { border: none !important; height: 40px; background: transparent !important; }
.btn-search-modern { padding: 0 24px !important; border-radius: var(--radius-md) !important; }

/* ========== 首页搜索 ========== */
#toolsContainer .tool-grid { margin-bottom: 8px; }

/* ========== Toast ========== */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
    display: flex; align-items: center; gap: 8px;
    padding: 12px 16px; border-radius: 8px;
    background: #fff; box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    font-size: 0.88rem; min-width: 200px;
    animation: slideIn 0.3s ease;
    border-left: 4px solid var(--primary);
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--error); }
.toast.warning { border-left-color: var(--warning); }

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

/* ========== 响应式 ========== */
@media (max-width: 768px) {
    .chart-table-wrapper { grid-template-columns: 1fr; }
    .detail-chart-container { height: 300px; }
    .time-big { font-size: 2rem; }
    .input-group-modern { flex-direction: column; }
    .btn-search-modern { width: 100%; }
    .tool-grid { grid-template-columns: 1fr; }
    .stats-dashboard { grid-template-columns: 1fr 1fr; }
}
