/* =========================================================================
   SewSociety Global CSS System — Mobile-First Responsive Design
   ========================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  /* LIGHT MODE (Default) */
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --text-primary: #0f172a;
  --text-secondary: #475569;

  --accent-primary: #4f46e5;
  --accent-hover: #4338ca;
  --accent-light: #e0e7ff;

  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;

  --border-color: rgba(0, 0, 0, 0.08);
  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(255, 255, 255, 0.4);

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-glow: 0 0 15px rgba(79, 70, 229, 0.3);

  /* Layout tokens */
  --navbar-height: 64px;
  --container-padding: 16px;
  --section-padding-y: 3rem;
  --radius-md: 8px;
  --radius-lg: 16px;
  --transition-base: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --bg-primary: #09090b;
  --bg-secondary: #18181b;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;

  --accent-primary: #6366f1;
  --accent-hover: #818cf8;
  --accent-light: rgba(99, 102, 241, 0.15);

  --border-color: rgba(255, 255, 255, 0.08);
  --glass-bg: rgba(24, 24, 27, 0.6);
  --glass-border: rgba(255, 255, 255, 0.05);

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 25px -3px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.4);
}

/* Global Reset & Base Styles */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  transition: background-color 0.4s ease, color 0.4s ease;
  overflow-x: hidden;
  padding-top: var(--navbar-height);
}

body.nav-open {
  overflow: hidden;
}

a {
  color: var(--accent-primary);
  text-decoration: none;
  transition: color 0.3s ease;
}

a:hover {
  color: var(--accent-hover);
}

img {
  max-width: 100%;
  height: auto;
}

/* Typography — fluid scaling */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 1rem;
  letter-spacing: -0.02em;
}

h1 { font-size: clamp(1.75rem, 5vw, 3rem); }
h2 { font-size: clamp(1.5rem, 4vw, 2.5rem); }
h3 { font-size: clamp(1.25rem, 3vw, 1.75rem); }

p {
  margin-bottom: 1.5rem;
  color: var(--text-secondary);
}

/* Container */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--container-padding);
}

/* =========================================================================
   Navbar — Mobile-first with slide-out drawer
   ========================================================================= */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  z-index: 1000;
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  padding: 0.75rem 0;
  transition: all 0.4s ease;
}

.navbar .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.nav-brand {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.03em;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  z-index: 1002;
}

.nav-brand img {
  height: 36px;
  width: auto;
}

.nav-brand-text {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-primary);
}

/* Hamburger toggle — visible on mobile */
.nav-toggle {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  padding: 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  z-index: 1002;
  transition: background var(--transition-base);
  -webkit-tap-highlight-color: transparent;
}

.nav-toggle:hover {
  background: var(--accent-light);
}

