/* 组织头条 · 全局布局与组件样式 */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: var(--fs-base);
  color: var(--text);
  background: #E5E5E5;
  -webkit-font-smoothing: antialiased;
}

/* App shell: 桌面预览时居中手机框 */
.app-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  background: var(--bg);
}

.desktop-stage {
  display: flex;
  width: 100%;
  min-height: 100vh;
  padding: 24px;
  gap: 24px;
  justify-content: center;
  align-items: flex-start;
}

.desktop-stage .side-panel {
  width: 320px;
  flex-shrink: 0;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 48px);
}

.desktop-stage .phone-frame {
  width: var(--phone-w);
  max-height: calc(100vh - 48px);
  background: var(--surface);
  border-radius: 32px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* 顶部端切换条 */
.top-bar {
  height: var(--header-h);
  background: var(--brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--sp-4);
  flex-shrink: 0;
  z-index: 10;
}

.top-bar .brand {
  font-weight: 700;
  font-size: var(--fs-h2);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.top-bar .end-tabs {
  display: flex;
  gap: var(--sp-1);
}

.end-tab {
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--radius);
  font-size: var(--fs-caption);
  cursor: pointer;
  opacity: 0.8;
  transition: opacity 0.15s, background 0.15s;
  white-space: nowrap;
}

.end-tab:hover { opacity: 1; }
.end-tab.active { background: rgba(255,255,255,0.2); opacity: 1; font-weight: 600; }

.end-tab[data-end="entry"] { border-bottom: 2px solid var(--brand-org123); }
.end-tab[data-end="student"] { border-bottom: 2px solid var(--brand-classroom); }
.end-tab[data-end="enterprise"] { border-bottom: 2px solid var(--brand-community); }
.end-tab[data-end="association"] { border-bottom: 2px solid var(--brand-orgtoutiao); }
.end-tab[data-end="platform"] { border-bottom: 2px solid var(--brand-orgtoutiao); }
.end-tab[data-end="mirror"] { border-bottom: 2px solid var(--brand-mirror); }

/* 角色切换器与协会切换器 */
.switchers {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.role-switcher, .org-switcher {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-caption);
  background: rgba(255,255,255,0.12);
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--radius);
}

.role-switcher select, .org-switcher select {
  border: 0;
  background: transparent;
  color: #fff;
  font-size: var(--fs-caption);
  outline: none;
  cursor: pointer;
  font-weight: 600;
}

.role-switcher select option, .org-switcher select option { color: var(--text); }

/* 协会 pills */
.pills-bar {
  display: flex;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  background: var(--surface);
  border-bottom: 1px solid var(--border-light);
  overflow-x: auto;
  flex-shrink: 0;
}

.pill {
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--radius-full);
  background: var(--border-light);
  color: var(--text-secondary);
  font-size: var(--fs-caption);
  white-space: nowrap;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
}

.pill:hover { background: var(--surface-2); }
.pill.active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

/* 左导航 */
.side-nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-3) 0;
}

.nav-group { margin-bottom: var(--sp-3); }
.nav-group-title {
  padding: var(--sp-2) var(--sp-4);
  font-size: var(--fs-caption);
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-2) var(--sp-4);
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background 0.12s;
}

.nav-item:hover { background: var(--surface-2); }
.nav-item.active {
  background: var(--surface-2);
  border-left-color: var(--brand);
  color: var(--brand);
  font-weight: 600;
}

.nav-item .status-badge {
  font-size: 10px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--border-light);
  color: var(--text-muted);
}

.nav-item .status-badge.ok { background: #D1FAE5; color: #065F46; }
.nav-item .status-badge.warn { background: #FEF3C7; color: #92400E; }
.nav-item .status-badge.err { background: #FEE2E2; color: #991B1B; }

/* 主画布 */
.main-canvas {
  flex: 1;
  overflow-y: auto;
  position: relative;
  background: var(--bg);
}

.canvas-inner { padding: var(--sp-4); min-height: 100%; }

/* 手机底部 tab bar（仅学员端显示） */
.bottom-tabs {
  display: flex;
  height: 56px;
  background: var(--surface);
  border-top: 1px solid var(--border-light);
  flex-shrink: 0;
}

.bottom-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: var(--fs-caption);
}

.bottom-tab.active { color: var(--brand); }

.bottom-tab .icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

/* 通用组件 */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--sp-4);
  margin-bottom: var(--sp-4);
}

.card-title {
  font-size: var(--fs-h3);
  font-weight: 600;
  margin: 0 0 var(--sp-3) 0;
}

.card-subtitle {
  font-size: var(--fs-caption);
  color: var(--text-muted);
  margin: calc(-1 * var(--sp-3)) 0 var(--sp-3) 0;
}

