/* ========================================
   蚁眼AI 全局布局 v6 — 简洁亮色
   窄侧边栏 + 清爽内容区
   ======================================== */

html, body {
    height: 100%; margin: 0; padding: 0;
    overflow: hidden;
    font-family: -apple-system, 'PingFang SC', 'Microsoft YaHei', 'Segoe UI', sans-serif;
    background: #f1f5f9; color: #334155;
    -webkit-font-smoothing: antialiased;
}
body.has-app-layout { display: flex; }

/* ========== 左侧导航栏 ========== */
.app-sidebar {
    width: 180px; min-width: 180px;
    height: 100vh;
    background: #fff;
    border-right: 1px solid #e2e8f0;
    display: flex; flex-direction: column;
    overflow: hidden;
    z-index: 100;
    user-select: none; -webkit-user-select: none;
    transition: width 0.25s, min-width 0.25s;
}
.app-sidebar.collapsed { width: 50px; min-width: 50px; }

.sidebar-logo {
    height: 50px; min-height: 50px;
    display: flex; align-items: center;
    padding: 0 14px; gap: 8px;
    border-bottom: 1px solid #f1f5f9;
    position: relative;
}
.sidebar-logo img { width: 24px; height: 24px; border-radius: 5px; }
.sidebar-logo span { font-size: 15px; font-weight: 700; color: #6366f1; }
.app-sidebar.collapsed .sidebar-logo { justify-content: center; padding: 0; }
.app-sidebar.collapsed .sidebar-logo span { display: none; }

.sidebar-collapse-btn {
    position: absolute; right: -9px; top: 50%; transform: translateY(-50%);
    width: 18px; height: 18px;
    background: #fff; border: 1px solid #e2e8f0;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: #94a3b8; font-size: 8px;
    transition: all 0.15s; z-index: 5;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.sidebar-collapse-btn:hover { background: #6366f1; color: #fff; border-color: #6366f1; }
.app-sidebar.collapsed .sidebar-collapse-btn { right: -10px; }
.app-sidebar.collapsed .sidebar-collapse-btn i { transform: rotate(180deg); }

/* 导航区 */
.sidebar-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 10px 0; }
.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: #e2e8f0; border-radius: 2px; }

.nav-group { margin-bottom: 6px; }
.nav-group-title {
    padding: 8px 14px 4px;
    font-size: 10px; font-weight: 600;
    color: #94a3b8; text-transform: uppercase;
    letter-spacing: 1.5px;
}

.nav-item {
    display: flex; align-items: center;
    padding: 7px 14px; margin: 1px 8px;
    border-radius: 6px;
    color: #475569; text-decoration: none;
    font-size: 13px; gap: 8px;
    transition: all 0.15s; cursor: pointer;
    white-space: nowrap;
}
.nav-item:hover { background: #f1f5f9; color: #1e293b; }
.nav-item.active { background: #6366f1; color: #fff; font-weight: 500; }
.nav-item .nav-icon { font-size: 14px; width: 18px; text-align: center; flex-shrink: 0; }
.nav-item .nav-label { flex: 1; }

.nav-parent { position: relative; }
.nav-chevron {
    margin-left: auto; font-size: 9px;
    transition: transform 0.2s; opacity: 0.3;
}
.nav-parent:not(.expanded) .nav-chevron { transform: rotate(-90deg); }

.nav-children { overflow: hidden; max-height: 600px; transition: max-height 0.25s; }
.nav-children.collapsed { max-height: 0; }

.nav-sub {
    display: flex; align-items: center;
    padding: 5px 14px 5px 40px;
    color: #64748b; text-decoration: none;
    font-size: 12px; gap: 6px;
    transition: all 0.15s; white-space: nowrap;
}
.nav-sub:hover { background: #f8fafc; color: #475569; }
.nav-sub.active { color: #6366f1; background: #eef2ff; font-weight: 500; }
.nav-sub .sub-icon { font-size: 12px; width: 14px; text-align: center; flex-shrink: 0; }
.nav-sub .sub-label { flex: 1; }
.nav-sub .nav-count {
    margin-left: auto; font-size: 10px;
    padding: 1px 5px; background: #f1f5f9;
    border-radius: 4px; color: #94a3b8;
}

.nav-divider { height: 1px; background: #f1f5f9; margin: 6px 12px; }

/* 折叠状态 */
.app-sidebar.collapsed .nav-group-title,
.app-sidebar.collapsed .nav-label,
.app-sidebar.collapsed .nav-chevron,
.app-sidebar.collapsed .nav-children,
.app-sidebar.collapsed .sub-label,
.app-sidebar.collapsed .nav-count,
.app-sidebar.collapsed .nav-divider { display: none; }
.app-sidebar.collapsed .nav-item,
.app-sidebar.collapsed .nav-sub {
    justify-content: center; padding: 9px 0; margin: 2px 8px;
}
.app-sidebar.collapsed .nav-item .nav-icon { font-size: 16px; width: auto; }

/* ========== 右侧主区域 ========== */
.app-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

.app-tabs {
    height: 38px; min-height: 38px;
    background: #fff; border-bottom: 1px solid #e2e8f0;
    display: flex; align-items: center;
    padding: 0 8px; gap: 4px;
    overflow-x: auto; overflow-y: hidden;
    flex-shrink: 0;
}
.app-tabs::-webkit-scrollbar { height: 2px; }
.app-tabs::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 1px; }

.tab-item {
    display: flex; align-items: center; gap: 5px;
    padding: 4px 12px; border-radius: 5px;
    font-size: 12px; color: #64748b;
    cursor: pointer; transition: all 0.15s;
    white-space: nowrap; user-select: none;
}
.tab-item:hover { background: #f1f5f9; }
.tab-item.active { background: #eef2ff; color: #6366f1; font-weight: 500; }
.tab-item .tab-icon { font-size: 11px; }
.tab-item .tab-close {
    font-size: 9px; opacity: 0.2; transition: opacity 0.15s;
    margin-left: 2px; padding: 1px 3px; border-radius: 2px;
}
.tab-item:hover .tab-close { opacity: 0.5; }
.tab-item .tab-close:hover { opacity: 1; color: #ef4444; background: #fef2f2; }

/* 内容区 */
.app-content {
    flex: 1; overflow-y: auto; overflow-x: hidden;
    background: #f8fafc;
}
.app-content::-webkit-scrollbar { width: 6px; }
.app-content::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
.app-content::-webkit-scrollbar-track { background: transparent; }

/* 移动端 */
@media (max-width: 768px) {
    .app-sidebar {
        position: fixed; left: -180px; z-index: 2000;
        transition: left 0.3s; box-shadow: 4px 0 24px rgba(0,0,0,0.15);
    }
    .app-sidebar.mobile-open { left: 0; }
    .app-sidebar.collapsed { width: 50px; min-width: 50px; }
}

.mobile-menu-btn {
    position: fixed; top: 10px; left: 10px;
    width: 34px; height: 34px;
    background: #fff; border: 1px solid #e2e8f0;
    border-radius: 8px; display: none;
    align-items: center; justify-content: center;
    color: #6366f1; font-size: 15px;
    cursor: pointer; z-index: 1900;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.mobile-menu-btn:hover { background: #f1f5f9; }
@media (max-width: 768px) { .mobile-menu-btn { display: flex; } }

.sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.3); z-index: 1999;
}
.sidebar-overlay.active { display: block; }
@media (min-width: 769px) { .sidebar-overlay { display: none !important; } }

/* ========== 用户系统样式 ========== */

/* 用户区（标签栏右侧） */
.user-area {
  margin-left: auto; display: flex; align-items: center; gap: 8px;
  padding-right: 8px; flex-shrink: 0;
}
.user-btn {
  padding: 4px 12px; border: 1px solid #e2e8f0; background: #fff;
  border-radius: 5px; font-size: 12px; color: #6366f1; cursor: pointer;
  transition: all 0.15s; white-space: nowrap;
}
.user-btn:hover { background: #eef2ff; border-color: #6366f1; }
.user-btn.primary { background: #6366f1; color: #fff; border-color: #6366f1; }
.user-btn.primary:hover { background: #4f46e5; }
.user-name { font-size: 12px; color: #475569; font-weight: 500; }

/* 提交按钮 */
.submit-dropdown { position: relative; }
.submit-menu {
  display: none; position: absolute; top: 100%; right: 0;
  background: #fff; border: 1px solid #e2e8f0; border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08); z-index: 100;
  min-width: 140px; padding: 4px 0; margin-top: 4px;
}
.submit-dropdown:hover .submit-menu { display: block; }
.submit-menu a {
  display: block; padding: 8px 14px; font-size: 12px; color: #475569;
  text-decoration: none; transition: all 0.1s;
}
.submit-menu a:hover { background: #f1f5f9; color: #6366f1; }

/* 登录弹窗 */
.auth-modal-overlay {
  display: flex; align-items: center; justify-content: center;
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  z-index: 3000;
}
.auth-modal {
  background: #fff; border-radius: 12px; padding: 28px 24px;
  width: 360px; max-width: 90vw;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  position: relative;
}
.auth-modal h2 { margin: 0 0 18px; font-size: 18px; color: #1e293b; }
.auth-close {
  position: absolute; top: 12px; right: 14px;
  border: none; background: none; font-size: 18px;
  color: #94a3b8; cursor: pointer;
}
.auth-modal input, .auth-modal textarea, .auth-modal select {
  width: 100%; padding: 10px 12px; margin: 6px 0;
  border: 1px solid #e2e8f0; border-radius: 8px;
  font-size: 14px; outline: none; box-sizing: border-box;
  font-family: inherit;
}
.auth-modal input:focus, .auth-modal textarea:focus, .auth-modal select:focus {
  border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}
.auth-modal textarea { resize: vertical; min-height: 100px; }
.auth-error { color: #ef4444; font-size: 12px; margin: 4px 0; min-height: 18px; }
.auth-submit {
  width: 100%; padding: 10px; margin-top: 8px;
  background: #6366f1; color: #fff; border: none;
  border-radius: 8px; font-size: 14px; font-weight: 500;
  cursor: pointer; transition: all 0.15s;
}
.auth-submit:hover { background: #4f46e5; }
.auth-switch { text-align: center; font-size: 12px; color: #94a3b8; margin-top: 14px; }
.auth-switch a { color: #6366f1; text-decoration: none; }

/* Toast */
.toast-msg {
  position: fixed; bottom: 40px; left: 50%; transform: translateX(-50%);
  background: #1e293b; color: #fff; padding: 10px 24px;
  border-radius: 8px; font-size: 13px; z-index: 4000;
  opacity: 0; transition: opacity 0.3s; pointer-events: none;
}
.toast-msg.show { opacity: 1; }

/* 收藏卡片 */
.fav-empty { text-align: center; padding: 24px; color: #94a3b8; font-size: 13px; }
.fav-empty a { color: #6366f1; }
.fav-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: #fff; border-radius: 8px;
  border: 1px solid #e2e8f0; text-decoration: none; color: inherit;
  transition: all 0.15s; position: relative;
}
.fav-card:hover { border-color: #6366f1; box-shadow: 0 2px 8px rgba(99,102,241,0.08); }
.fav-icon { font-size: 18px; }
.fav-name { flex: 1; font-size: 13px; font-weight: 500; color: #1e293b; }
.fav-tagline { display: none; @media(min-width:600px){display:block;font-size:11px;color:#94a3b8;max-width:200px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;} }
.fav-heat { font-size: 12px; color: #6366f1; font-weight: 600; }
.fav-remove {
  border: none; background: none; color: #94a3b8; cursor: pointer;
  font-size: 11px; padding: 2px 4px; border-radius: 3px;
}
.fav-remove:hover { color: #ef4444; background: #fef2f2; }

/* 点赞按钮 */
.like-btn {
  display: inline-flex; align-items: center; gap: 4px;
  border: 1px solid #e2e8f0; background: #fff;
  padding: 4px 10px; border-radius: 6px;
  font-size: 12px; color: #94a3b8; cursor: pointer;
  transition: all 0.15s;
}
.like-btn:hover { border-color: #6366f1; color: #6366f1; }
.like-btn.liked { background: #eef2ff; border-color: #6366f1; color: #6366f1; }
.like-btn .like-count { font-weight: 500; }

/* 收藏按钮（工具详情页用） */
.fav-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 6px 12px; border: 1px solid #e2e8f0; background: #fff;
  border-radius: 6px; font-size: 12px; color: #94a3b8; cursor: pointer;
  transition: all 0.15s;
}
.fav-btn:hover { border-color: #6366f1; color: #6366f1; }
.fav-btn.favorited { background: #eef2ff; border-color: #6366f1; color: #6366f1; }
