/* ============================================
   网址导航系统 - 独立样式控制文件
   日夜双主题 + 全局居中 + 浮动申请按钮
   主题色变量由 PHP 根据来路动态注入 :root
   ============================================ */

/* ---------- 全局重置 ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    min-height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    transition: background .4s ease, color .4s ease;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}
html { background: var(--bg); }
body { background: var(--bg); }

a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
img { display: block; }

/* ---------- 滚动条 ---------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--primary) 40%, transparent); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ============================================
   黑夜主题（默认）— 变量由PHP注入 :root
   ============================================ */
:root {
    --bg: #0f172a;
    --card-bg: #1e293b;
    --text: #f1f5f9;
    --border: rgba(255,255,255,.08);
    --input-bg: rgba(255,255,255,.06);
    --muted: rgba(241,245,249,.55);
}

/* ============================================
   白天主题 — html.light-mode / body.light-mode 全面覆盖
   ============================================ */
html.light-mode { background: #f5f7fa; }
body.light-mode {
    --bg: #f5f7fa;
    --card-bg: #ffffff;
    --text: #1a202c;
    --border: #e2e8f0;
    --input-bg: #f8fafc;
    --muted: rgba(26,32,44,.55);
    background: #f5f7fa;
    color: #1a202c;
}
body.light-mode .nav-header {
    background: rgba(255,255,255,.9);
    border-bottom-color: #e2e8f0;
    box-shadow: 0 1px 4px rgba(0,0,0,.04);
}
body.light-mode .nav-logo { -webkit-text-fill-color: transparent; }
body.light-mode .nav-logo span { -webkit-text-fill-color: #64748b; }
body.light-mode .nav-search input {
    background: #fff;
    border-color: #e2e8f0;
    color: #1a202c;
}
body.light-mode .nav-search input::placeholder { color: #94a3b8; }
body.light-mode .nav-btn-ghost {
    background: #fff;
    border-color: #e2e8f0;
    color: #475569;
}
body.light-mode .nav-btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
body.light-mode .theme-toggle {
    background: #fff;
    border-color: #e2e8f0;
    color: #475569;
}
body.light-mode .category-title {
    background: rgba(99,102,241,.08);
    border-color: rgba(99,102,241,.15);
    color: #1a202c;
}
body.light-mode .site-card {
    background: #fff;
    border-color: #e8ecf1;
    box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
body.light-mode .site-card:hover {
    border-color: var(--primary);
    box-shadow: 0 8px 24px rgba(99,102,241,.15);
}
body.light-mode .site-card .name { color: #1a202c; }
body.light-mode .site-card .desc { color: #64748b; }
body.light-mode .nav-footer {
    border-top-color: #e2e8f0;
    color: #94a3b8;
}
body.light-mode .modal-content {
    background: #fff;
    color: #1a202c;
    box-shadow: 0 24px 60px rgba(0,0,0,.15);
}
body.light-mode .modal-content input,
body.light-mode .modal-content textarea,
body.light-mode .modal-content select {
    background: #f8fafc;
    border-color: #e2e8f0;
    color: #1a202c;
}
body.light-mode .modal-content input::placeholder,
body.light-mode .modal-content textarea::placeholder { color: #94a3b8; }
body.light-mode .fab {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    box-shadow: 0 6px 20px rgba(99,102,241,.35);
}
body.light-mode .empty-state { color: #94a3b8; }

/* ---------- 顶部导航 ---------- */
.nav-header {
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    border-bottom: 1px solid var(--border);
}
.nav-header .inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
    flex-wrap: wrap;
}
.nav-logo {
    font-size: 24px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 1px;
    white-space: nowrap;
}
.nav-logo span {
    font-size: 13px;
    opacity: .5;
    margin-left: 6px;
    -webkit-text-fill-color: var(--text);
    font-weight: 400;
}
.nav-search {
    flex: 0 1 380px;
    position: relative;
}
.nav-search input {
    width: 100%;
    padding: 10px 16px 10px 42px;
    border: 1px solid var(--border);
    border-radius: 24px;
    background: var(--input-bg);
    color: var(--text);
    font-size: 14px;
    outline: none;
    transition: border-color .3s, box-shadow .3s;
}
.nav-search input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 15%, transparent);
}
.nav-search input::placeholder { color: var(--muted); }
.nav-search::before {
    content: "🔍";
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    opacity: .5;
}
.nav-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}
.nav-btn {
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: transform .2s, box-shadow .2s, background .3s;
    white-space: nowrap;
    font-family: inherit;
}
.nav-btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
}
.nav-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px color-mix(in srgb, var(--primary) 45%, transparent);
}
.nav-btn-ghost {
    background: var(--input-bg);
    color: var(--text);
    border: 1px solid var(--border);
}
.nav-btn-ghost:hover {
    border-color: var(--primary);
    color: var(--primary);
}
.theme-toggle {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--input-bg);
    color: var(--text);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .3s;
    flex-shrink: 0;
}
.theme-toggle:hover {
    border-color: var(--primary);
    transform: rotate(15deg);
}

/* ---------- 主体容器（居中） ---------- */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 40px 24px 80px;
    text-align: center;
}

