/* ========== Reset & Base ========== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --border: #30363d;
    --border-hover: #484f58;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #484f58;
    --accent: #58a6ff;
    --accent-hover: #79c0ff;
    --success: #3fb950;
    --danger: #f85149;
    --purple: #a371f7;
    --orange: #d29922;
    --gradient-1: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-2: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --shadow: 0 8px 30px rgba(0,0,0,.3);
    --transition: .25s ease;
}

html { font-size: 16px; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); }

/* ========== Layout ========== */
.site-container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }

/* ========== Top Navigation Bar ========== */
.navbar {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
}
.navbar-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
}
.navbar-brand {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: -0.02em;
}
.navbar-brand:hover { color: var(--text-primary); }
.navbar-brand .brand-icon {
    width: 34px; height: 34px;
    background: var(--gradient-1);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}
.navbar-links { display: flex; align-items: center; gap: 6px; }
.navbar-links a {
    padding: 6px 16px;
    border-radius: var(--radius-sm);
    font-size: .875rem;
    color: var(--text-secondary);
    transition: all var(--transition);
    font-weight: 500;
}
.navbar-links a:hover { color: var(--text-primary); background: var(--bg-tertiary); }
.navbar-links a.active {
    color: #fff;
    background: var(--gradient-1);
}

/* ========== Page Header ========== */
.page-hero {
    text-align: center;
    padding: 60px 24px 40px;
}
.page-hero h1 {
    font-size: 2.25rem;
    font-weight: 800;
    background: linear-gradient(90deg, #667eea, #a371f7, #f093fb);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 12px;
    letter-spacing: -0.03em;
}
.page-hero p {
    font-size: 1.05rem;
    color: var(--text-secondary);
    max-width: 480px;
    margin: 0 auto;
}

/* ========== Search ========== */
.search-wrapper {
    max-width: 480px;
    margin: 0 auto 36px;
    position: relative;
}
.search-wrapper input {
    width: 100%;
    padding: 14px 48px 14px 20px;
    border-radius: 28px;
    border: 2px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: .95rem;
    outline: none;
    transition: all var(--transition);
}
.search-wrapper input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(88,166,255,.1);
}
.search-wrapper input::placeholder { color: var(--text-muted); }
.search-wrapper .search-icon {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.15rem;
    color: var(--text-muted);
    pointer-events: none;
}

/* ========== Category Tabs ========== */
.category-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-bottom: 32px;
}
.category-tab {
    padding: 10px 22px;
    border-radius: 24px;
    border: 1.5px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: .9rem;
    font-weight: 500;
    transition: all var(--transition);
    user-select: none;
    white-space: nowrap;
}
.category-tab:hover {
    border-color: var(--accent);
    color: var(--text-primary);
    background: rgba(88,166,255,.06);
}
.category-tab.active {
    background: var(--gradient-1);
    border-color: transparent;
    color: #fff;
    font-weight: 600;
    box-shadow: 0 4px 16px rgba(102,126,234,.35);
}

/* ========== Link Cards Grid ========== */
.links-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
    padding-bottom: 60px;
}

.link-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px 20px;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.link-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--gradient-1);
    opacity: 0;
    transition: opacity var(--transition);
}
.link-card:hover {
    transform: translateY(-3px);
    border-color: var(--accent);
    box-shadow: var(--shadow);
}
.link-card:hover::before { opacity: 1; }

.link-card .card-icon {
    width: 46px; height: 46px;
    border-radius: 14px;
    background: rgba(102,126,234,.12);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}
.link-card .card-body { flex: 1; min-width: 0; }
.link-card .card-name {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.link-card .card-desc {
    font-size: .8rem;
    color: var(--text-secondary);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.link-card .card-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: .72rem;
    font-weight: 500;
    background: rgba(163,113,247,.1);
    color: var(--purple);
    margin-top: 6px;
}

/* ========== Empty State ========== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
    grid-column: 1 / -1;
}
.empty-state .empty-icon { font-size: 3.5rem; margin-bottom: 14px; }
.empty-state p { font-size: 1rem; }

/* ========== Admin Pages ========== */
.admin-layout {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 24px;
    padding: 32px 0;
}

.panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.panel-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: .95rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255,255,255,.015);
}
.panel-body { padding: 12px 14px; max-height: 520px; overflow-y: auto; }

.list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    margin-bottom: 4px;
    cursor: pointer;
    transition: all var(--transition);
    gap: 10px;
}
.list-item:hover { background: rgba(255,255,255,.025); border-color: var(--border); }
.list-item.selected { background: rgba(88,166,255,.08); border-color: rgba(88,166,255,.25); }
.list-item .item-info { flex: 1; min-width: 0; }
.list-item .item-name { font-weight: 500; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .item-sub { font-size: .78rem; color: var(--text-secondary); margin-top: 2px; }
.list-item .item-url { font-size: .75rem; color: var(--accent); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .item-actions { display: flex; gap: 4px; opacity: 0; transition: opacity var(--transition); flex-shrink: 0; }
.list-item:hover .item-actions { opacity: 1; }

/* ========== Buttons ========== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    cursor: pointer;
    font-size: .85rem;
    font-weight: 500;
    font-family: inherit;
    transition: all var(--transition);
    white-space: nowrap;
}
.btn:hover { background: var(--border-hover); border-color: var(--border-hover); }
.btn-primary { background: #238636; border-color: #2ea043; color: #fff; }
.btn-primary:hover { background: #2ea043; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: rgba(248,81,73,.1); border-color: var(--danger); }
.btn-sm { padding: 4px 12px; font-size: .78rem; border-radius: 6px; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--bg-tertiary); }

/* ========== Form ========== */
.form-group { margin-bottom: 18px; }
.form-group label {
    display: block;
    font-size: .82rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 500;
}
.form-group .required::after { content: ' *'; color: var(--danger); }
.form-control {
    width: 100%;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: .9rem;
    font-family: inherit;
    outline: none;
    transition: border-color var(--transition);
}
.form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(88,166,255,.1); }
textarea.form-control { resize: vertical; min-height: 72px; }
select.form-control { cursor: pointer; }

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* ========== Modal Form ========== */
.mini-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn .2s;
}
.mini-modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 460px;
    max-width: 94vw;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
}
.mini-modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.mini-modal-body { padding: 20px; }

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .page-hero { padding: 40px 20px 28px; }
    .page-hero h1 { font-size: 1.6rem; }
    .links-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
    .link-card { padding: 16px 14px; gap: 10px; }
    .link-card .card-icon { width: 38px; height: 38px; font-size: 1.15rem; }
    .link-card .card-name { font-size: .92rem; }
    .admin-layout { grid-template-columns: 1fr; }
    .category-tab { padding: 8px 14px; font-size: .8rem; }
}
