/* ==================== RESET & BASE ==================== */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Open Sans', Arial, Helvetica, sans-serif;
  background:
    radial-gradient(1100px 520px at 12% -8%, #e3effd 0%, rgba(227,239,253,0) 60%),
    radial-gradient(900px 480px at 92% 4%, #e9f2fe 0%, rgba(233,242,254,0) 58%),
    linear-gradient(180deg, #eef4fc 0%, #f5f8fd 38%, #f7fafe 100%);
  background-attachment: fixed;
  color: #1a1a2e;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ==================== HEADER ==================== */
.portal-header {
  background: #fff;
  border-bottom: 1px solid #e8ecf4;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.portal-header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 10px 32px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
}

.portal-header-left {
  display: flex;
  align-items: center;
  justify-self: start;
}

.portal-flags { height: 64px; width: auto; }

.portal-header-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 2px;
}

.portal-logo-link { display: flex; align-items: center; }

.portal-logo { height: 70px; width: auto; }

.portal-label {
  font-size: 28px;
  font-weight: 800;
  color: #313f99;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  text-shadow:
    -1px -1px 0 rgba(255,255,255,0.7),
    1px 1px 1px rgba(0,0,0,0.18),
    2px 2px 4px rgba(0,0,0,0.22);
}

.portal-name {
  font-size: 28px;
  font-weight: 700;
  color: #313f99;
  margin: 0;
  white-space: nowrap;
  text-transform: uppercase;
  text-shadow:
    -1px -1px 0 rgba(255,255,255,0.75),
    1px 1px 1px rgba(0,0,0,0.22),
    2px 3px 5px rgba(0,0,0,0.3);
}

.portal-header-right {
  display: flex;
  align-items: center;
  justify-self: end;
  gap: 12px;
}

.system-status-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border: 1.5px solid #c8e6c9;
  background: #f1f8e9;
  border-radius: 24px;
  font-size: 13px;
  font-weight: 600;
  color: #2e7d32;
  white-space: nowrap;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #43a047;
  display: inline-block;
  flex-shrink: 0;
  animation: statusPulse 2s infinite;
}

@keyframes statusPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(67,160,71,0.4); }
  50% { box-shadow: 0 0 0 5px rgba(67,160,71,0); }
}

/* User menu */
.portal-user-menu {
  position: relative;
  cursor: pointer;
}

.portal-user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 7px 12px;
  border-radius: 8px;
  background: #f5f7ff;
  border: 1px solid #e0e6ff;
  transition: background 0.2s;
}

.portal-user-info:hover { background: #e8edff; }

.portal-user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #1565c0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

/* .portal-username {
  font-weight: 700;
  color: #1565c0;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
} */

.portal-usercode {
  font-size: 11px;
  color: #888;
}

.portal-user-arrow {
  border: solid #888;
  border-width: 0 2px 2px 0;
  display: inline-block;
  padding: 3px;
  transform: rotate(45deg);
  margin-left: 2px;
  flex-shrink: 0;
}

.portal-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  background: #fff;
  border-radius: 10px;
  border: 1px solid #e0e6ff;
  min-width: 190px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.12);
  z-index: 300;
  overflow: hidden;
}

.portal-dropdown a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  text-decoration: none;
  color: #333;
  font-size: 14px;
  transition: background 0.15s;
}

