/* === Layout === */
:root {
    --sidebar-width: 280px;
    --topbar-height: 56px;
    --primary: #4361ee;
    --bg: #f8f9fa;
    --sidebar-bg: #1a1d29;
    --sidebar-text: #b8bcc9;
    --sidebar-active: #4361ee;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    display: flex;
    min-height: 100vh;
}

/* === Sidebar === */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 1000;
    transition: transform 0.3s;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: #333; border-radius: 2px; }

.sidebar-header {
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.logo-link {
    color: #fff;
    text-decoration: none;
    font-size: 1.3rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-link i { font-size: 1.5rem; color: var(--primary); }

.sidebar-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
}

.sidebar-nav { padding: 10px 0; }

.nav-group { margin-bottom: 4px; }

.nav-group-title {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #fff;
    transition: background 0.2s;
}

.nav-group-title:hover { background: rgba(255,255,255,0.05); }
.nav-group-title i:last-child { font-size: 0.7rem; transition: transform 0.2s; }
.nav-group-title[aria-expanded="true"] i:last-child { transform: rotate(180deg); }

.nav-group .collapse,
.nav-group .collapsing {
    transition-duration: 0.01ms !important;
}

.nav-group .collapse .nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 20px 9px 46px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.875rem;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.nav-group .collapse .nav-item:hover {
    background: rgba(255,255,255,0.05);
    color: #fff;
}

.nav-group .collapse .nav-item.active {
    background: rgba(67, 97, 238, 0.15);
    color: var(--sidebar-active);
    border-left-color: var(--sidebar-active);
}

/* === Main Content === */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.top-bar {
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.sidebar-toggle {
    display: none;
    font-size: 1.4rem;
    color: #333;
    text-decoration: none;
}

.content-wrapper { flex: 1; padding: 0; }

/* === Hero Section === */
.hero-section {
    padding: 40px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 0 0 24px 24px;
    color: #fff;
    margin-bottom: 30px;
}

.hero-section h1 { color: #fff; }
.hero-section .lead { color: rgba(255,255,255,0.85); }

/* === Category Section === */
.category-section { padding: 0 16px; }

.category-title {
    font-size: 1.2rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e9ecef;
}

/* === Tool Card === */
.tool-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 12px;
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e9ecef;
    transition: all 0.25s;
    height: 100%;
    text-align: center;
    color: #333;
}

.tool-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.1);
    border-color: var(--primary);
    color: var(--primary);
}

.tool-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    margin-bottom: 12px;
}

.tool-name {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.tool-desc {
    font-size: 0.75rem;
    color: #999;
    line-height: 1.4;
}

/* === Tool Page === */
.tool-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 32px 24px;
}

.tool-header {
    text-align: center;
    margin-bottom: 32px;
}

.tool-header h2 {
    font-weight: 700;
    margin-bottom: 8px;
}