.nav-toggle-bar {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(2) {
  opacity: 0;
}

.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* Mobile nav overlay */
.nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.nav-overlay.is-visible {
  display: block;
  opacity: 1;
}

/* Nav links — drawer on mobile, inline on desktop */
.nav-links {
  display: flex;
  position: fixed;
  top: 0;
  right: 0;
  width: min(320px, 88vw);
  height: 100vh;
  height: 100dvh;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  padding: calc(var(--navbar-height) + 1rem) 1.25rem 2rem;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1001;
  box-shadow: var(--shadow-lg);
}

.nav-links.is-open {
  transform: translateX(0);
}

.nav-links a {
  color: var(--text-primary);
  font-weight: 500;
  padding: 14px 12px;
  border-radius: var(--radius-md);
  font-size: 1rem;
  transition: background var(--transition-base), color var(--transition-base);
  -webkit-tap-highlight-color: transparent;
}

.nav-links a::after {
  display: none;
}

.nav-links a:hover,
.nav-links a:focus-visible {
  background: var(--accent-light);
  color: var(--accent-primary);
}

.nav-links .btn-primary {
  margin-top: 0.5rem;
  width: 100%;
  padding: 0.85rem 1rem;
  text-align: center;
}

.nav-links .theme-toggle {
  display: none;
}

.login-card {
  padding: 28px 20px;
}

@media (min-width: 640px) {
  .login-card {
    padding: 36px 32px;
  }
}

.nav-actions-mobile {
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 1002;
}

/* Theme Toggle Button */
.theme-toggle {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: 50px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  box-shadow: var(--shadow-sm);
  min-width: 44px;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
}

.theme-toggle:hover {
  background: var(--accent-light);
  transform: translateY(-2px);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.95rem;
  transition: all var(--transition-base);
  cursor: pointer;
  border: none;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
}

.btn-primary {
  background-color: var(--accent-primary);
  color: white;
  box-shadow: var(--shadow-md);
}

.btn-primary:hover {
  background-color: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
  color: white;
}

.btn-outline {
  background-color: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-outline:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  background: var(--accent-light);
}

.btn-secondary {
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

/* Hero Section */
.hero {
  padding: 3rem 0 2.5rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero h1 {
  font-size: clamp(2rem, 7vw, 4rem);
  font-weight: 800;
  margin-bottom: 1.25rem;
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent-primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero p {
  font-size: clamp(1rem, 2.5vw, 1.25rem);
  max-width: 700px;
  margin: 0 auto 1.5rem;
}

.hero-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: stretch;
  margin-top: 1.5rem;
}

.hero-actions .btn {
  width: 100%;
}

/* Page header (inner pages) */
.page-header {
  padding: 2rem 0 1.5rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  text-align: center;
}

.page-header h1 {
  margin-bottom: 0.75rem;
}

.page-header p {
  font-size: clamp(1rem, 2.5vw, 1.2rem);
  max-width: 600px;
  margin: 0 auto;
}

/* Sections */
.section {
  padding: var(--section-padding-y) 0;
}

.section-alt {
  background: var(--glass-bg);
}

.section-accent {
  background: var(--accent-primary);
  color: white;
}

.section-accent p,
.section-accent h2,
.section-accent h3 {
  color: rgba(255, 255, 255, 0.9);
}

.section-accent h3 {
  color: white;
}

/* Cards */
.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.4s ease;
  position: relative;
  overflow: hidden;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--accent-primary);
}

.card-icon {
  width: 50px;
  height: 50px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.25rem;
  flex-shrink: 0;
}

/* Forms */
.form-group {
  margin-bottom: 1.25rem;
  text-align: left;
}

.form-label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
  font-size: 0.95rem;
}

.form-control {
  width: 100%;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 16px; /* prevents iOS zoom on focus */
  transition: all 0.3s ease;
  min-height: 44px;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-light);
}

textarea.form-control {
  min-height: 120px;
  resize: vertical;
}

/* Footer */
.footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  padding: 2.5rem 0 1.5rem;
  margin-top: 3rem;
}

.footer-content {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  margin-bottom: 2rem;
}

.footer-content h3,
.footer-content h4 {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
  font-size: 1.1rem;
}

.footer-content h3 img {
  height: 28px;
}