.section-title {
  font-size: var(--fs-h2);
  font-weight: 700;
  margin-bottom: var(--sp-4);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-light);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-1);
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--radius);
  border: none;
  font-size: var(--fs-base);
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.05s;
  text-decoration: none;
}

.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--brand); color: #fff; }
.btn-sub { background: var(--sub); color: #fff; }
.btn-outline { background: var(--surface); color: var(--brand); border: 1px solid var(--brand); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-danger { background: var(--danger); color: #fff; }

.btn-block { width: 100%; }
.btn-sm { padding: var(--sp-1) var(--sp-3); font-size: var(--fs-caption); }

/* Forms */
.form-group { margin-bottom: var(--sp-4); }
.form-label {
  display: block;
  font-size: var(--fs-caption);
  color: var(--text-secondary);
  margin-bottom: var(--sp-1);
  font-weight: 500;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: var(--fs-base);
  outline: none;
  transition: border-color 0.15s;
}

.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--brand); }

.form-input::placeholder { color: var(--text-muted); }

.form-row {
  display: flex;
  gap: var(--sp-3);
  align-items: center;
}

.form-row .form-group { flex: 1; }

/* List items */
.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
}

.list-item:last-child { border-bottom: none; }

.list-item .meta { color: var(--text-muted); font-size: var(--fs-caption); }

/* Tabs */
.tabs {
  display: flex;
  gap: var(--sp-2);
  border-bottom: 1px solid var(--border-light);
  margin-bottom: var(--sp-4);
  overflow-x: auto;
}

.tab {
  padding: var(--sp-2) var(--sp-3);
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}

.tab.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
  font-weight: 600;
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-6) var(--sp-4);
  color: var(--text-muted);
  text-align: center;
}

.empty-state .icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin-bottom: var(--sp-3);
}

/* Breadcrumb */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  font-size: var(--fs-caption);
  color: var(--text-muted);
  margin-bottom: var(--sp-3);
  flex-wrap: wrap;
}

.breadcrumb span:not(:last-child)::after {
  content: "/";
  margin-left: var(--sp-1);
  color: var(--border);
}

.breadcrumb .crumb-link { cursor: pointer; color: var(--brand); }
.breadcrumb .crumb-link:hover { text-decoration: underline; }

/* Modal / Toast */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--sp-4);
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 400px;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  padding: var(--sp-4);
  border-bottom: 1px solid var(--border-light);
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-body { padding: var(--sp-4); overflow-y: auto; }
.modal-footer {
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--border-light);
  display: flex;
  gap: var(--sp-3);
  justify-content: flex-end;
}

.toast-container {
  position: fixed;
  top: calc(var(--header-h) + 12px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  pointer-events: none;
}

.toast {
  background: rgba(30,30,30,0.92);
  color: #fff;
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--radius);
  font-size: var(--fs-caption);
  box-shadow: var(--shadow-lg);
  animation: fadeInDown 0.2s ease;
  pointer-events: auto;
  max-width: 320px;
  text-align: center;
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Status chips */
.chip {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--sp-2);
  border-radius: var(--radius-full);
  font-size: var(--fs-caption);
  font-weight: 500;
}
.chip-success { background: #D1FAE5; color: #065F46; }
.chip-warning { background: #FEF3C7; color: #92400E; }
.chip-danger { background: #FEE2E2; color: #991B1B; }
.chip-info { background: #DBEAFE; color: #1E40AF; }
.chip-default { background: var(--border-light); color: var(--text-secondary); }

/* Progress bar */
.progress {
  height: 8px;
  background: var(--border-light);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--brand);
  border-radius: var(--radius-full);
  transition: width 0.3s;
}

/* Media / Feed cards */
.feed-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-3);
  cursor: pointer;
  transition: box-shadow 0.15s;
}

.feed-card:hover { box-shadow: var(--shadow); }

.feed-card .title { font-weight: 600; margin-bottom: var(--sp-1); line-height: 1.4; }
.feed-card .meta { font-size: var(--fs-caption); color: var(--text-muted); display: flex; gap: var(--sp-3); }
.feed-card .tag { color: var(--brand); font-weight: 600; }

/* Placeholder skeletons */
.skeleton { background: linear-gradient(90deg, #F3F4F6 25%, #E5E7EB 50%, #F3F4F6 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: var(--radius); }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Utility */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-brand { color: var(--brand); }
.mt-1 { margin-top: var(--sp-1); }
.mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); }
.mb-2 { margin-bottom: var(--sp-2); }
.mb-3 { margin-bottom: var(--sp-3); }
.mb-4 { margin-bottom: var(--sp-4); }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }
.justify-between { justify-content: space-between; }
.items-center { align-items: center; }
.w-full { width: 100%; }

/* Scrollbar styling */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.25); }

/* App mode helpers */
.hidden { display: none !important; }
