/* ===================================================================
   Tiamo Family Portal - UI Design System Specification
   Aliged with Tiamo Design System & UI Style Guide (documents/UI_STYLE_GUIDE.md)
   =================================================================== */

:root {
  /* --- 字体栈 --- */
  --font-primary: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans SC', sans-serif;

  /* --- 品牌主色系 (Primary Indigo) --- */
  --brand-primary: #4f46e5;          /* 主色：indigo-600 */
  --brand-primary-hover: #4338ca;    /* 悬停态：indigo-700 */
  --brand-primary-light: #eef2ff;    /* 极浅强调底色：indigo-50 */
  --brand-primary-glow: rgba(79, 70, 229, 0.22);

  /* --- 中性灰度色系 (Neutral Slate) --- */
  --bg-base: #f8fafc;                /* 页面整体底色：slate-50 */
  --surface-card: #ffffff;           /* 卡片与浮层：纯白 */
  --surface-glass: rgba(255, 255, 255, 0.88);
  --border-color: #e2e8f0;           /* 核心分隔线：slate-200 */
  --border-subtle: rgba(226, 232, 240, 0.8);

  /* --- 文本色阶 (Text) --- */
  --text-main: #0f172a;              /* 主标题、正文强调：slate-900 */
  --text-regular: #334155;           /* 正文常规：slate-700 */
  --text-muted: #64748b;             /* 辅助说明、占位符：slate-500 */
  --text-disabled: #94a3b8;          /* 禁用态文本：slate-400 */

  /* --- 状态功能色 (Feedback) --- */
  --color-success: #10b981;          /* 成功态：emerald-500 */
  --color-warning: #f59e0b;          /* 警告态：amber-500 */
  --color-danger: #ef4444;           /* 危险/删除：red-500 */
  --color-info: #0284c7;             /* 提示信息：sky-600 */

  /* --- 阴影系统 (Elevation Scale) --- */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
  --shadow-glass: 0 4px 30px rgba(0, 0, 0, 0.03);

  /* --- 圆角系统 --- */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* --- 微交互过渡 --- */
  --transition-tactile: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* -------------------------------------------------------------
   全局细长胶囊滚动条 (UI Style Guide 4.3)
------------------------------------------------------------- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

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

html, body {
  width: 100%;
  min-height: 100vh;
  font-family: var(--font-primary);
  color: var(--text-main);
  background-color: var(--bg-base);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* -------------------------------------------------------------
   背景层设计：通透轻磨砂环境微光 (Glassmorphism & Depth)
------------------------------------------------------------- */
.bg-wrapper {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.bg-image {
  position: absolute;
  inset: -15px;
  background-size: cover;
  background-position: center 30%;
  background-repeat: no-repeat;
  filter: brightness(0.98) saturate(0.85);
  opacity: 0.18;
  transform: scale(1.02);
}

.bg-overlay {
  position: absolute;
  inset: 0;
  background: 
    radial-gradient(circle at 15% 15%, rgba(79, 70, 229, 0.05) 0%, transparent 45%),
    radial-gradient(circle at 85% 80%, rgba(2, 132, 199, 0.05) 0%, transparent 45%),
    linear-gradient(180deg, rgba(248, 250, 252, 0.88) 0%, rgba(248, 250, 252, 0.96) 100%);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.ambient-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.25;
  pointer-events: none;
}

.glow-1 {
  width: 520px;
  height: 520px;
  top: -120px;
  left: 8%;
  background: radial-gradient(circle, rgba(79, 70, 229, 0.2) 0%, transparent 70%);
}

.glow-2 {
  width: 560px;
  height: 560px;
  bottom: -120px;
  right: 12%;
  background: radial-gradient(circle, rgba(2, 132, 199, 0.18) 0%, transparent 70%);
}

/* -------------------------------------------------------------
   主页面容器 (Layout Archetype)
------------------------------------------------------------- */
.portal-container {
  position: relative;
  z-index: 1;
  width: 100%;
  min-height: calc(100vh - 34px);
  min-height: calc(100dvh - 34px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1.5rem 3rem 1.25rem;
  max-width: 1360px;
  margin: 0 auto;
  box-sizing: border-box;
}

@media (min-height: 680px) and (min-width: 1024px) {
  html, body {
    height: 100%;
    overflow-y: hidden;
  }
  .portal-container {
    height: calc(100vh - 34px);
    height: calc(100dvh - 34px);
  }
}

/* -------------------------------------------------------------
   顶部 Header 区域 (Header Component Skeleton)
------------------------------------------------------------- */
.portal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 2rem;
  margin-bottom: 0.5rem;
  padding: 0.25rem 0;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  width: fit-content;
  padding: 0.3rem 0.8rem;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-sm);
}

.status-indicator {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--color-success);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
  animation: pulse-dot 2.5s infinite;
}

@keyframes pulse-dot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.25); opacity: 0.8; }
}

