/* ==========================================================================
   BenueDraws — Global Stylesheet (layout shell for ALL pages)
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--color-text, #0B1528);
  background: var(--color-bg, #F8FAFC);
  -webkit-font-smoothing: antialiased;
}

img, svg {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--color-primary, #0D8A4E);
  text-decoration: none;
}

a:hover { text-decoration: underline; }

ul, ol { margin: 0; padding: 0; list-style: none; }
h1, h2, h3, h4, h5, h6, p { margin-top: 0; }
button, input, select, textarea { font: inherit; }

/* --------------------------------------------------------------------------
   Centered page container
   -------------------------------------------------------------------------- */
.container {
  width: 100%;
  max-width: 1140px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 1rem;
  padding-right: 1rem;
}

@media (min-width: 768px) {
  .container {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }
}

/* Main grows; footer stays at bottom */
body > main,
#main-content,
.cert-wrapper,
.draw-detail-wrapper,
.dashboard-wrapper,
.legal-page-wrapper,
.draws-list-section {
  flex: 1 0 auto;
  width: 100%;
}

/* --------------------------------------------------------------------------
   SITE HEADER — always horizontal on desktop, clean on mobile
   -------------------------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 200;
  width: 100%;
  background: var(--color-surface, #ffffff);
  border-bottom: 1px solid var(--color-border, #e2e8f0);
  box-shadow: 0 1px 3px rgba(11, 21, 40, 0.05);
}

/* Force a real horizontal bar */
.site-header .header-container,
.header-container {
  width: 100%;
  max-width: 1140px;
  margin: 0 auto;
  padding: 0.75rem 1rem;
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: wrap;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 0.75rem 1rem;
}

@media (min-width: 900px) {
  .site-header .header-container,
  .header-container {
    flex-wrap: nowrap !important;
    padding: 0.85rem 1.5rem;
  }
}

.brand-logo {
  display: inline-flex !important;
  align-items: center;
  flex-shrink: 0;
  text-decoration: none;
  order: 1;
}

.brand-logo img {
  display: block;
  height: 36px;
  width: auto;
  max-width: 170px;
}

@media (min-width: 768px) {
  .brand-logo img {
    height: 40px;
    max-width: 180px;
  }
}

/* Nav sits in the middle as a ROW */
.main-nav {
  display: flex !important;
  align-items: center;
  justify-content: center;
  flex: 1 1 auto;
  order: 2;
  min-width: 0;
}

.nav-list {
  list-style: none !important;
  margin: 0 !important;
  padding: 0 !important;
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: wrap;
  align-items: center !important;
  justify-content: center;
  gap: 0.15rem 0.1rem;
}

.nav-list li {
  list-style: none !important;
  display: inline-flex !important;
  margin: 0 !important;
  padding: 0 !important;
}

.nav-link {
  display: inline-block !important;
  padding: 0.4rem 0.75rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text-muted, #64748B);
  text-decoration: none !important;
  border-radius: 9999px;
  white-space: nowrap;
  transition: color 0.15s ease, background 0.15s ease;
}

