* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: "Inter", "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  line-height: 1.6;
  color: #333;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding-top: var(--header-height);
  display: flex;
  flex-direction: column;
  min-height: 100vh; /* Đảm bảo body ít nhất bằng viewport */
  margin: 0;
}

#main-content {
  flex: 1; /* Tự động giãn để chiếm hết không gian còn lại, đẩy footer xuống dưới cùng */
  display: flex;
  flex-direction: column;
  width: 100%;
}

/* Các trang con sẽ có chiều cao tối thiểu bằng toàn bộ màn hình (Viewport) */
/* Điều này đảm bảo dù ít nội dung thì footer vẫn luôn nằm ở đáy màn hình hoặc xa hơn */
body:not([data-page="home"]) #main-content > * {
  flex: 1;
  width: 100%;
  min-height: calc(100vh - var(--header-height, 80px));
  display: flex;
  flex-direction: column;
}

.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 5px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-primary {
  background: #667eea;
  color: white;
}

.btn-primary:hover {
  background: #5568d3;
  transform: translateY(-2px);
}

.btn-secondary {
  background: transparent;
  color: white;
  border: 2px solid white;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-outline {
  background: transparent;
  color: #667eea;
  border: 2px solid #667eea;
}

.btn-outline:hover {
  background: #667eea;
  color: white;
}

@media (max-width: 768px) {
  body {
    font-size: 14px;
  }
}

.scroll-to-top {
  position: fixed;
  bottom: 40px;
  right: 40px;
  width: 56px;
  height: 56px;
  background-color: white;
  color: var(--color-primary, #0f766e);
  border: 2px solid rgba(15, 118, 110, 0.1);
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
  opacity: 0;
  visibility: hidden;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 1000;
  transform: translateY(50px) scale(0.5);
  padding: 0;
}

.scroll-to-top.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.scroll-to-top:hover {
  background-color: var(--color-bg-subtle, #f3f4f6);
  transform: translateY(-8px);
  box-shadow: 0 12px 32px rgba(15, 118, 110, 0.2);
  color: var(--color-primary-hover, #0d5a54);
}

.progress-square {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.progress-square-bar {
  transition: stroke-dashoffset 0.1s linear;
}

.scroll-icon {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Hide scroll-to-top button on mobile/tablet (max-width: 1024px) */
@media (max-width: 1024px) {
  .scroll-to-top {
    display: none !important;
  }
}

#global-loader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, #ffffff 0%, #f9fafb 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition:
    opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1),
    visibility 0.8s;
}

.loader-content {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.loader-logo-container {
  position: relative;
  width: 120px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0;
}

.loader-logo {
  width: 64px;
  height: 64px;
  z-index: 2;
  animation: pulse-logo 2.5s infinite ease-in-out;
}

.loader-glow {
  position: absolute;
  width: 140px;
  height: 140px;
  background: radial-gradient(
    circle,
    rgba(15, 118, 110, 0.15) 0%,
    transparent 70%
  );
  border-radius: 50% !important;
  animation: pulse-glow 2.5s infinite ease-in-out;
}

.loader-spinner-wrap {
  position: absolute;
  width: 100px;
  height: 100px;
  z-index: 1;
}

.loader-spinner {
  position: absolute;
  inset: 0;
  border: 2px solid transparent;
  border-top: 2px solid var(--color-primary, #0f766e);
  border-right: 2px solid var(--color-primary, #0f766e);
  border-radius: 50% !important;
  animation: spin 1.2s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.loader-spinner-inner {
  position: absolute;
  inset: 8px;
  border: 2px solid transparent;
  border-bottom: 2px solid var(--color-primary-light, #14b8a6);
  border-left: 2px solid var(--color-primary-light, #14b8a6);
  border-radius: 50% !important;
  opacity: 0.6;
  animation: spin-reverse 1.8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes pulse-logo {
  0%,
  100% {
    transform: scale(1);
    filter: drop-shadow(0 0 0px rgba(15, 118, 110, 0));
  }
  50% {
    transform: scale(1.05);
    filter: drop-shadow(0 0 15px rgba(15, 118, 110, 0.2));
  }
}

@keyframes pulse-glow {
  0%,
  100% {
    transform: scale(0.8);
    opacity: 0.3;
  }
  50% {
    transform: scale(1.2);
    opacity: 0.6;
  }
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

@keyframes spin-reverse {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(-360deg);
  }
}

body.loaded #global-loader {
  opacity: 0;
  visibility: hidden;
}

body.loading {
  overflow: hidden;
}