/* ---------- 分类区块（居中） ---------- */
.category-section {
    margin-bottom: 48px;
    animation: fadeUp .5s ease both;
    text-align: center;
}
.category-title {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 19px;
    font-weight: 700;
    margin-bottom: 22px;
    padding: 7px 22px;
    border-radius: 22px;
    background: color-mix(in srgb, var(--primary) 10%, transparent);
    border: 1px solid color-mix(in srgb, var(--primary) 18%, transparent);
}
.category-title .icon { font-size: 21px; }
.category-title .count {
    font-size: 12px;
    font-weight: 500;
    opacity: .6;
    background: var(--card-bg);
    padding: 2px 10px;
    border-radius: 10px;
}

/* ---------- 网址卡片网格（居中） ---------- */
.site-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 14px;
    justify-items: center;
    max-width: 1000px;
    margin: 0 auto;
}
/* 主页默认只显示前8个（电脑端） */
.site-grid .site-card:nth-child(n+9) {
    display: none;
}
/* 分类详情页显示全部 */
.site-grid-full .site-card:nth-child(n+9) {
    display: flex;
}
.view-more {
    display: inline-block;
    margin-top: 6px;
    padding: 8px 24px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    color: var(--primary);
    border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent);
    transition: all .25s;
}
.view-more:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* ---------- 分类详情页标签切换 ---------- */
.cat-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-bottom: 10px;
}
.cat-tab {
    padding: 7px 18px;
    border-radius: 18px;
    font-size: 13px;
    font-weight: 500;
    background: var(--card-bg);
    border: 1px solid var(--border);
    color: var(--text);
    opacity: .7;
    transition: all .2s;
}
.cat-tab:hover {
    opacity: 1;
    border-color: var(--primary);
}
.cat-tab.active {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    border-color: transparent;
    opacity: 1;
}
.site-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
    padding: 22px 16px;
    width: 100%;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    transition: transform .25s, border-color .25s, box-shadow .25s;
    cursor: pointer;
}
.site-card:hover {
    transform: translateY(-4px);
    border-color: var(--primary);
    box-shadow: 0 10px 28px color-mix(in srgb, var(--primary) 20%, transparent);
}
.site-card img {
    width: 46px;
    height: 46px;
    border-radius: 10px;
    background: #fff;
    object-fit: contain;
    padding: 3px;
}
.site-card .info { width: 100%; }
.site-card .name {
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color .3s;
}
.site-card .click-num {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    background: color-mix(in srgb, var(--primary) 15%, transparent);
    color: var(--primary);
    padding: 1px 6px;
    border-radius: 8px;
    margin-left: 4px;
    vertical-align: middle;
}
.site-card .desc {
    font-size: 12px;
    opacity: .55;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 4px;
}

/* ---------- 右下角浮动申请按钮 ---------- */
.fab {
    position: fixed;
    right: 28px;
    bottom: 28px;
    z-index: 90;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    box-shadow: 0 6px 24px color-mix(in srgb, var(--primary) 50%, transparent);
    transition: transform .3s, box-shadow .3s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.fab:hover {
    transform: scale(1.08) rotate(90deg);
    box-shadow: 0 8px 30px color-mix(in srgb, var(--primary) 60%, transparent);
}
.fab .fab-tip {
    position: absolute;
    right: 68px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--card-bg);
    color: var(--text);
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity .3s;
    border: 1px solid var(--border);
}
.fab:hover .fab-tip { opacity: 1; }

