/* ========================================
 * JexHRAI 使用者儀表板樣式 (Material Design 3 Refactor)
 * ======================================== */
/* :root definitions removed to use global variables.css */

.jexhrai-user-dashboard-container {
  max-width: 1500px;
  width: calc(100% - 48px);
  margin: 3rem auto;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  /* Ensure modern font */
  color: var(--md-sys-color-on-surface);

}

/* ==========================================
 * Profile Card (Left Sidebar)
 * ========================================== */
.jexhrai-user-dashboard-container .profile-card {
  background-color: var(--md-sys-color-surface);
  border-radius: var(--jexhrai-container-radius);
  box-shadow: var(--jexhrai-container-shadow);
  padding: 2rem;
  text-align: center;
  position: sticky;
  top: 2rem;
  flex: 0 0 320px;
  /* Slightly wider for better spacing */
  transition: var(--jexhrai-transition-standard);
}

.jexhrai-user-dashboard-container .profile-card:hover {
  box-shadow: 0 0 0 10px var(--jexhrai-container-glow);
  border-color: var(--jexhrai-container-hover-border);
}

.profile-card .profile-avatar {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid var(--md-sys-color-primary-container);
  display: block;
  margin: 0 auto 1rem;
  box-shadow: var(--md-sys-elevation-2);
}

.profile-card h2 {
  margin: 0.5rem 0 0.25rem;
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--md-sys-color-on-surface);
  letter-spacing: -0.5px;
}

.profile-card .member-since {
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
  display: inline-block;
  background: var(--md-sys-color-surface-variant);
  padding: 4px 12px;
  border-radius: var(--md-sys-shape-corner-full);
}

.profile-card .settings-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--md-sys-color-surface-variant);
  color: var(--md-sys-color-on-surface-variant);
  border: 1px solid var(--md-sys-color-outline-variant);
  transition: all 0.2s;
  text-decoration: none;
}

.profile-card .settings-btn:hover {
  background-color: var(--md-sys-color-surface-variant);
  color: var(--md-sys-color-primary);
}

.profile-card .settings-btn .dashicons {
  font-size: 20px;
  width: 20px;
  height: 20px;
}

.level-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  padding: 0.4rem 1.2rem;
  border-radius: var(--md-sys-shape-corner-full);
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--md-sys-elevation-1);
}

/* XP Progress */
.xp-progress {
  text-align: left;
  margin-bottom: 2rem;
}

/* ==========================================
 * Profile Credits（AI 點數）
 * ========================================== */
.profile-card .profile-credits {
  margin: 0 0 1.25rem;
  padding: 0.9rem 1rem;
  border-radius: var(--radius-md, var(--md-sys-shape-corner-large));
  border: 1px solid var(--md-sys-color-outline-variant);
  background: color-mix(in srgb, var(--md-sys-color-primary-container), var(--md-sys-color-surface) 70%);
  color: var(--md-sys-color-on-primary-container);
  text-align: left;
}

.profile-card .profile-credits__header {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 10px;
}

.profile-card .profile-credits__header .dashicons {
  font-size: 20px;
  width: 20px;
  height: 20px;
  opacity: 0.95;
}

.profile-card .profile-credits__label {
  font-weight: 800;
  letter-spacing: 0.2px;
}

.profile-card .profile-credits__value {
  font-weight: 900;
  font-size: 1.15rem;
  color: var(--md-sys-color-on-primary-container);
}

.profile-card .profile-credits__hint {
  margin-top: 6px;
  font-size: 0.85rem;
  color: color-mix(in srgb, var(--md-sys-color-on-primary-container), transparent 25%);
  line-height: 1.35;
}

.xp-progress .labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--md-sys-color-on-surface-variant);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.progress-bar-bg {
  background-color: var(--md-sys-color-surface-variant);
  height: 12px;
  /* Thicker for MD3 feel */
  border-radius: var(--md-sys-shape-corner-small);
  overflow: hidden;
  position: relative;
}

.progress-bar-fg {
  background: var(--md-sys-color-primary);
  height: 100%;
  border-radius: var(--md-sys-shape-corner-small);
  width: 0;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

/* Sheen effect */
.progress-bar-fg::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  background: linear-gradient(90deg,
      transparent 0%,
      color-mix(in srgb, var(--md-sys-color-inverse-on-surface), transparent 60%) 50%,
      transparent 100%);
  transform: translateX(-100%);
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  100% {
    transform: translateX(100%);
  }
}