.tool-header p { color: #666; }

.tool-form {
    background: #fff;
    border-radius: 16px;
    padding: 32px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    border: 1px solid #e9ecef;
}

.upload-area {
    border: 2px dashed #d1d5db;
    border-radius: 12px;
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: #fafbfc;
}

.upload-area:hover, .upload-area.dragover {
    border-color: var(--primary);
    background: rgba(67, 97, 238, 0.04);
}

.upload-area i {
    font-size: 2.5rem;
    color: #aaa;
    margin-bottom: 12px;
}

.upload-area p { color: #888; margin: 0; }

.file-list {
    margin-top: 16px;
    max-height: 200px;
    overflow-y: auto;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 6px;
    font-size: 0.875rem;
}

.file-item .bi { color: var(--primary); }
.file-item .remove-file { cursor: pointer; color: #dc3545; margin-left: auto; }

.result-area {
    margin-top: 24px;
    padding: 20px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 12px;
    display: none;
}

.result-area.error {
    background: #fef2f2;
    border-color: #fecaca;
}

.result-area h5 { color: #16a34a; font-weight: 600; }
.result-area.error h5 { color: #dc2626; }

/* === Loading === */
.loading-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.loading-overlay.active { display: flex; }

/* === Sidebar overlay (mobile) === */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}

/* === Responsive === */
@media (max-width: 991px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .sidebar-toggle { display: block; }
    .sidebar-overlay.active { display: block; }
}

/* === Misc === */
.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover {
    background: #3451d1;
    border-color: #3451d1;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(67,97,238,0.15);
}

.text-preview {
    max-height: 400px;
    overflow-y: auto;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 16px;
    font-family: monospace;
    font-size: 0.875rem;
    white-space: pre-wrap;
    word-break: break-all;
}

.diff-added { background: #dcfce7; color: #166534; }
.diff-removed { background: #fee2e2; color: #991b1b; }
.diff-unchanged { color: #666; }

.param-group {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.param-group .form-group {
    flex: 1;
    min-width: 150px;
}

/* === User Menu === */
.user-menu .dropdown-toggle {
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* === Limit Modal === */
.plan-mini-card {
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    padding: 16px 20px;
    min-width: 140px;
    position: relative;
    transition: all 0.2s;
}
.plan-mini-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.plan-mini-card.featured { border-color: #f59e0b; background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%); }
.plan-mini-badge { position: absolute; top: -10px; left: 50%; transform: translateX(-50%); background: #f59e0b; color: #fff; font-size: 0.7rem; padding: 2px 10px; border-radius: 10px; font-weight: 600; }
.plan-mini-name { font-weight: 700; font-size: 0.9rem; margin-bottom: 4px; }
.plan-mini-price { font-size: 1.2rem; font-weight: 800; color: var(--primary); }
.plan-mini-card.featured .plan-mini-price { color: #d97706; }
.plan-mini-desc { font-size: 0.75rem; color: #888; }

/* === Usage Bar === */
.usage-bar {
    background: #fff; border: 1px solid #e9ecef; border-radius: 10px;
    padding: 10px 16px; margin-bottom: 16px; display: flex;
    align-items: center; justify-content: space-between; font-size: 0.85rem;
}
.usage-bar .usage-info { display: flex; align-items: center; gap: 8px; color: #555; }
.usage-bar .usage-info .bi { color: var(--primary); }
.usage-bar .progress { width: 120px; height: 6px; }
.usage-bar .usage-link { color: var(--primary); text-decoration: none; font-weight: 600; font-size: 0.8rem; }

/* === Auth Pages === */
.auth-container { max-width: 420px; margin: 60px auto; padding: 0 24px; }
.auth-card { background: #fff; border-radius: 16px; padding: 36px; box-shadow: 0 4px 20px rgba(0,0,0,0.08); border: 1px solid #e9ecef; }
.auth-card h2 { font-weight: 700; text-align: center; margin-bottom: 24px; }
.auth-card .form-control { padding: 10px 14px; border-radius: 8px; }
.auth-card .btn { padding: 10px; border-radius: 8px; font-weight: 600; }
.auth-footer { text-align: center; margin-top: 16px; font-size: 0.875rem; color: #888; }
.auth-footer a { color: var(--primary); text-decoration: none; font-weight: 600; }

/* === Pricing === */
.pricing-hero { text-align: center; padding: 48px 24px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: #fff; border-radius: 0 0 24px 24px; margin-bottom: 40px; }
.pricing-hero h1 { color: #fff; font-weight: 800; }
.pricing-hero p { color: rgba(255,255,255,0.85); font-size: 1.1rem; }
.pricing-card { background: #fff; border: 2px solid #e9ecef; border-radius: 16px; padding: 32px 24px; text-align: center; transition: all 0.3s; height: 100%; display: flex; flex-direction: column; }
.pricing-card:hover { transform: translateY(-6px); box-shadow: 0 12px 32px rgba(0,0,0,0.12); }
.pricing-card.recommended { border-color: var(--primary); position: relative; box-shadow: 0 8px 24px rgba(67,97,238,0.2); }
.pricing-card.recommended::before { content: '\63a8\8350'; position: absolute; top: -12px; left: 50%; transform: translateX(-50%); background: var(--primary); color: #fff; padding: 4px 16px; border-radius: 12px; font-size: 0.75rem; font-weight: 700; }
.pricing-card.premium { border-color: #f59e0b; background: linear-gradient(180deg, #fffbeb 0%, #fff 30%); }
.pricing-price { font-size: 2.5rem; font-weight: 800; margin: 16px 0; }
.pricing-price small { font-size: 1rem; font-weight: 400; color: #888; }
.pricing-features { list-style: none; padding: 0; margin: 20px 0; text-align: left; flex-grow: 1; }
.pricing-features li { padding: 6px 0; font-size: 0.9rem; display: flex; align-items: center; gap: 8px; }
.pricing-features li i { color: #22c55e; font-size: 0.85rem; }
.pricing-features li.disabled { color: #aaa; }
.pricing-features li.disabled i { color: #ddd; }

/* === Dashboard === */
.stat-card { background: #fff; border: 1px solid #e9ecef; border-radius: 12px; padding: 20px; text-align: center; }
.stat-card .stat-value { font-size: 2rem; font-weight: 800; color: var(--primary); }
.stat-card .stat-label { font-size: 0.85rem; color: #888; margin-top: 4px; }
