/* ========================================
   FILE: frontend/css/global.css
   ======================================== */

/* ── Hide scrollbar (all browsers) ───────────────────────────────────────── */
html, body {
  scrollbar-width: none;        /* Firefox */
  -ms-overflow-style: none;     /* IE / Edge */
  overflow-x: hidden;
  max-width: 100vw;
}
html::-webkit-scrollbar,
body::-webkit-scrollbar {
  display: none;                /* Chrome / Safari / Opera */
}

/* ── Page Layout ──────────────────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  padding: 0 10px;
}

.page-wrapper {
  padding-top: calc(var(--navbar-height) + var(--announcement-height));
  min-height: 100vh;
  overflow-x: hidden;
}
.page-wrapper.announcement-hidden {
  padding-top: var(--navbar-height);
}

/* ── Typography Utilities ─────────────────────────────────────────────────── */
.text-xs     { font-size: var(--font-size-xs); }
.text-sm     { font-size: var(--font-size-sm); }
.text-base   { font-size: var(--font-size-base); }
.text-lg     { font-size: var(--font-size-lg); }
.text-xl     { font-size: var(--font-size-xl); }
.text-2xl    { font-size: var(--font-size-2xl); }
.text-3xl    { font-size: var(--font-size-3xl); }
.text-4xl    { font-size: var(--font-size-4xl); }

.font-medium   { font-weight: var(--font-weight-medium); }
.font-semibold { font-weight: var(--font-weight-semibold); }
.font-bold     { font-weight: var(--font-weight-bold); }
.font-black    { font-weight: var(--font-weight-black); }

.text-muted    { color: var(--color-text-muted); }
.text-primary  { color: var(--color-primary); }
.text-success  { color: var(--color-success); }
.text-error    { color: var(--color-error); }
.text-center   { text-align: center; }
.text-right    { text-align: right; }

.uppercase     { text-transform: uppercase; }
.tracking-wide { letter-spacing: 0.08em; }
.tracking-widest { letter-spacing: 0.16em; }

/* ── Flex & Grid Utilities ────────────────────────────────────────────────── */
.flex         { display: flex; }
.flex-col     { flex-direction: column; }
.flex-wrap    { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start  { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.gap-sm       { gap: var(--space-sm); }
.gap-md       { gap: var(--space-md); }
.gap-lg       { gap: var(--space-lg); }

/* ── Spacing Utilities ────────────────────────────────────────────────────── */
.mt-sm   { margin-top: var(--space-sm); }
.mt-md   { margin-top: var(--space-md); }
.mt-lg   { margin-top: var(--space-lg); }
.mt-xl   { margin-top: var(--space-xl); }
.mb-md   { margin-bottom: var(--space-md); }
.mb-lg   { margin-bottom: var(--space-lg); }
.mb-xl   { margin-bottom: var(--space-xl); }

/* ── Section Styles ───────────────────────────────────────────────────────── */
.section {
  padding: var(--space-3xl) 0;
}

.section-sm {
  padding: var(--space-2xl) 0;
}

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: var(--space-xl);
}

.section-title {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-black);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.section-link {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--color-primary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: gap var(--transition-fast);
}
.section-link:hover { gap: 8px; }

/* ── Loading State ────────────────────────────────────────────────────────── */
#loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-overlay);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base);
}
#loading-overlay.active {
  opacity: 1;
  pointer-events: all;
}
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast Notifications ──────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 420px;
  pointer-events: none;  /* container non-blocking */
}
#toast-container .toast {
  pointer-events: all;   /* toasts themselves ARE clickable */
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 12px 16px;
  border-radius: 8px;
  background: var(--color-secondary);
  color: white;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  min-width: 260px;
  max-width: 400px;
  animation: toastSlideIn 0.3s ease forwards;
  position: relative;
}
.toast.success { background: var(--color-success); }
.toast.error   { background: var(--color-error); }
.toast.warning { background: var(--color-warning); }
.toast.info    { background: var(--color-info); }
.toast.removing {
  animation: toastSlideOut 0.35s ease forwards;
  pointer-events: none;
}

.toast-icon { font-size: 16px; flex-shrink: 0; }
.toast-close {
  margin-left: auto;
  background: none;
  border: none;
  color: white;
  font-size: 18px;
  cursor: pointer;
  padding: 0 0 0 8px;
  line-height: 1;
  opacity: 0.8;
  flex-shrink: 0;
  pointer-events: all;  /* CRITICAL — must not be blocked */
  z-index: 10;
  position: relative;
}
.toast-close:hover { opacity: 1; }

@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(100%); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes toastSlideOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(110%); }
}

/* ── Skeleton Loader ──────────────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* ── Scroll Reveal Animations ─────────────────────────────────────────────── */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}
.reveal-delay-1 { transition-delay: 0.1s; }
.reveal-delay-2 { transition-delay: 0.2s; }
.reveal-delay-3 { transition-delay: 0.3s; }

/* ── Badge ────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.badge-primary { background: var(--color-primary); color: white; }
.badge-success { background: #d4f6e6; color: #0f6b38; }
.badge-warning { background: #fef3cd; color: #856404; }
.badge-error   { background: #fde8e6; color: #9c1f15; }
.badge-dark    { background: var(--color-secondary); color: white; }
.badge-muted   { background: var(--color-bg-light); color: var(--color-text-muted); }

/* ── Divider ──────────────────────────────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: var(--space-lg) 0;
}

/* ── Visually Hidden (accessibility) ─────────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border-width: 0;
}

/* ── Breadcrumb ───────────────────────────────────────────────────────────── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-lg);
}
.breadcrumb a:hover { color: var(--color-primary); }
.breadcrumb .sep { opacity: 0.4; }

/* ── Offline Banner ───────────────────────────────────────────────────────── */
#offline-banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  background: var(--color-warning);
  color: white;
  text-align: center;
  padding: var(--space-sm);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  z-index: var(--z-overlay);
  display: none;
}
body.offline #offline-banner { display: block; }