/* Stats */
.profile-stats {
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  width: 100%;
}

.profile-stats .stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0.5rem;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.profile-stats .stat-item:last-child {
  border-bottom: none;
}

.profile-stats .label {
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.95rem;
}

.profile-stats .value {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--md-sys-color-on-surface);
}

/* ==========================================
 * Dashboard Main Area
 * ========================================== */
.dashboard-main-card {
  background-color: transparent;
  /* Remove card bg from container, let sections have it or transparent */
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  flex: 1 1 auto;
}

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.dashboard-header h1 {
  margin: 0;
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--md-sys-color-on-surface);
}

/* Sections */
.courses-section,
.activity-section,
.capability-section {
  background-color: var(--md-sys-color-surface);
  border-radius: var(--jexhrai-container-radius);
  padding: 2rem;
  box-shadow: var(--jexhrai-container-shadow);
  transition: var(--jexhrai-transition-standard);
}

.courses-section:hover,
.activity-section:hover,
.capability-section:hover {
  box-shadow: 0 0 0 10px var(--jexhrai-container-glow);
  border-color: var(--jexhrai-container-hover-border);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  padding-bottom: 1rem;
}

.section-header h3 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--md-sys-color-on-surface);
}

.section-subtitle {
  font-size: 0.9rem;
  color: var(--md-sys-color-on-surface-variant);
  margin: 0.5rem 0 0;
}

/* Tabs - MD3 Style */
.tabs {
  display: flex;
  gap: 0.5rem;
  background-color: var(--md-sys-color-surface-variant);
  padding: 0.25rem;
  border-radius: var(--md-sys-shape-corner-full);
  /* Pill shape container */
}

.tab-button {
  padding: 0.5rem 1.5rem;
  border: none;
  background: transparent;
  border-radius: var(--md-sys-shape-corner-full);
  cursor: pointer;
  font-weight: 500;
  color: var(--md-sys-color-on-surface-variant);
  transition: all 0.2s ease;
  font-size: 0.9rem;
}

.tab-button:hover {
  color: var(--md-sys-color-on-surface);
  background-color: color-mix(in srgb, var(--md-sys-color-on-surface), transparent 92%);
}

.tab-button.active {
  background-color: var(--md-sys-color-surface);
  color: var(--md-sys-color-primary);
  box-shadow: var(--md-sys-elevation-1);
  font-weight: 600;
}

/* Course List Grid */
.course-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

/* Course Card - MD3 Filled Card */
.course-card-sm {
  background-color: var(--md-sys-color-surface-variant);
  /* Surface Variant for Filled Card */
  border-radius: var(--md-sys-shape-corner-medium);
  overflow: hidden;
  transition: var(--jexhrai-transition-standard);
  border: 1px solid transparent;
  position: relative;
}

.course-card-sm:hover {
  transform: translateY(-4px);
  box-shadow: 0 0 0 10px var(--jexhrai-container-glow);
  border-color: var(--jexhrai-container-hover-border);
}

.course-card-sm .image {
  height: 160px;
  background-size: cover;
  background-position: center;
  margin: 0;
}

.course-card-sm .content {
  padding: 1.25rem;
}

.course-card-sm h4 {
  margin: 0 0 1rem;
  font-size: 1.125rem;
  line-height: 1.4;
  font-weight: 600;
  color: var(--md-sys-color-on-surface);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: normal;
  /* Allow wrap */
}

.course-card-sm .progress-bar-bg {
  height: 8px;
  background-color: var(--md-sys-color-outline-variant);
}

.course-card-sm .progress-bar-fg {
  background-color: var(--md-sys-color-primary);
}

.course-card-sm .progress-text {
  font-size: 0.8rem;
  color: var(--md-sys-color-on-surface-variant);
  margin-top: 0.75rem;
  font-weight: 500;
  text-align: right;
}

.course-card-sm .completed-overlay {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--jexhrai-success);
  font-weight: 600;
  background: var(--jexhrai-success-bg);
  padding: 6px 12px;
  border-radius: var(--md-sys-shape-corner-small);
  font-size: 0.9rem;
}