.brand-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-regular);
}

.portal-greeting {
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
  line-height: 1.25;
}

.portal-subtitle {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-muted);
}

/* 顶部右侧时钟小卡片 (Glassmorphism & Depth) */
.header-right {
  display: flex;
  align-items: center;
}

.clock-card {
  padding: 0.75rem 1.4rem;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow-sm);
  text-align: right;
  transition: var(--transition-tactile);
  user-select: none;
}

.clock-card:hover {
  background: #ffffff;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.clock-time {
  font-size: 1.75rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  color: var(--text-main);
  line-height: 1.1;
}

.clock-meta {
  margin-top: 0.2rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
}

.clock-divider {
  opacity: 0.5;
}

/* -------------------------------------------------------------
   中间主体：5 个应用横向卡片网格 (Microsoft 365 图 1 布局 + UI Style Guide 规范)
------------------------------------------------------------- */
.portal-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0 1rem 0;
  width: 100%;
  min-height: 0;
}

#portalSection {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* 核心应用分组栏 (Microsoft 365 图 1 头部规范) */
.shelf-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 1240px;
  margin: 0 auto 1.2rem;
  padding: 0 0.25rem;
}

.shelf-title-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.shelf-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text-main);
}

.shelf-badge {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--brand-primary);
  background: var(--brand-primary-light);
  padding: 0.18rem 0.65rem;
  border-radius: var(--radius-full);
  border: 1px solid rgba(79, 70, 229, 0.2);
}

.cards-shelf {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 1.5rem;
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  align-items: stretch;
}

/* 单个卡片容器 */
.portal-card {
  grid-column: span 2;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.45rem 1.65rem;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: var(--transition-tactile);
  cursor: pointer;
  outline: none;
  overflow: hidden;
  min-height: 138px;
}

/* 当刚好 5 张卡片时，第 2 行的第 4、第 5 张卡片自动优雅居中对齐 */
.cards-shelf:has(> .portal-card:nth-child(5):last-child) > .portal-card:nth-child(4) {
  grid-column: 2 / span 2;
}
.cards-shelf:has(> .portal-card:nth-child(5):last-child) > .portal-card:nth-child(5) {
  grid-column: 4 / span 2;
}

.portal-card:hover {
  transform: translateY(-3px);
  background: #ffffff;
  border-color: #cbd5e1;
  box-shadow: var(--shadow-lg);
}

.portal-card:active {
  transform: scale(0.98);
}

.portal-card:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 3px;
}

/* 顶部图标与标题栏 */
.portal-card-top {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.85rem;
  z-index: 1;
}

.portal-card-icon-wrap {
  width: 52px;
  height: 52px;
  border-radius: 0;
  overflow: visible;
  flex-shrink: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.portal-card:hover .portal-card-icon-wrap {
  transform: scale(1.06);
}

.portal-card-icon {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  border-radius: 0;
}

.portal-card-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.portal-card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.portal-card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.015em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
  line-height: 1.3;
  transition: color 0.15s ease;
}