/* ---------- 空状态 ---------- */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    font-size: 15px;
    color: var(--muted);
}

/* ---------- 页脚 ---------- */
.nav-footer {
    text-align: center;
    padding: 28px 20px;
    font-size: 12px;
    opacity: .5;
    border-top: 1px solid var(--border);
}

/* ============================================
   申请加入模态框
   ============================================ */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn .25s ease;
}
.modal-overlay.active { display: flex; }
.modal-content {
    background: var(--card-bg);
    color: var(--text);
    border-radius: 16px;
    width: 100%;
    max-width: 460px;
    padding: 32px;
    box-shadow: 0 24px 60px rgba(0,0,0,.4);
    animation: slideUp .3s ease;
    text-align: left;
    position: relative;
    border: 1px solid var(--border);
}
.modal-content h2 {
    font-size: 20px;
    margin-bottom: 6px;
    text-align: center;
}
.modal-content .sub {
    text-align: center;
    font-size: 13px;
    opacity: .6;
    margin-bottom: 24px;
}
.modal-content .form-group { margin-bottom: 16px; }
.modal-content label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    opacity: .8;
}
.modal-content input,
.modal-content textarea,
.modal-content select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--input-bg);
    color: var(--text);
    font-size: 14px;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
    font-family: inherit;
}
.modal-content input:focus,
.modal-content textarea:focus,
.modal-content select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 15%, transparent);
}
.modal-content textarea { resize: vertical; min-height: 70px; }
.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}
.modal-actions button { flex: 1; padding: 11px; font-size: 15px; }
.modal-close {
    position: absolute;
    top: 14px;
    right: 18px;
    background: none;
    border: none;
    color: var(--text);
    font-size: 24px;
    cursor: pointer;
    opacity: .4;
    transition: opacity .2s;
    line-height: 1;
}
.modal-close:hover { opacity: 1; }

