/* egp-public — Modern Responsive Design */

/* ── Base ────────────────────────────────────────────────────────────────── */
:root {
  --egp-primary: #1557b0;
  --egp-primary-dark: #1a3a5c;
  --egp-blue-light: #e8f0fe;
  --egp-green: #0d8a5e;
  --egp-green-light: #e6f7f0;
  --egp-purple: #6f42c1;
  --egp-purple-light: #f0ebfa;
  --egp-orange: #e67e22;
  --egp-orange-light: #fef5e7;
  --egp-danger: #dc3545;
  --egp-body-bg: #f4f6f9;
  --egp-card-radius: 10px;
  --egp-transition: 0.2s ease;
}

* { box-sizing: border-box; }

body {
  background-color: var(--egp-body-bg);
  font-family: 'Sarabun', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: #2c3e50;
  font-size: 1rem;
  -webkit-font-smoothing: antialiased;
}

/* ── Navbar ──────────────────────────────────────────────────────────────── */
.navbar {
  padding: 0.5rem 0;
}
.navbar-brand {
  font-size: 1rem;
}

/* ── Stat Cards ─────────────────────────────────────────────────────────── */
.stat-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-radius: var(--egp-card-radius);
  background: #fff;
  border: 1px solid rgba(0,0,0,0.06);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  transition: transform var(--egp-transition), box-shadow var(--egp-transition);
  height: 100%;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.stat-card__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  font-size: 1.15rem;
  flex-shrink: 0;
}
.stat-card__body { min-width: 0; }
.stat-card__value {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat-card__label {
  font-size: 0.7rem;
  color: #6c757d;
  line-height: 1.2;
  margin-top: 2px;
}

.stat-card--blue .stat-card__icon  { background: var(--egp-blue-light);   color: var(--egp-primary); }
.stat-card--green .stat-card__icon { background: var(--egp-green-light);  color: var(--egp-green); }
.stat-card--purple .stat-card__icon { background: var(--egp-purple-light); color: var(--egp-purple); }
.stat-card--orange .stat-card__icon { background: var(--egp-orange-light); color: var(--egp-orange); }

.stat-card--blue .stat-card__value  { color: var(--egp-primary); }
.stat-card--green .stat-card__value { color: var(--egp-green); }
.stat-card--purple .stat-card__value { color: var(--egp-purple); }
.stat-card--orange .stat-card__value { color: var(--egp-orange); }

/* ── Latest Project Banner ──────────────────────────────────────────────── */
.latest-project-banner {
  background: #fff;
  border: 1px solid rgba(0,0,0,0.06);
  border-left: 4px solid var(--egp-danger);
  border-radius: var(--egp-card-radius);
  padding: 0.85rem 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.latest-project-banner__badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #fde8ea;
  color: var(--egp-danger);
  font-size: 1rem;
}
.text-truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.min-width-0 { min-width: 0; }

/* ── Cards ──────────────────────────────────────────────────────────────── */
.card {
  border-radius: var(--egp-card-radius);
  overflow: hidden;
}
.card-header {
  border-bottom: 1px solid rgba(0,0,0,0.06);
}

/* ── Filter toggle icon (mobile) ────────────────────────────────────────── */
.filter-toggle-icon {
  transition: transform var(--egp-transition);
}
[aria-expanded="false"] .filter-toggle-icon {
  transform: rotate(-90deg);
}

/* ── Table ──────────────────────────────────────────────────────────────── */
#egpTable {
  font-size: 0.92rem;
}
#egpTable thead th {
  border-bottom: 2px solid #dee2e6;
  font-weight: 600;
  color: #495057;
  white-space: nowrap;
  user-select: none;
  background: #f8f9fa;
  padding: 0.6rem 0.5rem;
}
#egpTable thead th[data-sort]:hover {
  background: #e9ecef;
}
#egpTable tbody td {
  padding: 0.55rem 0.5rem;
  vertical-align: middle;
  border-color: #f0f0f0;
}
#egpTable tbody tr {
  transition: background var(--egp-transition);
}
#egpTable tbody tr:hover {
  background: var(--egp-blue-light) !important;
}

.sort-icon {
  font-size: 0.68rem;
  opacity: 0.5;
}

/* ── Mobile Card List ───────────────────────────────────────────────────── */
.mobile-project-card {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid #f0f0f0;
  transition: background var(--egp-transition);
}
.mobile-project-card:last-child {
  border-bottom: none;
}
.mobile-project-card:active {
  background: var(--egp-blue-light);
}
.mobile-project-card__name {
  font-size: 0.95rem;
  font-weight: 600;
  color: #2c3e50;
  line-height: 1.35;
  margin-bottom: 0.4rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.mobile-project-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  font-size: 0.84rem;
  color: #6c757d;
}
.mobile-project-card__meta i { margin-right: 0.2rem; }
.mobile-project-card__budget {
  color: var(--egp-green);
  font-weight: 600;
}
.mobile-project-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
}
.mobile-project-card__num {
  font-size: 0.68rem;
  color: #adb5bd;
  flex-shrink: 0;
  padding-top: 0.1rem;
}

/* ── Badges ─────────────────────────────────────────────────────────────── */
.badge.text-wrap {
  white-space: normal;
  word-break: break-word;
  line-height: 1.3;
}
.badge-status {
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.3em 0.55em;
  border-radius: 4px;
}

/* ── Loading Overlay ────────────────────────────────────────────────────── */
#loadingOverlay {
  position: relative;
  min-height: 80px;
}

/* ── Pagination ─────────────────────────────────────────────────────────── */
.pagination .page-link {
  border-radius: 6px;
  margin: 0 2px;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.35rem 0.7rem;
  color: var(--egp-primary);
  border-color: #dee2e6;
  min-width: 36px;
  text-align: center;
}
.pagination .page-item.active .page-link {
  background-color: var(--egp-primary);
  border-color: var(--egp-primary);
  color: #fff;
}

/* ── Footer ─────────────────────────────────────────────────────────────── */
footer {
  font-size: 0.78rem;
  color: #6c757d;
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 991.98px) {
  .stat-card {
    padding: 0.65rem 0.75rem;
    gap: 0.5rem;
  }
  .stat-card__icon {
    width: 34px;
    height: 34px;
    font-size: 1rem;
    border-radius: 8px;
  }
  .stat-card__value { font-size: 0.92rem; }
  .stat-card__label { font-size: 0.65rem; }
}

@media (max-width: 575.98px) {
  body { font-size: 0.88rem; }

  .stat-card {
    flex-direction: column;
    text-align: center;
    gap: 0.35rem;
    padding: 0.6rem 0.5rem;
  }
  .stat-card__icon {
    width: 30px;
    height: 30px;
    font-size: 0.9rem;
    border-radius: 7px;
  }
  .stat-card__value { font-size: 0.82rem; }

  .latest-project-banner {
    padding: 0.7rem 0.75rem;
  }
  .latest-project-banner__badge {
    width: 30px;
    height: 30px;
    font-size: 0.85rem;
  }

  .navbar-brand {
    font-size: 0.9rem;
  }
}

/* ── Animate on load ────────────────────────────────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.stat-card,
.latest-project-banner,
.card {
  animation: fadeInUp 0.4s ease both;
}
.stat-card:nth-child(1) { animation-delay: 0.05s; }
.stat-card:nth-child(2) { animation-delay: 0.1s; }
.stat-card:nth-child(3) { animation-delay: 0.15s; }
.stat-card:nth-child(4) { animation-delay: 0.2s; }
