/* ============================================================
   PM Training Hub — Glass Morphism Edition
   Light theme · Emerald/Teal palette · Premium typography
   ============================================================ */

:root {
  /* Brand — Emerald/Teal */
  --emerald-50:  #f0fdf9;
  --emerald-100: #d1fae5;
  --emerald-200: #a7f3d0;
  --emerald-400: #34d399;
  --emerald-500: #10b981;
  --emerald-600: #059669;
  --emerald-700: #047857;
  --emerald-800: #065f46;

  --teal-100: #ccfbf1;
  --teal-300: #5eead4;
  --teal-500: #14b8a6;
  --teal-600: #0d9488;
  --teal-700: #0f766e;
  --teal-800: #115e59;

  /* Neutrals — Slate */
  --slate-50:  #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;

  /* Glass surface */
  --glass-bg: rgba(255, 255, 255, 0.55);
  --glass-bg-strong: rgba(255, 255, 255, 0.7);
  --glass-bg-soft: rgba(255, 255, 255, 0.4);
  --glass-border: rgba(255, 255, 255, 0.8);
  --glass-border-soft: rgba(255, 255, 255, 0.6);

  /* Layout */
  --radius-sm: 10px;
  --radius:    14px;
  --radius-lg: 18px;
  --max-width: 1320px;

  /* Shadow (very subtle) */
  --shadow-glass: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 16px rgba(15, 23, 42, 0.04);
  --shadow-card-hover: 0 4px 20px rgba(15, 118, 110, 0.08), 0 2px 8px rgba(15, 23, 42, 0.04);
}

* {
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', 'IBM Plex Sans Thai', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.55;
  color: var(--slate-900);
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
  letter-spacing: -0.005em;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* Background mesh */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #f0fdf9 0%, #ecfdf5 30%, #f0fdfa 60%, #f7fee7 100%);
  z-index: -3;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(at 15% 10%, rgba(110, 231, 183, 0.35) 0px, transparent 45%),
    radial-gradient(at 85% 80%, rgba(94, 234, 212, 0.32) 0px, transparent 50%),
    radial-gradient(at 65% 25%, rgba(167, 243, 208, 0.28) 0px, transparent 45%),
    radial-gradient(at 25% 75%, rgba(204, 251, 241, 0.4) 0px, transparent 40%);
  z-index: -2;
  pointer-events: none;
}

a { color: var(--teal-700); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--teal-800); }

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.02em; color: var(--slate-900); }

.num {
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--glass-bg-soft);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  border-bottom: 1px solid var(--glass-border-soft);
}

.topbar-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand { display: flex; align-items: center; gap: 14px; }

.brand-logo {
  width: 38px; height: 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--emerald-500), var(--teal-600));
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 13px; letter-spacing: 0.3px;
  box-shadow: 0 4px 14px rgba(13, 148, 136, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.brand-text h1 {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--slate-900);
  letter-spacing: -0.015em;
}

.brand-text p {
  margin: 1px 0 0;
  font-size: 11.5px;
  color: var(--slate-500);
}

.topbar-actions { display: flex; align-items: center; gap: 12px; }

.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  background: rgba(16, 185, 129, 0.1);
  border-radius: 999px;
  font-size: 11.5px;
  color: var(--emerald-700);
  font-weight: 500;
}

.live-indicator::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--emerald-500);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

.btn-refresh {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  background: var(--slate-900);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.btn-refresh:hover { background: var(--slate-800); }
.btn-refresh:active { transform: scale(0.97); }
.btn-refresh.loading svg { animation: spin 0.9s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

/* Container */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 36px 32px 80px;
}

/* Page header (Hero) */
.page-header { margin-bottom: 32px; }

.page-header .eyebrow {
  font-size: 11px;
  font-weight: 600;
  color: var(--emerald-700);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.page-header h2 {
  font-size: 26px;
  font-weight: 600;
  color: var(--slate-900);
  letter-spacing: -0.025em;
  line-height: 1.2;
  margin: 0 0 6px;
}

.page-header p {
  margin: 0;
  font-size: 13.5px;
  color: var(--slate-500);
  max-width: 640px;
}

/* Stat cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 32px;
}

.stat-card {
  position: relative;
  background: var(--glass-bg);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 18px 20px 20px;
  box-shadow: var(--shadow-glass);
  overflow: hidden;
  transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.2s;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
}

.stat-label {
  font-size: 10.5px;
  font-weight: 500;
  color: var(--slate-500);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.stat-row { display: flex; align-items: baseline; gap: 8px; }

.stat-value {
  font-size: 30px;
  font-weight: 600;
  color: var(--slate-900);
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.035em;
  line-height: 1;
}

.stat-pill {
  font-size: 11px;
  color: var(--emerald-700);
  font-weight: 500;
  background: rgba(16, 185, 129, 0.1);
  padding: 2px 8px;
  border-radius: 6px;
}

.stat-pill.muted { color: var(--slate-500); background: var(--slate-100); }

.stat-extra {
  margin-top: 14px;
  font-size: 11.5px;
  color: var(--slate-500);
  line-height: 1.5;
  min-height: 24px;
}

.sparkbars {
  margin-top: 14px;
  height: 24px;
  display: flex;
  align-items: flex-end;
  gap: 2px;
}
.sparkbars > div {
  flex: 1;
  background: var(--emerald-500);
  border-radius: 2px;
  opacity: 0.85;
  transition: opacity 0.2s;
}
.stat-card:hover .sparkbars > div { opacity: 1; }

.sparkdots {
  margin-top: 14px;
  display: flex;
  gap: 3px;
}
.sparkdots > div {
  flex: 1;
  height: 6px;
  border-radius: 2px;
  background: var(--slate-200);
}
.sparkdots > div.active { background: var(--emerald-500); }

.tag-cloud {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.tag-cloud > span {
  font-size: 10px;
  padding: 2px 8px;
  background: rgba(16, 185, 129, 0.1);
  color: var(--emerald-700);
  border-radius: 6px;
  font-weight: 500;
}
.tag-cloud > span:nth-child(2n) {
  background: rgba(13, 148, 136, 0.1);
  color: var(--teal-800);
}
.tag-cloud > span:nth-child(3n) {
  background: rgba(20, 184, 166, 0.1);
  color: var(--teal-800);
}

/* Filters */
.filters {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.filter-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: var(--glass-bg-soft);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
}

.tab {
  padding: 7px 14px;
  background: transparent;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--slate-600);
  cursor: pointer;
  transition: all 0.15s;
}
.tab:hover {
  color: var(--slate-900);
  background: rgba(255, 255, 255, 0.5);
}
.tab.active {
  background: var(--slate-900);
  color: white;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.15);
}

