/* ==========================================================================
   茱萸 ZhuYu Design System — 基础扁平通用组件 (Components)
   Style: Linear / Notion Inspired Clean Flat & Border-driven
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. 按钮体系 (Buttons)
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  transition: all var(--transition-fast);
  background: var(--bg-surface);
  color: var(--text-primary);
}

.btn:disabled, .btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* 主按钮 - 琉璃金高保真扁平 */
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  font-weight: 600;
}
.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #ffffff;
}
.btn-primary:active {
  background: var(--primary-active);
  border-color: var(--primary-active);
}

/* 次级线框按钮 */
.btn-secondary, .btn-outline {
  background: var(--bg-surface);
  border-color: var(--border-strong);
  color: var(--text-primary);
}
.btn-secondary:hover, .btn-outline:hover {
  background: var(--bg-subtle);
  border-color: #beb7a7;
  color: var(--text-primary);
}
.btn-secondary:active, .btn-outline:active {
  background: var(--bg-hover);
}

/* 危险/警告按钮 */
.btn-danger {
  background: var(--status-danger-bg);
  border-color: var(--status-danger-border);
  color: var(--status-danger);
  font-weight: 500;
}
.btn-danger:hover {
  background: var(--status-danger);
  border-color: var(--status-danger);
  color: #ffffff;
}

/* 按钮尺寸 */
.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: var(--radius-xs);
  gap: 5px;
}
.btn-xs {
  padding: 4px 9px;
  font-size: 12px;
  border-radius: var(--radius-xs);
  gap: 4px;
}
.btn-lg {
  padding: 10px 22px;
  font-size: 15px;
  border-radius: var(--radius-md);
}

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  background: var(--bg-surface);
  color: var(--text-secondary);
}
.btn-icon:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

/* --------------------------------------------------------------------------
   2. 徽标与胶囊标签 (Badges & Pills)
   -------------------------------------------------------------------------- */
.badge, .pill-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.2;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-light);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  white-space: nowrap;
}

.badge-gold, .pill-gold {
  background: var(--primary-subtle);
  border-color: var(--primary-border);
  color: var(--primary-text);
  font-weight: 600;
}

.badge-success, .pill-free {
  background: var(--status-success-bg);
  border-color: var(--status-success-border);
  color: var(--status-success);
}

.badge-warning, .pill-warning {
  background: var(--status-warning-bg);
  border-color: var(--status-warning-border);
  color: var(--status-warning);
}

.badge-danger, .pill-red {
  background: var(--status-danger-bg);
  border-color: var(--status-danger-border);
  color: var(--status-danger);
}

.badge-info, .pill-info {
  background: var(--status-info-bg);
  border-color: var(--status-info-border);
  color: var(--status-info);
}

/* 微型状态胶囊 */
.stat-micro-pill {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  font-weight: 600;
  border: 1px solid transparent;
  line-height: 1.3;
  display: inline-flex;
  align-items: center;
}

.stat-micro-pill.pill-free {
  background: var(--status-success-bg);
  color: var(--status-success);
  border: 1px solid var(--status-success-border);
}

.stat-micro-pill.pill-gold {
  background: var(--primary-bg);
  color: var(--primary-text);
  border: 1px solid var(--primary-border);
}

.stat-micro-pill.pill-red {
  background: var(--status-danger-bg);
  color: var(--status-danger);
  border: 1px solid var(--status-danger-border);
}

/* --------------------------------------------------------------------------
   3. 表单与输入控件 (Forms & Inputs)
   -------------------------------------------------------------------------- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
}
.form-label.required::after {
  content: "*";
  color: var(--status-danger);
  font-size: 14px;
}

.form-input, .form-select, .form-textarea, .search-input {
  width: 100%;
  padding: 9px 13px;
  font-size: 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
}

.form-input:hover, .form-select:hover, .form-textarea:hover, .search-input:hover {
  border-color: var(--border-strong);
}

.form-input:focus, .form-select:focus, .form-textarea:focus, .search-input:focus {
  border-color: var(--primary);
  background: #ffffff;
}

.form-input::placeholder, .search-input::placeholder, .form-textarea::placeholder {
  color: var(--text-tertiary);
}

.form-select {
  cursor: pointer;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235a646e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px;
  padding-right: 32px;
  appearance: none;
}

.form-row {
  display: flex;
  gap: var(--space-3);
  align-items: center;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-4);
}

/* --------------------------------------------------------------------------
   4. 通用卡片与控制台卡片 (Cards & Containers)
   -------------------------------------------------------------------------- */
.card, .dorm-console-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-none);
  transition: border-color var(--transition-fast);
}

.card:hover {
  border-color: var(--border-strong);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: var(--space-4);
  margin-bottom: var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* 视图切换 Tabs (如看板 / 花名册) */
.view-tabs {
  display: inline-flex;
  background: var(--bg-subtle);
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  gap: 2px;
}

.view-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 15px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
  transition: all var(--transition-fast);
}

.view-tab:hover {
  color: var(--text-primary);
}

.view-tab.active {
  background: #ffffff;
  color: var(--primary-text);
  font-weight: 600;
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-subtle);
}

/* --------------------------------------------------------------------------
   5. 数据表格 (Flat Data Table)
   -------------------------------------------------------------------------- */
