/* ============================================
   导航页样式 - 现代简约风格
   ============================================ */

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

:root {
    /* 默认主题 - 白天模式 (light) */
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.12);
    --radius: 12px;
    --radius-sm: 8px;
}

/* 黑夜模式 */
.theme-dark {
    --primary: #818cf8;
    --primary-hover: #6366f1;
    --bg: #0f172a;
    --card-bg: #1e293b;
    --text: #f1f5f9;
    --text-light: #94a3b8;
    --border: #334155;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.4);
}

/* 浅粉模式 */
.theme-pink {
    --primary: #ec4899;
    --primary-hover: #db2777;
    --bg: #fdf2f8;
    --card-bg: #ffffff;
    --text: #831843;
    --text-light: #9d174d;
    --border: #fbcfe8;
    --shadow: 0 1px 3px rgba(236, 72, 153, 0.1);
    --shadow-lg: 0 10px 40px rgba(236, 72, 153, 0.15);
}

/* 浅蓝模式 */
.theme-blue {
    --primary: #0ea5e9;
    --primary-hover: #0284c7;
    --bg: #f0f9ff;
    --card-bg: #ffffff;
    --text: #0c4a6e;
    --text-light: #0369a1;
    --border: #bae6fd;
    --shadow: 0 1px 3px rgba(14, 165, 233, 0.1);
    --shadow-lg: 0 10px 40px rgba(14, 165, 233, 0.15);
}