.portal-card:hover .portal-card-title {
  color: var(--brand-primary);
}

.badge-tag {
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  width: fit-content;
}

/* 描述文本 (图 1 风格) */
.portal-card-desc {
  font-size: 0.86rem;
  line-height: 1.55;
  color: var(--text-muted);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  z-index: 1;
}

/* -------------------------------------------------------------
   极简白磨砂登录卡片 (Modal & Card Patterns - 5.5)
------------------------------------------------------------- */
.clean-login-card {
  max-width: 410px;
  width: 100%;
  margin: 0 auto;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 40px -10px rgba(15, 23, 42, 0.08);
  padding: 2.2rem 2rem;
  position: relative;
  z-index: 10;
}

.clean-card-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  margin-bottom: 1.6rem;
}

.clean-card-icon {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, #0284c7 0%, #38bdf8 100%);
  color: #ffffff;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.35);
}

.clean-card-icon img,
.clean-card-icon svg {
  width: 18px;
  height: 18px;
  display: block;
}

.clean-card-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #0f172a;
  line-height: 1.2;
}

.clean-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-regular);
  margin-bottom: 0.4rem;
}

.input-box {
  position: relative;
  display: flex;
  align-items: center;
}

.input-prefix-icon {
  position: absolute;
  left: 0.85rem;
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

.form-input {
  width: 100%;
  padding: 0.65rem 0.85rem 0.65rem 2.4rem;
  font-size: 0.88rem;
  font-family: inherit;
  color: var(--text-main);
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  outline: none;
  transition: var(--transition-tactile);
}

.form-input:focus {
  background: #ffffff;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px var(--brand-primary-light);
}

.pwd-toggle-btn {
  position: absolute;
  right: 0.6rem;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

.pwd-toggle-btn:hover {
  color: var(--text-main);
}

.clean-submit-btn {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: #ffffff;
  background: var(--brand-primary);
  border: none;
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 12px var(--brand-primary-glow);
  cursor: pointer;
  transition: var(--transition-tactile);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.5rem;
}

.clean-submit-btn:hover {
  background: var(--brand-primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.35);
}

.clean-submit-btn:active {
  transform: scale(0.97);
}

.clean-submit-btn:disabled {
  opacity: 0.6;
  pointer-events: none;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

.alert-box {
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  margin-bottom: 1rem;
  display: none;
}

.alert-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--color-danger);
}

/* -------------------------------------------------------------
   底部 Footer 区域
------------------------------------------------------------- */
.portal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 0 0.25rem 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-color);
  margin-top: auto;
  flex-shrink: 0;
}

.footer-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--color-success);
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
}

.footer-tips {
  display: flex;
  align-items: center;
  font-weight: 500;
}

/* -------------------------------------------------------------
   响应式断点适配
------------------------------------------------------------- */
@media (max-width: 1024px) {
  .portal-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1.2rem;
  }
  .header-right {
    width: 100%;
  }
  .clock-card {
    text-align: left;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .clock-meta {
    justify-content: flex-start;
    margin-top: 0;
  }
  .portal-main {
    padding: 1rem 0;
    justify-content: center;
  }
  .cards-shelf {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.2rem;
    width: 100%;
  }
  .portal-card {
    grid-column: auto !important;
    width: 100%;
  }
}

@media (max-width: 640px) {
  .portal-container {
    padding: 1.2rem 1rem;
    height: auto !important;
    min-height: calc(100vh - 34px);
  }
  html, body {
    overflow-y: auto !important;
  }
  .shelf-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
  .cards-shelf {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  .portal-card {
    grid-column: auto !important;
    width: 100%;
  }
  .portal-footer {
    flex-direction: column;
    gap: 0.75rem;
    text-align: center;
    padding: 1rem 0;
  }
}