.table-container, .custom-table-container {
  width: 100%;
  overflow-x: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
}

.table, .data-table, .custom-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 14px;
}

.table th, .data-table th, .custom-table th {
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 13px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.table td, .data-table td, .custom-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  vertical-align: middle;
  transition: background-color var(--transition-fast);
}

.table tbody tr:last-child td, .data-table tbody tr:last-child td, .custom-table tbody tr:last-child td {
  border-bottom: none;
}

.table tbody tr:hover td, .data-table tbody tr:hover td, .custom-table tbody tr:hover td {
  background-color: var(--bg-subtle);
}

.table-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.custom-table select,
.custom-table .form-select-sm {
  height: 30px;
  padding: 2px 24px 2px 8px;
  font-size: 13px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xs);
  background: var(--bg-surface);
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition-fast);
}

.custom-table select:focus,
.custom-table .form-select-sm:focus {
  border-color: var(--primary);
}

/* 表格分页条 */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--border-light);
  background: var(--bg-surface);
  font-size: 13px;
  color: var(--text-secondary);
}

.page-controls {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.page-btn {
  padding: 5px 12px;
  font-size: 13px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-light);
  background: var(--bg-surface);
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.page-btn:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: var(--bg-subtle);
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.page-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   6. 全局弹窗体系 (Modals & Dialogs)
   -------------------------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(25, 32, 38, 0.45);
  backdrop-filter: blur(4px);
  z-index: 999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.modal-overlay.active {
  display: flex;
  opacity: 1;
}

.modal-container {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-overlay);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.97);
  transition: transform var(--transition-normal);
}

.modal-container.modal-lg {
  max-width: 820px;
}

.modal-container.modal-xl {
  max-width: 980px;
}

.modal-overlay.active .modal-container {
  transform: scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-surface);
}

.modal-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.modal-close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xs);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: 14px 20px;
  border-top: 1px solid var(--border-light);
  background: var(--bg-subtle);
}

/* --------------------------------------------------------------------------
   6.5 自定义弹窗对话框 (Custom Alert & Confirm Dialogs)
   -------------------------------------------------------------------------- */
#custom-dialog-container {
  position: relative;
  z-index: 100000;
}

.custom-dialog-overlay {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100000;
  padding: 1rem;
  box-sizing: border-box;
  animation: fadeInDialogOverlay 0.18s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

.custom-dialog {
  background: #ffffff;
  border-radius: 14px;
  padding: 1.75rem 1.5rem;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 20px 45px -10px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.05);
  box-sizing: border-box;
  animation: slideUpDialogBox 0.22s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  text-align: center;
}

@keyframes slideUpDialogBox {
  from {
    transform: translateY(18px) scale(0.96);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

.custom-dialog-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin: 0 auto 1.1rem auto;
  box-sizing: border-box;
}

.custom-dialog-icon.alert-info {
  background: #eff6ff;
  color: #2563eb;
  border: 1px solid #bfdbfe;
}

.custom-dialog-icon.alert-warning {
  background: #fffbeb;
  color: #d97706;
  border: 1px solid #fde68a;
}

.custom-dialog-icon.alert-danger {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
}

.custom-dialog-icon.alert-success {
  background: #f0fdf4;
  color: #16a34a;
  border: 1px solid #bbf7d0;
}

.custom-dialog-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #1e293b;
  text-align: center;
  margin-bottom: 0.55rem;
  line-height: 1.35;
}

.custom-dialog-message {
  font-size: 0.92rem;
  color: #475569;
  text-align: center;
  line-height: 1.6;
  margin-bottom: 1.5rem;
  word-break: break-word;
}

.custom-dialog-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  align-items: center;
}

.custom-dialog-actions .btn {
  padding: 8px 18px;
  font-size: 0.92rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

/* --------------------------------------------------------------------------
   7. 提示与警告条 (Alerts & Tips)
   -------------------------------------------------------------------------- */
.tip-banner, .dorm-console-tip {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.5;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  margin-top: var(--space-3);
}

.tip-banner i, .dorm-console-tip i {
  color: var(--primary);
  margin-top: 2px;
  flex-shrink: 0;
}

.role-restricted-banner {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px 12px;
  font-size: 13px;
  border-radius: var(--radius-sm);
  background: var(--status-warning-bg);
  border: 1px solid var(--status-warning-border);
  color: var(--status-warning);
}

/* --------------------------------------------------------------------------
   8. 极简轻量浮动通知 (Toasts)
   -------------------------------------------------------------------------- */
.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: 10000;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 11px 18px;
  min-width: 240px;
  max-width: 380px;
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-left-width: 4px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-dropdown);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  animation: toastIn 0.2s cubic-bezier(0.2, 0, 0, 1) forwards;
}

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

/* --------------------------------------------------------------------------
   9. 空状态 (Empty State)
   -------------------------------------------------------------------------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  color: var(--text-tertiary);
  gap: var(--space-2);
}

.empty-state i {
  font-size: 36px;
  color: var(--border-strong);
  margin-bottom: var(--space-2);
}

.empty-state-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
}

.empty-state-desc {
  font-size: 13px;
  color: var(--text-tertiary);
  max-width: 320px;
}