.footer-bottom {
  text-align: center;
  border-top: 1px solid var(--border-color);
  padding-top: 1.5rem;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* Grids */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

.grid-donate {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

/* Stat numbers */
.stat-number {
  font-size: clamp(2rem, 6vw, 3rem);
  margin-bottom: 0.5rem;
  color: white;
}

.stat-label {
  color: rgba(255, 255, 255, 0.8);
  font-size: 1rem;
  margin: 0;
}

/* Modal overlay (events registration) */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 9999;
  justify-content: center;
  align-items: flex-end;
  padding: 0;
}

.modal-overlay.is-open {
  display: flex;
}

.modal-panel {
  background: var(--bg-secondary);
  width: 100%;
  max-width: 500px;
  max-height: 92vh;
  max-height: 92dvh;
  overflow-y: auto;
  padding: 1.5rem;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--shadow-lg);
  position: relative;
  -webkit-overflow-scrolling: touch;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.modal-title {
  margin-top: 0;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 10px;
  padding-right: 2rem;
  font-size: 1.15rem;
}

.modal-actions {
  display: flex;
  flex-direction: column-reverse;
  gap: 10px;
  margin-top: 1rem;
}

.modal-actions .btn {
  width: 100%;
}

/* Admin responsive helpers */
.admin-content table {
  display: block;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.admin-content .admin-page-header {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 1.25rem;
}

.admin-content .admin-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Utilities */
.text-center { text-align: center; }
.mb-4 { margin-bottom: 2rem; }
.mb-2 { margin-bottom: 1rem; }
.mt-4 { margin-top: 2rem; }
.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;
}

/* Alerts */
.alert {
  padding: 1rem;
  border-radius: var(--radius-md);
  margin-bottom: 1.5rem;
  font-weight: 500;
  font-size: 0.95rem;
}

.alert-success { background: rgba(16, 185, 129, 0.1); color: var(--success); border: 1px solid var(--success); }
.alert-danger { background: rgba(239, 68, 68, 0.1); color: var(--danger); border: 1px solid var(--danger); }

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-fade-in {
  animation: fadeIn 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Focus visible for keyboard users */
:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

/* =========================================================================
   Tablet breakpoint (min-width: 640px)
   ========================================================================= */
@media (min-width: 640px) {
  :root {
    --container-padding: 20px;
    --section-padding-y: 4rem;
  }

  .hero {
    padding: 4rem 0 3rem;
  }

  .hero-actions {
    flex-direction: row;
    justify-content: center;
    flex-wrap: wrap;
  }

  .hero-actions .btn {
    width: auto;
  }

  .page-header {
    padding: 3rem 0 2rem;
  }

  .card {
    padding: 1.5rem;
  }

  .footer-content {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.75rem;
  }

  .grid-2 {
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
  }

  .modal-overlay {
    align-items: center;
    padding: 20px;
  }

  .modal-panel {
    border-radius: var(--radius-lg);
    max-height: 90vh;
    max-height: 90dvh;
  }

  .modal-actions {
    flex-direction: row;
    justify-content: flex-end;
  }

  .modal-actions .btn {
    width: auto;
  }

  .nav-brand img {
    height: 40px;
  }
}

/* =========================================================================
   Desktop breakpoint (min-width: 992px)
   ========================================================================= */
@media (min-width: 992px) {
  :root {
    --navbar-height: 72px;
    --section-padding-y: 5rem;
  }

  body {
    padding-top: var(--navbar-height);
  }

  .navbar {
    padding: 1rem 0;
  }

  .nav-toggle {
    display: none;
  }

  .nav-overlay {
    display: none !important;
  }

  .nav-actions-mobile {
    display: none;
  }

  .nav-links {
    position: static;
    width: auto;
    height: auto;
    background: transparent;
    border: none;
    flex-direction: row;
    align-items: center;
    gap: 1.25rem;
    padding: 0;
    overflow: visible;
    transform: none;
    box-shadow: none;
    display: flex;
  }

  .nav-links a {
    padding: 0;
    font-size: 0.95rem;
    position: relative;
  }

  .nav-links a::after {
    display: block;
    content: '';
    position: absolute;
    width: 0%;
    height: 2px;
    bottom: -4px;
    left: 0;
    background-color: var(--accent-primary);
    transition: width 0.3s ease;
  }

  .nav-links a:hover,
  .nav-links a:focus-visible {
    background: transparent;
  }

  .nav-links a:hover::after {
    width: 100%;
  }

  .nav-links .btn-primary {
    margin-top: 0;
    width: auto;
    padding: 0.5rem 1rem;
  }

  .nav-links .theme-toggle {
    display: flex;
    margin-top: 0;
  }

  .hero {
    padding: 5rem 0 100px;
  }

  .page-header {
    padding: 2.5rem 0 60px;
  }

  .card {
    padding: 2rem;
  }

  .card:hover {
    transform: translateY(-8px);
  }

  .footer {
    padding: 4rem 0 2rem;
    margin-top: 5rem;
  }

  .footer-content {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
  }

  .grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
  }

  .grid-donate {
    grid-template-columns: 1fr 1.5fr;
    gap: 2rem;
  }
}

/* Safe area for notched devices */
@supports (padding: max(0px)) {
  .navbar .container {
    padding-left: max(var(--container-padding), env(safe-area-inset-left));
    padding-right: max(var(--container-padding), env(safe-area-inset-right));
  }

  .nav-links {
    padding-bottom: max(2rem, env(safe-area-inset-bottom));
  }
}