.nav-link:hover {
  color: var(--color-primary, #0D8A4E);
  background: rgba(13, 138, 78, 0.08);
}

.nav-link.active,
.nav-link[aria-current="page"] {
  color: var(--color-primary, #0D8A4E);
  background: rgba(13, 138, 78, 0.12);
}

/* Right side actions as a ROW */
.header-actions {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap;
  align-items: center !important;
  justify-content: flex-end;
  gap: 0.5rem;
  flex-shrink: 0;
  order: 3;
}

#navAuthArea {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 0.5rem;
}

.btn-theme-toggle {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 9999px;
  border: 1px solid var(--color-border, #e2e8f0);
  background: var(--color-bg, #F8FAFC);
  cursor: pointer;
  font-size: 1.05rem;
  line-height: 1;
  padding: 0;
}

.btn-theme-toggle:hover {
  background: rgba(13, 138, 78, 0.08);
}

/* Mobile header layout */
@media (max-width: 899px) {
  .site-header .header-container,
  .header-container {
    display: grid !important;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "logo actions"
      "nav nav";
    align-items: center;
  }

  .brand-logo { grid-area: logo; order: unset; }
  .header-actions { grid-area: actions; order: unset; }
  .main-nav {
    grid-area: nav;
    order: unset;
    width: 100%;
    justify-content: flex-start;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .nav-list {
    flex-wrap: nowrap !important;
    justify-content: flex-start;
  }

  .nav-link {
    padding: 0.35rem 0.65rem;
    font-size: 0.85rem;
  }
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.55rem 1.1rem;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.25;
  border-radius: 9999px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none !important;
  white-space: nowrap;
  font-family: inherit;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.btn:disabled { opacity: 0.65; cursor: not-allowed; }

.btn-primary {
  background: var(--color-primary, #0D8A4E);
  color: #fff !important;
  border-color: var(--color-primary, #0D8A4E);
}
.btn-primary:hover:not(:disabled) {
  background: #0a7a44;
  box-shadow: 0 4px 12px rgba(13, 138, 78, 0.25);
}

.btn-secondary {
  background: #3D2B1F;
  color: #fff !important;
  border-color: #3D2B1F;
}

.btn-outline {
  background: transparent;
  color: var(--color-text, #0B1528) !important;
  border-color: var(--color-border, #CBD5E1);
}
.btn-outline:hover:not(:disabled) {
  border-color: var(--color-primary, #0D8A4E);
  color: var(--color-primary, #0D8A4E) !important;
  background: rgba(13, 138, 78, 0.05);
}

.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.82rem; }
.btn-lg { padding: 0.85rem 1.35rem; font-size: 1rem; }
.btn-block { width: 100%; }

.btn-link {
  background: none;
  border: none;
  color: var(--color-primary, #0D8A4E);
  font-weight: 600;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
}

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.form-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text, #0B1528);
}

.form-input,
.form-select,
textarea.form-input {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--color-border, #CBD5E1);
  border-radius: 8px;
  background: var(--color-surface, #ffffff);
  color: var(--color-text, #0B1528);
  font-size: 0.95rem;
}

.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: var(--color-primary, #0D8A4E);
  box-shadow: 0 0 0 3px rgba(13, 138, 78, 0.15);
}

.form-hint {
  font-size: 0.8rem;
  color: var(--color-text-muted, #64748B);
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2364748B' d='M1.4 0.6L6 5.2 10.6 0.6 12 2 6 8 0 2z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.9rem center;
  padding-right: 2.2rem;
}

/* --------------------------------------------------------------------------
   Badges / breadcrumbs / spinner
   -------------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.7rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
}

.badge-primary {
  background: rgba(13, 138, 78, 0.12);
  color: var(--color-primary, #0D8A4E);
  border: 1px solid rgba(13, 138, 78, 0.25);
}

.breadcrumb-nav { margin-bottom: 1.25rem; }

.breadcrumb-list {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.85rem;
  color: var(--color-text-muted, #64748B);
}

.breadcrumb-list li {
  display: inline-flex !important;
}

.breadcrumb-list a {
  color: var(--color-text-muted, #64748B);
  text-decoration: none;
}

.breadcrumb-sep { opacity: 0.5; }

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(13, 138, 78, 0.2);
  border-top-color: var(--color-primary, #0D8A4E);
  border-radius: 50%;
  animation: bd-spin 0.7s linear infinite;
  margin: 0 auto 0.75rem;
}

@keyframes bd-spin {
  to { transform: rotate(360deg); }
}

.detail-loading-box,
.draws-empty-box {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--color-text-muted, #64748B);
}

/* Progress */
.progress-bar-track {
  width: 100%;
  height: 8px;
  background: var(--color-border, #e2e8f0);
  border-radius: 9999px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary, #0D8A4E), #10B981);
  border-radius: 9999px;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--color-text-muted, #64748B);
  margin-bottom: 0.35rem;
}

.progress-figures {
  font-weight: 600;
  color: var(--color-text, #0B1528);
}

/* Skeleton */
.skeleton-image,
.skeleton-line {
  background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
  background-size: 200% 100%;
  animation: bd-shimmer 1.4s ease infinite;
  border-radius: 8px;
}
.skeleton-image { height: 160px; width: 100%; }
.skeleton-line { height: 12px; margin-bottom: 0.6rem; }
.skeleton-content { padding: 1rem; }
@keyframes bd-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Utilities */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-primary { color: var(--color-primary, #0D8A4E); }

/* --------------------------------------------------------------------------
   SITE FOOTER
   -------------------------------------------------------------------------- */
.site-footer {
  flex-shrink: 0;
  width: 100%;
  background: var(--color-surface, #ffffff);
  border-top: 1px solid var(--color-border, #e2e8f0);
  padding-top: 2.5rem;
  margin-top: auto;
}

.footer-container {
  display: grid !important;
  grid-template-columns: 1fr;
  gap: 1.75rem;
  padding-bottom: 2rem;
}

@media (min-width: 640px) {
  .footer-container {
    grid-template-columns: 1.4fr 1fr 1fr;
  }
}

.footer-col {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.footer-col img {
  height: 36px;
  width: auto;
  max-width: 160px;
}

.footer-desc {
  font-size: 0.9rem;
  color: var(--color-text-muted, #64748B);
  line-height: 1.6;
  margin: 0;
  max-width: 320px;
}

.footer-title {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--color-text, #0B1528);
  margin: 0 0 0.35rem;
}

.footer-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 0;
  padding: 0;
}

.footer-links a {
  font-size: 0.9rem;
  color: var(--color-text-muted, #64748B);
  text-decoration: none;
}

.footer-links a:hover,
.footer-links a.active {
  color: var(--color-primary, #0D8A4E);
}

.footer-bottom {
  border-top: 1px solid var(--color-border, #e2e8f0);
  padding: 1rem 1rem 1.25rem;
  text-align: center;
}

.footer-bottom p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--color-text-muted, #94A3B8);
}

/* Dark mode */
[data-theme="dark"] body {
  background: var(--color-bg, #0B1528);
  color: var(--color-text, #F1F5F9);
}

[data-theme="dark"] .site-header,
[data-theme="dark"] .site-footer {
  background: var(--color-surface, #111827);
  border-color: var(--color-border, #1F2937);
}

[data-theme="dark"] .btn-outline {
  color: var(--color-text, #F1F5F9) !important;
}