.filter-search {
  position: relative;
  flex: 1;
  max-width: 320px;
  min-width: 200px;
}

.filter-search svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--slate-400);
  pointer-events: none;
}

.filter-search input {
  width: 100%;
  padding: 9px 14px 9px 40px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  background: var(--glass-bg-soft);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-family: inherit;
  font-size: 12.5px;
  color: var(--slate-900);
  outline: none;
  transition: all 0.15s;
}
.filter-search input::placeholder { color: var(--slate-400); }
.filter-search input:focus {
  border-color: var(--emerald-400);
  background: rgba(255, 255, 255, 0.75);
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.12);
}

/* Items */
.items-section { margin-bottom: 32px; }

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}

.section-header h3 {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.section-count {
  font-size: 11.5px;
  color: var(--slate-500);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}

.item-card {
  position: relative;
  background: var(--glass-bg);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 18px 20px 20px;
  box-shadow: var(--shadow-glass);
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.2s, background 0.2s;
  overflow: hidden;
}
.item-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
  background: var(--glass-bg-strong);
}

.item-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  flex-wrap: wrap;
}

.item-tag {
  font-size: 10px;
  padding: 3px 9px;
  border-radius: 6px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.tag-thai          { background: rgba(16, 185, 129, 0.12); color: var(--emerald-700); }
.tag-international { background: rgba(13, 148, 136, 0.12); color: var(--teal-800); }
.tag-webinars      { background: rgba(20, 184, 166, 0.12); color: var(--teal-800); }

.item-source {
  font-size: 11.5px;
  color: var(--slate-500);
  font-weight: 500;
}

.item-date {
  margin-left: auto;
  color: var(--slate-400);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.item-title {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--slate-900);
  line-height: 1.4;
  letter-spacing: -0.015em;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.item-title a { color: inherit; }
.item-title a:hover { color: var(--teal-700); }

.item-desc {
  font-size: 12.5px;
  color: var(--slate-600);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 0;
}

.item-cta {
  margin-top: auto;
  padding-top: 4px;
  font-size: 11.5px;
  color: var(--teal-700);
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: gap 0.2s;
}
.item-card:hover .item-cta { gap: 8px; }
.item-cta svg { transition: transform 0.2s; }
.item-card:hover .item-cta svg { transform: translate(2px, -2px); }

/* Empty state */
.loading-state, .empty-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 80px 20px;
  text-align: center;
  color: var(--slate-500);
}

.empty-state .icon {
  width: 56px; height: 56px;
  border-radius: 16px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--emerald-600);
}

.empty-state h4 {
  margin: 8px 0 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--slate-900);
}

.empty-state p {
  margin: 0;
  font-size: 13px;
  color: var(--slate-500);
  max-width: 360px;
  line-height: 1.55;
}

.spinner {
  width: 32px; height: 32px;
  border: 2.5px solid var(--slate-200);
  border-top-color: var(--emerald-500);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Errors */
.errors-panel {
  margin-top: 24px;
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 12px 18px;
}

.errors-panel summary {
  cursor: pointer;
  font-size: 12.5px;
  color: var(--slate-600);
  font-weight: 500;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.errors-panel summary::-webkit-details-marker { display: none; }
.errors-panel summary::before {
  content: '▸';
  color: var(--slate-400);
  font-size: 10px;
  transition: transform 0.15s;
}
.errors-panel[open] summary::before { transform: rotate(90deg); }

.errors-panel summary span {
  color: var(--slate-400);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

#errorsList {
  margin-top: 14px;
  font-size: 12px;
  color: var(--slate-600);
  display: grid;
  gap: 6px;
}

.error-item {
  padding: 8px 12px;
  background: rgba(251, 191, 36, 0.08);
  border-radius: 8px;
  font-size: 11.5px;
}

.error-item strong {
  color: var(--slate-800);
  font-weight: 600;
}

/* Footer */
.footer {
  margin-top: 60px;
  padding: 24px 32px;
  border-top: 1px solid var(--glass-border-soft);
  background: var(--glass-bg-soft);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  text-align: center;
  font-size: 12px;
  color: var(--slate-500);
}
.footer-inner p { margin: 3px 0; }
.footer-meta {
  font-size: 11px;
  color: var(--slate-400);
}

/* Responsive */
@media (max-width: 768px) {
  .topbar-inner { padding: 14px 20px; }
  .container { padding: 24px 20px 60px; }
  .topbar-actions .live-indicator { display: none; }
  .page-header h2 { font-size: 22px; }
  .filters { flex-direction: column; align-items: stretch; }
  .filter-search { max-width: none; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .items-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
}