/* Toast */
.toast {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    z-index: 2000;
    opacity: 0;
    transition: all .3s;
    pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { background: #16a34a; color: #fff; }
.toast.error { background: #ef4444; color: #fff; }

/* ---------- 动画 ---------- */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp {
    from { opacity: 0; transform: translateY(24px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---------- 响应式 ---------- */
@media (max-width: 768px) {
    .nav-header .inner { gap: 10px; padding: 12px 16px; }
    .nav-search { order: 3; flex-basis: 100%; max-width: 100%; }
    .theme-toggle { display: none; }
    .site-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
    /* 移动端只显示前4个 */
    .site-grid .site-card:nth-child(n+5) { display: none; }
    .site-grid-full .site-card:nth-child(n+5) { display: flex; }
    .site-card { padding: 16px 10px; }
    .site-card img { width: 38px; height: 38px; }
    .container { padding: 24px 14px 80px; }
    .category-title { font-size: 17px; padding: 5px 16px; }
    .modal-content { padding: 24px 20px; }
    .fab { right: 18px; bottom: 18px; width: 50px; height: 50px; font-size: 20px; }
    .fab .fab-tip { display: none; }
    .cat-tabs { justify-content: flex-start; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; }
    .cat-tab { white-space: nowrap; }
}

/* ============================================
   后台管理样式
   ============================================ */
.admin-body {
    background: #f1f5f9;
    color: #1e293b;
}
.admin-layout { display: flex; min-height: 100vh; }
.admin-sidebar {
    width: 220px;
    background: linear-gradient(180deg, #1e293b, #0f172a);
    color: #cbd5e1;
    padding: 24px 0;
    flex-shrink: 0;
}
.admin-sidebar .brand {
    padding: 0 24px 24px;
    font-size: 18px;
    font-weight: 800;
    color: #fff;
    border-bottom: 1px solid #334155;
    margin-bottom: 16px;
}
.admin-sidebar .brand small { display: block; font-size: 11px; font-weight: 400; opacity: .5; margin-top: 4px; }
.admin-sidebar nav a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    font-size: 14px;
    color: #94a3b8;
    transition: all .2s;
    border-left: 3px solid transparent;
}
.admin-sidebar nav a:hover,
.admin-sidebar nav a.active {
    background: rgba(79, 70, 229, .15);
    color: #fff;
    border-left-color: #6366f1;
}
.admin-sidebar .badge {
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    padding: 1px 7px;
    border-radius: 10px;
    font-weight: 600;
}
.admin-main { flex: 1; padding: 28px 32px; overflow-x: auto; }
.admin-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}
.admin-topbar h1 { font-size: 22px; color: #0f172a; }
.admin-topbar .user-info { font-size: 13px; color: #64748b; }
.admin-topbar .user-info a { color: #ef4444; margin-left: 12px; }
.admin-card {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
    margin-bottom: 20px;
}
.admin-card h2 {
    font-size: 16px;
    margin-bottom: 16px;
    color: #0f172a;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th {
    text-align: left;
    padding: 12px 14px;
    background: #f8fafc;
    color: #64748b;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .5px;
    border-bottom: 2px solid #e2e8f0;
}
.admin-table td { padding: 12px 14px; border-bottom: 1px solid #f1f5f9; color: #334155; }
.admin-table tr:hover td { background: #f8fafc; }
.admin-table .actions a { margin-right: 10px; font-size: 13px; }
.admin-table .actions .edit { color: #6366f1; }
.admin-table .actions .del  { color: #ef4444; }
.admin-table .actions .approve { color: #16a34a; }
.admin-table .actions .reject { color: #f59e0b; }
.status-tag {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
}
.status-pending { background: #fef3c7; color: #b45309; }
.status-approved { background: #dcfce7; color: #15803d; }
.status-rejected { background: #fee2e2; color: #b91c1c; }
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #475569;
    margin-bottom: 6px;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 14px;
    color: #0f172a;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
    font-family: inherit;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}
.form-row { display: flex; gap: 16px; }
.form-row .form-group { flex: 1; }
.btn {
    display: inline-block;
    padding: 8px 18px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all .2s;
    font-family: inherit;
}
.btn-primary { background: #6366f1; color: #fff; }
.btn-primary:hover { background: #4f46e5; }
.btn-success { background: #16a34a; color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-warning { background: #f59e0b; color: #fff; }
.btn-warning:hover { background: #d97706; }
.btn-danger  { background: #ef4444; color: #fff; }
.btn-danger:hover  { background: #dc2626; }
.btn-secondary { background: #e2e8f0; color: #475569; }
.btn-secondary:hover { background: #cbd5e1; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.stat-card .num { font-size: 32px; font-weight: 800; color: #6366f1; }
.stat-card .label { font-size: 13px; color: #64748b; margin-top: 4px; }
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.login-box {
    background: #fff;
    padding: 40px;
    border-radius: 16px;
    width: 360px;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.login-box h1 { text-align: center; font-size: 24px; margin-bottom: 8px; color: #0f172a; }
.login-box .sub { text-align: center; font-size: 13px; color: #94a3b8; margin-bottom: 28px; }
.login-box .btn { width: 100%; padding: 11px; font-size: 15px; }
.login-error {
    background: #fef2f2;
    color: #dc2626;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 16px;
    text-align: center;
}
.alert { padding: 12px 16px; border-radius: 8px; font-size: 14px; margin-bottom: 16px; }
.alert-success { background: #f0fdf4; color: #16a34a; border: 1px solid #bbf7d0; }
.alert-error   { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.color-preview {
    display: inline-block;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    vertical-align: middle;
    border: 1px solid #e2e8f0;
}
.filter-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.filter-tabs a {
    padding: 6px 16px;
    border-radius: 16px;
    font-size: 13px;
    background: #f1f5f9;
    color: #64748b;
    transition: all .2s;
}
.filter-tabs a.active { background: #6366f1; color: #fff; }

@media (max-width: 768px) {
    .admin-layout { flex-direction: column; }
    .admin-sidebar { width: 100%; padding: 12px 0; }
    .admin-sidebar nav { display: flex; overflow-x: auto; }
    .admin-sidebar nav a { white-space: nowrap; border-left: none; border-bottom: 3px solid transparent; }
    .admin-main { padding: 16px; }
    .form-row { flex-direction: column; gap: 0; }
}