.portal-dropdown a i { color: #1565c0; width: 16px; }

.portal-dropdown a:hover { background: #f0f4ff; color: #1565c0; }

.portal-dropdown.active { display: block; }

/* ==================== HERO BANNER ==================== */
.portal-hero-wrap {
  padding: 24px 32px 8px;
  background: transparent;
}

.portal-hero {
  max-width: 1280px;
  margin: 0 auto;
  background:
    radial-gradient(120% 150% at 100% 0%, #58a5f3 0%, rgba(88,165,243,0) 55%),
    linear-gradient(120deg, #1257b0 0%, #1976d2 45%, #2196f3 80%, #42a5f5 100%);
  border-radius: 24px;
  padding: 48px 52px;
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 48px;
  align-items: center;
  position: relative;
  overflow: hidden;
  box-shadow: 0 24px 50px -22px rgba(13,71,161,0.55);
}

/* Concentric decorative rings (top-right) */
.portal-hero::before {
  content: '';
  position: absolute;
  top: -120px; right: -90px;
  width: 360px; height: 360px;
  border-radius: 50%;
  background: rgba(255,255,255,0.07);
  box-shadow:
    0 0 0 60px rgba(255,255,255,0.05),
    0 0 0 130px rgba(255,255,255,0.035);
  pointer-events: none;
}

/* Soft blob (bottom area) */
.portal-hero::after {
  content: '';
  position: absolute;
  bottom: -90px; right: 120px;
  width: 240px; height: 240px;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.12), rgba(255,255,255,0) 70%);
  border-radius: 50%;
  pointer-events: none;
}

.hero-left { position: relative; z-index: 1; }

.hero-title {
  font-size: 2rem;
  font-weight: 800;
  color: #fff;
  margin: 0 0 18px;
  line-height: 1.18;
  letter-spacing: -0.5px;
  max-width: 37ch;
  text-shadow: 0 2px 12px rgba(13,71,161,0.25);
}

.hero-desc {
  font-size: 14.5px;
  color: rgba(255,255,255,0.85);
  line-height: 1.7;
  margin: 0;
  max-width: 72ch;
}

.hero-right { position: relative; z-index: 1; }

.hero-search {
  display: flex;
  align-items: center;
  background: rgba(255,255,255,0.96);
  border: 1px solid rgba(255,255,255,0.5);
  border-radius: 14px;
  padding: 6px 8px 6px 18px;
  box-shadow: 0 14px 34px -14px rgba(13,71,161,0.5);
  margin-bottom: 18px;
}

.hero-search i.fa-search { color: #9bb4d6; font-size: 16px; flex-shrink: 0; }

.hero-search input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 14.5px;
  color: #28395a;
  background: transparent;
  padding: 10px 12px;
  font-family: inherit;
}

.hero-search input::placeholder { color: #aab6c9; }

.hero-search-btn {
  background: #eef4fc;
  border: 1px solid #dbe7f7;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #1565c0;
  font-size: 14px;
  cursor: pointer;
  flex-shrink: 0;
  touch-action: manipulation;
  transition: background 0.2s, transform 0.2s;
}

.hero-search-btn:hover { background: #1565c0; color: #fff; transform: translateX(2px); }

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.hero-stat {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 14px;
  padding: 14px 16px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.hero-stat-num {
  font-size: 1.75rem;
  font-weight: 800;
  color: #fff;
  line-height: 1;
  margin-bottom: 4px;
}

.hero-stat-lbl {
  font-size: 11.5px;
  color: rgba(255,255,255,0.78);
  line-height: 1.3;
}

/* ==================== MAIN CONTENT ==================== */
.portal-main {
  flex: 1;
  padding: 28px 32px 56px;
  background: transparent;
}

.portal-main-inner {
  max-width: 1280px;
  margin: 0 auto;
}

/* Filter Tabs */
.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}

.filter-bar .portal-user-menu { margin-left: auto; }

.filter-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-tab {
  min-height: 44px;
  padding: 8px 22px;
  border-radius: 24px;
  border: 1.5px solid #dde3f0;
  background: #fff;
  color: #555;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.18s;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}

.filter-tab:hover {
  border-color: #1565c0;
  color: #1565c0;
}

.filter-tab.active {
  background: linear-gradient(135deg, #1565c0, #1e88e5);
  color: #fff;
  border-color: transparent;
  font-weight: 600;
  box-shadow: 0 8px 18px -8px rgba(21,101,192,0.6);
}

/* Catalog Header */
.catalog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.catalog-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: #1a1a2e;
  margin: 0 0 5px;
}

.catalog-desc {
  font-size: 13px;
  color: #5b6373;
  margin: 0;
}

.catalog-count {
  background: #fff;
  color: #1565c0;
  font-size: 13px;
  font-weight: 700;
  padding: 7px 18px;
  border-radius: 20px;
  border: 1px solid #e2eaf7;
  box-shadow: 0 6px 16px -10px rgba(21,101,192,0.4);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Loading */
#portal-loading {
  display: none;
  text-align: center;
  padding: 60px 0;
}

.portal-spinner {
  width: 38px;
  height: 38px;
  border: 3px solid #dde3f0;
  border-top-color: #1565c0;
  border-radius: 50%;
  animation: portalSpin 0.75s linear infinite;
  margin: 0 auto 14px;
}

@keyframes portalSpin { to { transform: rotate(360deg); } }

#portal-loading p { color: #888; font-size: 14px; margin: 0; }

/* Empty State */
.portal-empty {
  text-align: center;
  padding: 60px 0;
  color: #999;
}

.portal-empty i { font-size: 48px; margin-bottom: 16px; display: block; color: #d0d8e8; }
.portal-empty p { font-size: 15px; margin: 0; }

/* Apps Grid */
#data-container {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

/* App Card */
.app-card {
  background:
    radial-gradient(circle at 116% 118%, rgba(33,150,243,0.10) 0%, rgba(33,150,243,0) 30%),
    radial-gradient(circle at 96% 130%, rgba(100,181,246,0.12) 0%, rgba(100,181,246,0) 28%),
    #fff;
  border-radius: 18px;
  padding: 24px 24px 22px;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 1px solid #eaf0f8;
  box-shadow: 0 14px 30px -22px rgba(21,101,192,0.4);
  transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

/* Top accent bar — fully visible from the start */
.app-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, #1565c0 0%, #64b5f6 45%, #ffffff 100%);
  opacity: 1;
  transition: height 0.28s ease;
  z-index: 2;
}

/* Soft layered wave cluster in bottom-right corner */
.app-card::after {
  content: '';
  position: absolute;
  bottom: -46px; right: -38px;
  width: 128px; height: 128px;
  background: rgba(33,150,243,0.13);
  border-radius: 50%;
  box-shadow:
    -30px 10px 0 -8px rgba(100,181,246,0.13),
    -10px -34px 0 -12px rgba(33,150,243,0.10);
  pointer-events: none;
  transition: transform 0.3s ease, opacity 0.3s ease;
  z-index: 0;
}

.app-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 18px 38px -16px rgba(21,101,192,0.42);
  border-color: #bcd8f7;
  text-decoration: none;
}

.app-card:hover::before { height: 5px; }

.app-card:hover::after {
  transform: scale(1.12);
}

.app-card.app-disabled {
  filter: grayscale(1);
  opacity: 0.55;
  pointer-events: none;
  box-shadow: none;
}

.app-card-icon {
  width: 56px;
  height: 56px;
  border-radius: 15px;
  background: #eaf3fe;
  border: 1px solid #dbeafb;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  transition: background 0.22s ease, transform 0.22s ease;
}

.app-card:hover .app-card-icon {
  background: #ddebfc;
  transform: translateY(-1px);
}

.app-card-icon img {
  width: 30px;
  height: 30px;
  object-fit: contain;
  position: relative;
  z-index: 1;
}

.app-card-name {
  font-size: 16.5px;
  font-weight: 700;
  color: #15233b;
  margin: 0;
  line-height: 1.35;
  position: relative;
  z-index: 1;
}

.app-card-desc {
  font-size: 14px;
  color: #6b7689;
  line-height: 1.6;
  margin: 0;
  flex: 1;
  position: relative;
  z-index: 1;
}

.app-card-group {
  font-size: 12.5px;
  font-weight: 700;
  color: #1565c0;
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid #eef2f8;
  letter-spacing: 0.2px;
  position: relative;
  z-index: 1;
}

/* ==================== FOOTER ==================== */
.portal-footer {
  background: #fff;
  border-top: 1px solid #e8ecf4;
  padding: 18px 32px;
}

.portal-footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 0;
  flex-wrap: wrap;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: #1a1a2e;
  font-size: 13px;
  flex-shrink: 0;
  padding-right: 28px;
  border-right: 1px solid #e0e6f0;
  margin-right: 28px;
}

.footer-logo { height: 30px; width: auto; }

.footer-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12.5px;
  color: #555;
  padding-right: 28px;
  margin-right: 28px;
  border-right: 1px solid #e0e6f0;
}

.footer-item:last-child {
  padding-right: 0;
  margin-right: 0;
  border-right: none;
}

.footer-item i { color: #1565c0; margin-top: 2px; flex-shrink: 0; font-size: 13px; }

.footer-item strong { color: #333; }

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1024px) {
  #data-container { grid-template-columns: repeat(3, 1fr); }
  .portal-hero { grid-template-columns: 1fr; gap: 32px; padding: 36px 32px; }
  .hero-right { max-width: 100%; }
}

@media (max-width: 768px) {
  .portal-header-inner { padding: 10px 16px; grid-template-columns: auto 1fr auto; }
  .portal-name { font-size: 15px; white-space: normal; }
  .portal-label { display: none; }
  .portal-flags { height: 44px; }
  .portal-hero-wrap { padding: 12px 16px; }
  .portal-hero { padding: 28px 24px; border-radius: 14px; }
  .hero-title { font-size: 1.4rem; }
  .portal-main { padding: 24px 16px 40px; }
  #data-container { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .catalog-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .portal-footer-inner { gap: 0; flex-direction: column; align-items: flex-start; }
  .footer-brand { border-right: none; padding-right: 0; margin-right: 0; margin-bottom: 12px; }
  .footer-item { border-right: none; padding-right: 0; margin-right: 0; margin-bottom: 8px; }
}

/* @media (max-width: 480px) {
  #data-container { grid-template-columns: 1fr; }
  .hero-stats { grid-template-columns: repeat(3, 1fr); }
  .system-status-badge span:not(.status-dot) { display: none; }
  .portal-username { max-width: 90px; }
  .portal-usercode { display: none; }
} */

/* ==================== ACCESSIBILITY — FOCUS RINGS ==================== */
/* Hiện vòng focus rõ ràng cho người dùng bàn phím (không hiện khi bấm chuột) */
.app-card:focus-visible,
.filter-tab:focus-visible,
.hero-search-btn:focus-visible,
.portal-user-info:focus-visible,
.portal-dropdown a:focus-visible,
.portal-footer a:focus-visible {
  outline: 3px solid #1565c0;
  outline-offset: 2px;
  border-radius: 12px;
}

.hero-search:focus-within {
  outline: 3px solid rgba(255,255,255,0.85);
  outline-offset: 2px;
}

/* Bỏ outline mặc định khi điều hướng bằng chuột, giữ lại cho bàn phím */
.app-card:focus:not(:focus-visible),
.filter-tab:focus:not(:focus-visible),
.hero-search-btn:focus:not(:focus-visible) {
  outline: none;
}

/* ==================== REDUCED MOTION ==================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .app-card:hover { transform: none; }
}