/* =========================================================
   教師檢定歷屆評量整合平台 - Portal Hub CSS
   ========================================================= */

:root {
  --portal-bg: #f8fafc;
  --portal-card-bg: #ffffff;
  --portal-primary: #2563eb;
  --portal-primary-hover: #1d4ed8;
  --portal-purple: #7c3aed;
  --portal-emerald: #059669;
  --portal-amber: #d97706;
  --portal-text: #0f172a;
  --portal-muted: #64748b;
  --portal-border: #e2e8f0;
}

body.portal-body {
  background-color: var(--portal-bg);
  color: var(--portal-text);
  font-family: 'Noto Sans TC', system-ui, -apple-system, sans-serif;
  margin: 0;
  padding: 0;
  line-height: 1.6;
}

.portal-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}

/* Hero Header */
.portal-hero {
  text-align: center;
  margin-bottom: 48px;
}

.portal-badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  color: #1e40af;
  font-size: 0.88rem;
  font-weight: 800;
  padding: 6px 16px;
  border-radius: 9999px;
  border: 1px solid #bfdbfe;
  margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.08);
}

.portal-title {
  font-size: 2.3rem;
  font-weight: 900;
  color: #0f172a;
  margin-bottom: 12px;
  letter-spacing: -0.02em;
}

.portal-subtitle {
  font-size: 1.12rem;
  color: var(--portal-muted);
  max-width: 720px;
  margin: 0 auto 24px;
}

.portal-stats-bar {
  display: flex;
  justify-content: center;
  gap: 24px;
  flex-wrap: wrap;
}

.p-stat-item {
  background: #fff;
  border: 1px solid var(--portal-border);
  padding: 10px 20px;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  display: flex;
  align-items: center;
  gap: 10px;
}

.p-stat-num {
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--portal-primary);
  font-family: 'JetBrains Mono', monospace;
}

.p-stat-label {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--portal-muted);
}

/* Years Grid */
.years-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 28px;
}

.year-card {
  background: var(--portal-card-bg);
  border-radius: 20px;
  border: 1.5px solid var(--portal-border);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.02);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.year-card:hover {
  transform: translateY(-5px);
  border-color: #93c5fd;
  box-shadow: 0 16px 24px -4px rgba(37, 99, 235, 0.12), 0 8px 12px -6px rgba(37, 99, 235, 0.06);
}

.year-card-header {
  padding: 24px 24px 18px;
  border-bottom: 1px solid var(--portal-border);
  background: #fafbfc;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.year-tag {
  font-size: 1.65rem;
  font-weight: 900;
  color: #0f172a;
  letter-spacing: -0.02em;
}

.year-status-badge {
  font-size: 0.75rem;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 6px;
}

.badge-newest {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

.badge-standard {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

.year-card-body {
  padding: 22px 24px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.exam-subject-name {
  font-size: 1.15rem;
  font-weight: 800;
  color: #1e293b;
}

.exam-meta-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.meta-pill {
  font-size: 0.8rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  background: #f1f5f9;
  color: #475569;
}

.meta-pill.highlight {
  background: #e0e7ff;
  color: #3730a3;
}

/* User Progress in Card */
.card-user-progress {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 12px 14px;
  margin-top: auto;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--portal-muted);
  margin-bottom: 6px;
}

.progress-bar-bg {
  height: 6px;
  background: #e2e8f0;
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-line {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #10b981);
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* Mode Buttons in Card */
.year-card-actions {
  padding: 16px 24px 24px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.mode-enter-btn {
  border: none;
  padding: 10px 8px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: all 0.15s ease;
}

.btn-practice {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}
.btn-practice:hover {
  background: #dbeafe;
  transform: translateY(-2px);
}

.btn-exam {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}
.btn-exam:hover {
  background: #d1fae5;
  transform: translateY(-2px);
}

.btn-parallel {
  background: #f5f3ff;
  color: #5b21b6;
  border: 1px solid #ddd6fe;
}
.btn-parallel:hover {
  background: #ede9fe;
  transform: translateY(-2px);
}

/* Footer */
.portal-footer {
  text-align: center;
  margin-top: 64px;
  padding-top: 24px;
  border-top: 1px solid var(--portal-border);
  color: var(--portal-muted);
  font-size: 0.88rem;
}

/* =========================================================
   Cloudflare D1 Candidate Auth & Profile Card
   ========================================================= */
.auth-panel-container {
  background: #ffffff;
  border-radius: 16px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.02);
  padding: 24px 28px;
  margin: 0 auto 36px;
  max-width: 860px;
  transition: all 0.2s ease;
}

.auth-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 12px;
}

.auth-panel-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 8px;
}

.cloud-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 9999px;
  background: #ecfdf5;
  color: #059669;
  border: 1px solid #a7f3d0;
}

.cloud-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
  animation: pulse-dot 2s infinite;
}

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

.auth-form-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1.2fr auto;
  gap: 12px;
  align-items: end;
}

@media (max-width: 768px) {
  .auth-form-grid {
    grid-template-columns: 1fr;
  }
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 700;
  color: #475569;
}

.form-input, .form-select {
  padding: 10px 14px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 0.92rem;
  font-family: inherit;
  color: #1e293b;
  background: #f8fafc;
  outline: none;
  transition: all 0.15s ease;
}

.form-input:focus, .form-select:focus {
  border-color: #3b82f6;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.auth-submit-btn {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: white;
  border: none;
  padding: 11px 20px;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.auth-submit-btn:hover {
  background: linear-gradient(135deg, #1d4ed8, #1e40af);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

/* User Logged-in State Card */
.user-logged-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 12px;
  padding: 16px 20px;
}

.user-info-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.user-avatar-badge {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #22c55e;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 900;
  box-shadow: 0 2px 6px rgba(34, 197, 94, 0.3);
}

.user-text-details h4 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  color: #14532d;
}

.user-text-details p {
  margin: 2px 0 0;
  font-size: 0.85rem;
  color: #166534;
}

.user-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-switch-user {
  background: #ffffff;
  color: #166534;
  border: 1px solid #86efac;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-switch-user:hover {
  background: #dcfce7;
}