/* 移动端布局类 */
@media (max-width: 768px) {
    .mobile-columns-2 .nav-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

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

/* ============================================
   登录界面
   ============================================ */

.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.login-box {
    background: var(--card-bg);
    padding: 40px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    text-align: center;
    width: 100%;
    max-width: 400px;
    animation: fadeInUp 0.5s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.login-box h2 {
    font-size: 24px;
    margin-bottom: 8px;
    color: var(--text);
}

.login-box p {
    color: var(--text-light);
    margin-bottom: 24px;
}

.login-box input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 16px;
    transition: border-color 0.2s;
    outline: none;
}

.login-box input:focus {
    border-color: var(--primary);
}

.login-box button {
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    margin-top: 12px;
}

.login-box button:hover {
    background: var(--primary-hover);
}

.error-msg {
    color: #ef4444;
    font-size: 14px;
    margin-top: 12px;
    min-height: 20px;
}

.back-link {
    display: inline-block;
    margin-top: 16px;
    color: var(--text-light);
    text-decoration: none;
    font-size: 14px;
}

.back-link:hover {
    color: var(--primary);
}

/* ============================================
   主页头部
   ============================================ */

header {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-content h1 {
    font-size: 24px;
    font-weight: 700;
}

.header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.btn-admin, .btn-home {
    padding: 8px 16px;
    background: var(--bg);
    color: var(--text);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: background 0.2s;
}

.btn-admin:hover, .btn-home:hover {
    background: var(--border);
}

.btn-logout {
    padding: 8px 16px;
    background: transparent;
    color: var(--text-light);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-logout:hover {
    background: #fef2f2;
    color: #ef4444;
    border-color: #fecaca;
}

/* ============================================
   导航卡片网格
   ============================================ */

main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px;
}

.nav-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}

.nav-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 24px;
    text-decoration: none;
    color: var(--text);
    transition: all 0.2s;
    border: 1px solid var(--border);
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.nav-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

.nav-card-icon {
    font-size: 36px;
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    border-radius: var(--radius-sm);
}

.nav-card-icon img {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

.nav-card-info {
    flex: 1;
    min-width: 0;
}

.nav-card-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-card-desc {
    font-size: 14px;
    color: var(--text-light);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-card-category {
    display: inline-block;
    font-size: 12px;
    color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
    margin-top: 8px;
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.empty-state p {
    color: var(--text-light);
    margin-bottom: 20px;
}

.btn-add {
    display: inline-block;
    padding: 10px 24px;
    background: var(--primary);
    color: white;
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-weight: 500;
}

/* ============================================
   后台管理界面
   ============================================ */

.admin-container {
    min-height: 100vh;
}

.admin-section {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
    border: 1px solid var(--border);
}

.admin-section h2 {
    font-size: 18px;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

/* 表单样式 */
.nav-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-light);
}

.form-group input {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.form-group input:focus {
    border-color: var(--primary);
}

.form-actions {
    display: flex;
    gap: 12px;
}

.btn-save {
    padding: 10px 24px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-save:hover {
    background: var(--primary-hover);
}

.btn-cancel {
    padding: 10px 24px;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-cancel:hover {
    background: var(--border);
}

/* 列表样式 */
.nav-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    transition: all 0.2s;
}

.nav-item:hover {
    border-color: var(--primary);
}

.nav-item-sort {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.nav-item-sort .sort-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 600;
}

.nav-item-icon {
    font-size: 24px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--card-bg);
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.nav-item-info {
    flex: 1;
    min-width: 0;
}

.nav-item-title {
    font-weight: 600;
    font-size: 15px;
}

.nav-item-url {
    font-size: 13px;
    color: var(--text-light);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-item-desc {
    font-size: 13px;
    color: var(--text-light);
}

.nav-item-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.btn-edit, .btn-delete {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-edit {
    background: var(--primary);
    color: white;
}

.btn-edit:hover {
    background: var(--primary-hover);
}

.btn-delete {
    background: #fee2e2;
    color: #ef4444;
}

.btn-delete:hover {
    background: #fecaca;
}

.empty-list {
    text-align: center;
    padding: 40px;
    color: var(--text-light);
}

/* ============================================
   页脚
   ============================================ */

footer {
    text-align: center;
    padding: 24px;
    color: var(--text-light);
    font-size: 14px;
}

/* ============================================
   响应式设计
   ============================================ */

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 12px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .nav-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .nav-item-actions {
        width: 100%;
        justify-content: flex-end;
    }
}

/* ============================================
   提示消息
   ============================================ */

.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    background: var(--text);
    color: white;
    border-radius: var(--radius-sm);
    font-size: 14px;
    z-index: 1000;
    animation: slideIn 0.3s ease, fadeOut 0.3s ease 2.7s;
    box-shadow: var(--shadow-lg);
}

.toast.success {
    background: #10b981;
}

.toast.error {
    background: #ef4444;
}

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

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

/* 分类标签 */
.category-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 24px;
}

.category-tag {
    padding: 6px 16px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.category-tag:hover,
.category-tag.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ============================================
   表单扩展样式
   ============================================ */

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group textarea {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    font-family: 'Courier New', Courier, monospace;
    resize: vertical;
    min-height: 80px;
}

.form-group textarea:focus {
    border-color: var(--primary);
}

.form-group small {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 2px;
}

/* ============================================
   开关组件
   ============================================ */

.password-toggle-container {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 4px;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    transition: 0.3s;
    border-radius: 26px;
}

.toggle-slider:before {
    content: "";
    position: absolute;
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--primary);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

.toggle-switch input:focus + .toggle-slider {
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.toggle-label {
    font-size: 14px;
    color: var(--text);
    user-select: none;
}

/* ============================================
   内联编辑表单
   ============================================ */

.nav-item-wrapper {
    background: var(--bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    transition: all 0.2s;
}

.nav-item-wrapper:hover {
    border-color: var(--primary);
}

.nav-item-wrapper .nav-item {
    padding: 16px;
    border: none;
    background: transparent;
}

.inline-edit-form {
    padding: 16px;
    background: var(--card-bg);
    border-top: 1px solid var(--border);
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

.inline-edit-form form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.inline-edit-form .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.inline-edit-form .form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.inline-edit-form .form-group label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-light);
}

.inline-edit-form .form-group input {
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.inline-edit-form .form-group input:focus {
    border-color: var(--primary);
}

.inline-edit-form .form-actions {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

.inline-edit-form .btn-save {
    padding: 8px 20px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.inline-edit-form .btn-save:hover {
    background: var(--primary-hover);
}

.inline-edit-form .btn-cancel {
    padding: 8px 20px;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.inline-edit-form .btn-cancel:hover {
    background: var(--border);
}

/* 导航项分类标签 */
.nav-item-category {
    display: inline-block;
    font-size: 12px;
    color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
    margin-top: 6px;
}

/* ============================================
   网站头部 Logo 和副标题样式
   ============================================ */

.site-header {
    display: flex;
    align-items: center;
    gap: 16px;
}

.site-header img {
    width: 48px;
    height: 48px;
    object-fit: contain;
    border-radius: 8px;
    background: var(--bg);
    padding: 4px;
    border: 1px solid var(--border);
}

.site-title-group {
    display: flex;
    flex-direction: column;
}

.site-title-group h1 {
    margin: 0;
    line-height: 1.2;
}

.site-subtitle {
    margin: 4px 0 0 0;
    font-size: 14px;
    color: var(--text-light);
    font-weight: 400;
}

@media (max-width: 768px) {
    .site-header {
        flex-direction: column;
        align-items: center;
        gap: 8px;
    }
    
    .site-header img {
        width: 40px;
        height: 40px;
    }
    
    .site-title-group {
        align-items: center;
    }
    
    .site-subtitle {
        text-align: center;
    }
}