/* Clickable State */
.course-card-sm.is-clickable {
  cursor: pointer;
}

.course-card-sm.is-clickable::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--md-sys-color-on-surface);
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

.course-card-sm.is-clickable:hover::before {
  opacity: 0.04;
  /* Ripple-like hover state */
}

.course-card-sm.is-clickable:active::before {
  opacity: 0.1;
}

/* Heatmap */
.heatmap-container {
  /* Inherits section style */
  padding: 0;
}

.heatmap {
  display: grid;
  grid-template-columns: repeat(26, 1fr);
  grid-auto-flow: column;
  grid-template-rows: repeat(7, 1fr);
  gap: 6px;
}

.heatmap-day {
  width: 100%;
  aspect-ratio: 1 / 1;
  background-color: var(--md-sys-color-surface-variant);
  border-radius: var(--md-sys-shape-corner-extra-small);
  transition: transform 0.2s;
}

.heatmap-day:hover {
  transform: scale(1.2);
  z-index: 1;
  box-shadow: var(--md-sys-elevation-2);
}

/* Using Primary Color Opacity for levels */
.heatmap-day[data-level="1"] {
  background-color: color-mix(in srgb, var(--md-sys-color-primary) 40%, var(--md-sys-color-surface) 60%);
}

.heatmap-day[data-level="2"] {
  background-color: color-mix(in srgb, var(--md-sys-color-primary) 70%, var(--md-sys-color-surface) 30%);
}

.heatmap-day[data-level="3"] {
  background-color: var(--jexhrai-primary);
}

/* Tooltip */
.info-tooltip {
  position: relative;
  margin-left: auto;
}

.info-tooltip-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background-color: var(--md-sys-color-surface-variant);
  color: var(--md-sys-color-on-surface-variant);
  font-weight: bold;
  cursor: help;
  transition: all 0.2s;
}

.info-tooltip-trigger:hover {
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}

.tooltip-content {
  position: absolute;
  bottom: 140%;
  right: -10px;
  background-color: var(--md-sys-color-inverse-surface);
  color: var(--md-sys-color-inverse-on-surface);
  padding: 1rem;
  border-radius: var(--md-sys-shape-corner-small);
  box-shadow: var(--md-sys-elevation-2);
  width: 280px;
  font-size: 0.85rem;
  line-height: 1.5;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s;
  pointer-events: none;
  z-index: 10;
}

.info-tooltip:hover .tooltip-content {
  opacity: 1;
  visibility: visible;
  bottom: 130%;
}

/* Loading States */
.jexhrai-user-dashboard-container .courses-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 40px;
  min-height: 240px;
}

.jexhrai-user-dashboard-container .courses-loading .loader {
  width: 48px;
  height: 48px;
  border: 5px solid var(--md-sys-color-surface-variant);
  border-bottom-color: var(--md-sys-color-primary);
  border-radius: 50%;
  display: inline-block;
  box-sizing: border-box;
  animation: rotation 1s linear infinite;
}

@keyframes rotation {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

/* Overlay Loading */
.jexhrai-loading-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  background: color-mix(in srgb, var(--md-sys-color-surface), transparent 20%);
  backdrop-filter: blur(4px);
}

.jexhrai-loading-overlay .courses-loading .loader {
  width: 60px;
  height: 60px;
  border-width: 6px;
}

/* ==========================================
 * 個人能力儀表板 (Capability Dashboard)
 * ========================================== */
.capability-dashboard-container {
  min-height: 200px;
}

/* 載入狀態 */
.capability-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  gap: 1rem;
  color: var(--md-sys-color-on-surface-variant);
}

.capability-loading .loader {
  width: 36px;
  height: 36px;
  border: 4px solid var(--md-sys-color-surface-variant);
  border-bottom-color: var(--md-sys-color-primary);
  border-radius: 50%;
  animation: rotation 1s linear infinite;
}

.capability-loading p {
  margin: 0;
  font-size: 0.9rem;
}

/* 主佈局：左雷達圖，右摘要 */
.capability-layout {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
}

/* 雷達圖容器 */
.capability-chart-wrapper {
  flex: 0 0 300px;
  max-width: 300px;
}

.capability-chart-wrapper canvas {
  max-width: 100%;
  height: auto !important;
}

