/* ============================================================
   layout.css —— 前台公共布局（导航 / 容器 / flash / footer / busy / toast）
   自包含，不依赖任何公共样式。
   被 views/layout_header.php + layout_footer.php 引入。
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px; line-height: 1.6; color: #1f2937; background: #f5f7fb;
}
a { color: #4f46e5; text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
h1, h2, h3, h4, h5 { margin: 0 0 .5em; font-weight: 700; line-height: 1.3; color: #111827; }
h1 { font-size: 1.7rem; } h2 { font-size: 1.4rem; } h3 { font-size: 1.15rem; }
h5 { font-size: 1rem; } h6 { font-size: .95rem; margin: 0; }
p { margin: 0 0 1em; }

.container { width: 100%; max-width: 1280px; margin: 0 auto; padding: 0 16px; }

.app-navbar {
  background: #fff; border-bottom: 1px solid #e5e7eb; position: sticky; top: 0; z-index: 100;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.app-navbar .container { display: flex; align-items: center; justify-content: space-between; padding-top: .7rem; padding-bottom: .7rem; position: relative; }
/* 品牌靠左：用负 margin 稍微往左推，更贴边 */
.navbar-brand { display: flex; align-items: center; gap: .5rem; font-size: 1.1rem; margin-left: -.35rem; }
.navbar-brand:hover { text-decoration: none; }
.brand-icon { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 8px; background: #4f46e5; color: #fff; font-weight: 800; font-size: 1rem; }
.brand-text { font-weight: 800; color: #111827; }
/* 导航链接：与品牌同级别，靠右平铺为四个按钮 */
.navbar-nav { list-style: none; margin: 0; padding: 0; display: flex; gap: 1.4rem; align-items: center; }
.nav-link { color: #374151; font-weight: 500; padding: .35rem 0; }
.nav-link:hover, .nav-link.active { color: #4f46e5; text-decoration: none; }
.app-nav-links { margin-left: auto; }
.app-nav-auth { margin-left: 1.2rem; }
/* 右上角按钮组：胶囊圆角，未登录的登录链接稍弱化 */
.app-navbar .btn-sm { border-radius: 999px; padding: .4rem 1.1rem; font-weight: 600; }
.navbar-toggler { display: none; background: none; border: 1px solid #d1d5db; border-radius: 6px; padding: .35rem .6rem; cursor: pointer; }
/* 因未引入 Bootstrap，手动绘制汉堡图标，避免显示成空方框 */
.navbar-toggler-icon {
  display: inline-block; width: 20px; height: 14px; position: relative;
}
.navbar-toggler-icon::before,
.navbar-toggler-icon::after,
.navbar-toggler-icon > i {
  content: ""; position: absolute; left: 0; right: 0; height: 2px;
  background: #374151; border-radius: 2px;
}
.navbar-toggler-icon::before { top: 0; }
.navbar-toggler-icon::after { bottom: 0; }
.navbar-toggler-icon > i { top: 6px; }

.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; right: 0; top: 110%; min-width: 200px; background: #fff;
  border: 1px solid #e5e7eb; border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,.08);
  padding: .4rem 0; z-index: 200; display: none;
}
.dropdown.show .dropdown-menu, .dropdown:hover .dropdown-menu { display: block; }
.dropdown-item { display: block; padding: .5rem 1rem; color: #374151; font-size: .9rem; }
.dropdown-item:hover { background: #f3f4f6; text-decoration: none; color: #4f46e5; }
.dropdown-divider { height: 1px; background: #e5e7eb; margin: .35rem 0; }

.quota-badge {
  display: inline-flex; align-items: center; gap: .35rem; font-size: .8rem;
  background: #eef2ff; color: #4338ca; padding: .25rem .6rem; border-radius: 999px; font-weight: 600;
}

.app-main { padding: 1.5rem 0; min-height: 60vh; }

.app-footer { text-align: center; color: #9ca3af; font-size: .82rem; padding: 2rem 0 3rem; }

/* Flash 提示 */
.flash { padding: .8rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid transparent; font-size: .9rem; }
.flash-success { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.flash-error, .flash-danger { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.flash-warning { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.flash-info { background: #dbeafe; color: #1e40af; border-color: #bfdbfe; }

/* 加载遮罩 + Toast */
.busy-overlay { position: fixed; inset: 0; background: rgba(255,255,255,.7); z-index: 2000; display: none; align-items: center; justify-content: center; }
.busy-overlay.show { display: flex; }
.spinner { width: 42px; height: 42px; border: 4px solid #eef2ff; border-top-color: #4f46e5; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast-wrap { position: fixed; top: 20px; right: 20px; z-index: 2100; display: flex; flex-direction: column; gap: .5rem; }
.toast { background: #111827; color: #fff; padding: .7rem 1.1rem; border-radius: 8px; font-size: .88rem; box-shadow: 0 4px 16px rgba(0,0,0,.08); animation: toastIn .2s ease; max-width: 320px; }
.toast.success { background: #166534; }
.toast.error { background: #991b1b; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } }

.text-muted { color: #6b7280; }
.text-center { text-align: center; }
.small { font-size: .875rem; }
.text-danger { color: #dc2626; }

@media (max-width: 768px) {
  .app-navbar .container { flex-wrap: wrap; }
  .app-nav-links { margin-left: 0; order: 3; width: 100%; gap: .8rem; flex-wrap: wrap; margin-top: .5rem; }
  .app-nav-auth { margin-left: auto; }
  .navbar-nav { font-size: .9rem; }
}

/* 右上角 toast 弹窗提示（替代 Bootstrap alert） */
.toast {
  position: fixed; bottom: 24px; left: 24px; z-index: 1080;
  display: flex; align-items: center; gap: .55rem;
  min-width: 260px; max-width: 380px;
  padding: .8rem 1rem; border-radius: 12px;
  background: #fff; color: #1f2937;
  box-shadow: 0 12px 34px rgba(15, 23, 42, .22);
  border: 1px solid #e5e7eb; border-left: 4px solid #4f46e5;
  animation: toast-in .25s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translateX(-14px); } to { opacity: 1; transform: translateX(0); } }
.toast.toast-success { border-left-color: #16a34a; }
.toast.toast-danger  { border-left-color: #dc2626; }
.toast.toast-warning { border-left-color: #d97706; }
.toast.toast-info    { border-left-color: #2563eb; }
.toast-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%; font-size: .8rem; font-weight: 700; color: #fff; flex: none;
}
.toast-success .toast-icon { background: #16a34a; }
.toast-danger  .toast-icon { background: #dc2626; }
.toast-warning .toast-icon { background: #d97706; }
.toast-info    .toast-icon { background: #2563eb; }
.toast-msg { flex: 1; font-size: .92rem; line-height: 1.4; }
.toast-close {
  border: none; background: none; color: #9ca3af; font-size: 1.1rem; line-height: 1;
  cursor: pointer; padding: 0 .2rem; flex: none;
}
.toast-close:hover { color: #4b5563; }