/* 摘要容器 */
.capability-summary-wrapper {
  flex: 1;
  min-width: 0;
}

/* 統計卡片 */
.capability-stat-cards {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.capability-stat-cards .stat-card {
  flex: 1;
  background: var(--md-sys-color-surface-variant);
  border-radius: var(--md-sys-shape-corner-medium);
  padding: 1rem 1.25rem;
  text-align: center;
}

.capability-stat-cards .stat-card.stat-overall {
  background: linear-gradient(135deg,
      var(--md-sys-color-primary-container) 0%,
      color-mix(in srgb, var(--md-sys-color-primary-container), var(--md-sys-color-surface) 50%) 100%);
}

.capability-stat-cards .stat-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--md-sys-color-on-surface-variant);
  margin-bottom: 0.5rem;
}

.capability-stat-cards .stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--md-sys-color-on-surface);
  line-height: 1;
}

.capability-stat-cards .stat-unit {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--md-sys-color-on-surface-variant);
  margin-left: 0.25rem;
}

/* 亮點提示 */
.capability-highlights {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.highlight-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--md-sys-shape-corner-small);
  background: var(--md-sys-color-surface-variant);
}

.highlight-item.highlight-strength {
  background: color-mix(in srgb, var(--jexhrai-success-bg), transparent 30%);
  border-left: 3px solid var(--jexhrai-success);
}

.highlight-item.highlight-opportunity {
  background: color-mix(in srgb, var(--md-sys-color-tertiary-container), transparent 30%);
  border-left: 3px solid var(--md-sys-color-tertiary);
}

.highlight-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

.highlight-text {
  font-size: 0.9rem;
  color: var(--md-sys-color-on-surface);
}

.highlight-text strong {
  font-weight: 600;
  color: var(--md-sys-color-primary);
}

/* 空狀態 */
.capability-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
}

.capability-empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.6;
}

.capability-empty-state .empty-message {
  margin: 0;
  font-size: 0.95rem;
  color: var(--md-sys-color-on-surface-variant);
  max-width: 300px;
  line-height: 1.5;
}

/* Responsive */
@media (min-width: 992px) {
  .jexhrai-user-dashboard-container {
    flex-direction: row;
    align-items: flex-start;
  }
}

@media (max-width: 992px) {
  .jexhrai-user-dashboard-container {
    flex-direction: column;
    width: calc(100% - 32px);
    margin: 1rem auto;
    gap: 1rem;
  }

  .jexhrai-user-dashboard-container .profile-card {
    position: static;
    text-align: left;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: none;
    width: 100%;
  }

  .dashboard-header h1 {
    font-size: 2rem;
  }
}

@media (max-width: 768px) {
  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .tabs {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 0.5rem;
  }

  .tab-button {
    white-space: nowrap;
    flex: 1;
    text-align: center;
  }

  .courses-section,
  .activity-section,
  .capability-section {
    padding: 1.5rem;
  }

  .heatmap {
    gap: 2px;
  }

  .course-list {
    grid-template-columns: 1fr;
  }

  /* 能力儀表板響應式：垂直佈局 */
  .capability-layout {
    flex-direction: column;
    align-items: center;
  }

  .capability-chart-wrapper {
    flex: none;
    width: 100%;
    max-width: 280px;
  }

  .capability-summary-wrapper {
    width: 100%;
  }

  .capability-stat-cards {
    flex-direction: column;
  }
}

/* ==========================================
 * Talent Hub v1.7：公司切換器定位
 * ========================================== */
.jexhrai-dashboard-company-switcher {
  position: absolute;
  top: 1rem;
  left: 1rem;
  z-index: 100;
}

/* 桌面版：切換器固定在左上角 */
@media (min-width: 992px) {
  .jexhrai-user-dashboard-container {
    position: relative;
  }

  .jexhrai-dashboard-company-switcher {
    position: fixed;
    top: 100px;
    left: 24px;
  }
}

/* 手機版：切換器置於頂部 */
@media (max-width: 991px) {
  .jexhrai-dashboard-company-switcher {
    position: relative;
    top: 0;
    left: 0;
    width: 100%;
    margin-bottom: 0.5rem;
  }

  .jexhrai-dashboard-company-switcher .jexhrai-company-trigger {
    width: 100%;
    max-width: 100%;
  }
}