/* ==========================================================================
   Family Platform - Heritage Design System & Design Tokens
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Amiri:ital,wght@0,400;0,700;1,400&family=Plus+Jakarta+Sans:wght@400;500;600;700&family=Tajawal:wght@400;500;700;800&display=swap');

:root {
  /* Heritage Palette Tokens */
  --brand-deep-green: #003C2F;
  --brand-dark-green: #002A22;
  --brand-gold:       #C89A3D;
  --brand-warm-gold:  #E6BB69;
  --brand-ivory:      #F7F5F0;
  --brand-white:      #FFFFFF;

  /* Theme Defaults: Light Mode */
  --bg-primary:       #F7F5F0;
  --bg-surface:       #FFFFFF;
  --bg-surface-elevated: #FFFFFF;
  --bg-card:          #FFFFFF;
  --bg-header:        rgba(255, 255, 255, 0.92);
  --bg-hero:          radial-gradient(130% 90% at 50% 10%, #EAE4D7 0%, #F7F5F0 100%);
  --bg-badge:         rgba(200, 154, 61, 0.12);

  --text-primary:     #142521;
  --text-secondary:   #3E524D;
  --text-muted:       #6C7D78;
  --text-inverted:    #FFFFFF;
  --text-gold:        #9B7322;

  --border-light:     #E5DFD4;
  --border-color:     #DCD5C7;
  --border-focus:     #C89A3D;

  --btn-primary-bg:   #003C2F;
  --btn-primary-text: #FFFFFF;
  --btn-primary-hover: #002A22;
  --btn-secondary-bg: #FFFFFF;
  --btn-secondary-text: #003C2F;
  --btn-secondary-border: #C89A3D;
  --btn-secondary-hover: rgba(200, 154, 61, 0.08);

  --shadow-sm:        0 1px 3px rgba(0, 42, 34, 0.05);
  --shadow-md:        0 4px 12px rgba(0, 42, 34, 0.07);
  --shadow-lg:        0 12px 28px rgba(0, 42, 34, 0.09);

  /* Typography */
  --font-family-arabic: 'Tajawal', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-family-latin: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-family-heritage: 'Amiri', serif;
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --container-max: 1200px;
  --transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Dark Mode Tokens */
[data-theme="dark"] {
  --bg-primary:       #0A1412;
  --bg-surface:       #11201D;
  --bg-surface-elevated: #162925;
  --bg-card:          #11201D;
  --bg-header:        rgba(17, 32, 29, 0.94);
  --bg-hero:          radial-gradient(130% 90% at 50% 10%, #162925 0%, #0A1412 100%);
  --bg-badge:         rgba(230, 187, 105, 0.16);

  --text-primary:     #F3F5F4;
  --text-secondary:   #C2CCC8;
  --text-muted:       #8A9A95;
  --text-inverted:    #0A1412;
  --text-gold:        #E6BB69;

  --border-light:     #1E332E;
  --border-color:     #253F39;
  --border-focus:     #E6BB69;

  --btn-primary-bg:   #C89A3D;
  --btn-primary-text: #002A22;
  --btn-primary-hover: #E6BB69;
  --btn-secondary-bg: transparent;
  --btn-secondary-text: #E6BB69;
  --btn-secondary-border: #C89A3D;
  --btn-secondary-hover: rgba(200, 154, 61, 0.14);

  --shadow-sm:        0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md:        0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg:        0 12px 30px rgba(0, 0, 0, 0.55);
}

/* ==========================================================================
   Base & Reset
   ========================================================================== */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  height: 100%;
}

body {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  font-family: var(--font-family-arabic);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.25s ease, color 0.25s ease;
}

[dir="ltr"] body {
  font-family: var(--font-family-latin);
}

a {
  color: inherit;
  text-decoration: none;
  transition: var(--transition);
}

img, svg {
  display: block;
  max-width: 100%;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

/* Focus styles for accessibility */
a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

.container {
  width: 100%;
  max-width: var(--container-max);
  margin-left: auto;
  margin-right: auto;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

/* ==========================================================================
   Header & Navigation
   ========================================================================== */

.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background-color: var(--bg-header);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-light);
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 4.75rem;
}

/* Brand */
.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: -0.01em;
}

.brand-icon {
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--brand-deep-green), var(--brand-dark-green));
  color: var(--brand-gold);
  border-radius: var(--radius-md);
  border: 1px solid rgba(200, 154, 61, 0.4);
  box-shadow: var(--shadow-sm);
}

[data-theme="dark"] .brand-icon {
  background: linear-gradient(135deg, #162925, #002A22);
  border-color: var(--brand-gold);
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  color: var(--text-primary);
  font-weight: 800;
  line-height: 1.2;
}

.brand-subtitle {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Navigation Links */
.nav-menu {
  display: flex;
  align-items: center;
  gap: 2rem;
  list-style: none;
}

.nav-link {
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--text-secondary);
  padding: 0.5rem 0.25rem;
  position: relative;
}

.nav-link:hover, .nav-link.active {
  color: var(--text-primary);
}

.nav-link.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--brand-gold);
  border-radius: var(--radius-full);
}

/* Header Utilities */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.control-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  height: 2.35rem;
  padding: 0 0.85rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  transition: var(--transition);
}

.control-btn:hover {
  background-color: var(--bg-surface-elevated);
  border-color: var(--border-focus);
  color: var(--text-primary);
}

.icon-only-btn {
  width: 2.35rem;
  padding: 0;
}

.btn-login {
  background-color: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  border-color: var(--btn-primary-bg);
}

.btn-login:hover {
  background-color: var(--btn-primary-hover);
  color: var(--btn-primary-text);
}

.mobile-toggle {
  display: none;
}

/* ==========================================================================
   Hero Section
   ========================================================================== */

.hero-section {
  padding: 5rem 0 4.5rem;
  background: var(--bg-hero);
  border-bottom: 1px solid var(--border-light);
  position: relative;
  overflow: hidden;
}

.hero-section::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -20%;
  width: 140%;
  height: 200%;
  background-image: radial-gradient(circle at 50% 20%, rgba(200, 154, 61, 0.08) 0%, transparent 60%);
  pointer-events: none;
}

.hero-content {
  position: relative;
  z-index: 1;
  max-width: 820px;
  margin: 0 auto;
  text-align: center;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 1rem;
  border-radius: var(--radius-full);
  background: var(--bg-badge);
  border: 1px solid rgba(200, 154, 61, 0.35);
  color: var(--text-gold);
  font-size: 0.88rem;
  font-weight: 700;
  margin-bottom: 1.75rem;
}

.hero-title {
  font-size: 2.85rem;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: 1.5rem;
}

.hero-subtitle {
  font-size: 1.15rem;
  line-height: 1.75;
  color: var(--text-secondary);
  margin-bottom: 2.5rem;
  max-width: 680px;
  margin-left: auto;
  margin-right: auto;
}

.hero-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.85rem 1.85rem;
  font-weight: 700;
  font-size: 1rem;
  border-radius: var(--radius-md);
  transition: var(--transition);
  border: 1px solid transparent;
}

.btn-primary {
  background-color: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  box-shadow: 0 4px 14px rgba(0, 60, 47, 0.25);
}

.btn-primary:hover {
  background-color: var(--btn-primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(0, 60, 47, 0.35);
}

.btn-secondary {
  background-color: var(--btn-secondary-bg);
  color: var(--btn-secondary-text);
  border-color: var(--btn-secondary-border);
}

.btn-secondary:hover {
  background-color: var(--btn-secondary-hover);
  transform: translateY(-1px);
}

/* ==========================================================================
   Features Section
   ========================================================================== */

.section {
  padding: 5rem 0;
}

.section-header {
  text-align: center;
  max-width: 660px;
  margin: 0 auto 3.5rem;
}

.section-title {
  font-size: 2.1rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 0.85rem;
  letter-spacing: -0.01em;
}

.section-desc {
  font-size: 1.05rem;
  color: var(--text-muted);
  line-height: 1.65;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.75rem;
}

.feature-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 2.25rem 1.75rem;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.feature-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--brand-deep-green), var(--brand-gold));
  opacity: 0;
  transition: opacity 0.25s ease;
}

.feature-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-color);
}

.feature-card:hover::before {
  opacity: 1;
}

.feature-icon-wrapper {
  width: 3.25rem;
  height: 3.25rem;
  border-radius: var(--radius-md);
  background: var(--bg-badge);
  border: 1px solid rgba(200, 154, 61, 0.25);
  color: var(--text-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.feature-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
}

.feature-desc {
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.65;
}

/* ==========================================================================
   Footer
   ========================================================================== */

.site-footer {
  margin-top: auto;
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-light);
  padding: 3.5rem 0 2rem;
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

.footer-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 2.5rem;
  padding-bottom: 2.5rem;
  border-bottom: 1px solid var(--border-light);
  flex-wrap: wrap;
}

.footer-brand {
  max-width: 380px;
}

.footer-brand-desc {
  margin-top: 0.85rem;
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.65;
}

.footer-nav {
  display: flex;
  gap: 2rem;
  list-style: none;
  flex-wrap: wrap;
}

.footer-link {
  font-size: 0.92rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.footer-link:hover {
  color: var(--text-gold);
}

.footer-bottom {
  padding-top: 1.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  flex-wrap: wrap;
  gap: 1rem;
}

/* ==========================================================================
   Error Pages
   ========================================================================== */

.error-hero {
  padding: 6rem 0;
  text-align: center;
}

.error-code {
  font-size: 6rem;
  font-weight: 800;
  line-height: 1;
  color: var(--brand-gold);
  margin-bottom: 1rem;
}

.error-title {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

.error-desc {
  font-size: 1.1rem;
  color: var(--text-muted);
  max-width: 500px;
  margin: 0 auto 2rem;
}

/* ==========================================================================
   Responsive & Mobile Navigation
   ========================================================================== */

@media (max-width: 900px) {
  .hero-title {
    font-size: 2.2rem;
  }
  .section-title {
    font-size: 1.8rem;
  }
}

@media (max-width: 768px) {
  .header-inner {
    height: 4.25rem;
  }

  .mobile-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.35rem;
    height: 2.35rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background-color: var(--bg-surface);
    color: var(--text-primary);
  }

  .nav-menu {
    position: fixed;
    top: 4.25rem;
    left: 0;
    right: 0;
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    flex-direction: column;
    padding: 1.5rem;
    gap: 1rem;
    display: none;
    z-index: 999;
  }

  .nav-menu.open {
    display: flex;
  }

  .nav-link {
    width: 100%;
    padding: 0.6rem 0;
  }

  .hero-section {
    padding: 3.5rem 0 3rem;
  }

  .hero-title {
    font-size: 1.85rem;
  }

  .hero-subtitle {
    font-size: 1rem;
    margin-bottom: 2rem;
  }

  .footer-top {
    flex-direction: column;
    gap: 1.5rem;
  }

  .footer-bottom {
    flex-direction: column;
    text-align: center;
  }
}

/* ==========================================================================
   Admin Dashboard Shell Styles (Phase 2)
   ========================================================================== */

.admin-wrapper {
  display: flex;
  min-height: 100vh;
  background-color: var(--bg-primary);
  color: var(--text-primary);
}

.admin-sidebar {
  width: 270px;
  background-color: var(--bg-surface);
  border-inline-end: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 1000;
}

.admin-sidebar-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.admin-sidebar-nav {
  flex: 1;
  padding: 1.25rem 0.85rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.admin-nav-heading {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 0.6rem 0.85rem 0.25rem;
  margin-top: 0.5rem;
}

.admin-nav-item {
  list-style: none;
}

.admin-nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  transition: var(--transition);
}

.admin-nav-link:hover {
  background-color: var(--bg-badge);
  color: var(--brand-gold);
}

.admin-nav-link.active {
  background-color: var(--brand-deep-green);
  color: #FFFFFF;
  font-weight: 600;
}

[data-theme="dark"] .admin-nav-link.active {
  background-color: var(--brand-gold);
  color: #002A22;
}

.admin-nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.admin-nav-badge {
  margin-inline-start: auto;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  background-color: var(--border-light);
  color: var(--text-muted);
}

.admin-nav-link.active .admin-nav-badge {
  background-color: rgba(255, 255, 255, 0.25);
  color: #FFFFFF;
}

[data-theme="dark"] .admin-nav-link.active .admin-nav-badge {
  background-color: rgba(0, 42, 34, 0.25);
  color: #002A22;
}

.admin-sidebar-footer {
  padding: 1.25rem;
  border-top: 1px solid var(--border-light);
  background-color: var(--bg-surface);
}

.admin-user-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.admin-user-avatar {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--radius-full);
  background: var(--brand-deep-green);
  color: var(--brand-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.admin-user-info {
  flex: 1;
  min-width: 0;
}

.admin-user-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-user-role {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.admin-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.admin-header {
  height: 4rem;
  background-color: var(--bg-header);
  border-bottom: 1px solid var(--border-light);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.75rem;
}

.admin-header-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.admin-title-text {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-primary);
}

.admin-header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.admin-body {
  padding: 2rem 1.75rem;
  flex: 1;
  max-width: 1350px;
  width: 100%;
  margin: 0 auto;
}

/* Stat Cards */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.stat-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  transition: var(--transition);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-focus);
}

.stat-card-value {
  font-size: 2.25rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.1;
  margin-bottom: 0.35rem;
  font-family: var(--font-family-latin);
}

.stat-card-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

.stat-card-desc {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.stat-card-icon {
  width: 3rem;
  height: 3rem;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: rgba(200, 154, 61, 0.12);
  color: var(--brand-gold);
}

/* Admin Card Component */
.admin-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 2rem;
  overflow: hidden;
}

.admin-card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.admin-card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.admin-card-body {
  padding: 1.5rem;
}

/* Mobile Sidebar Drawer */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 998;
}

@media (max-width: 900px) {
  .admin-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    transform: translateX(-100%);
  }

  [dir="rtl"] .admin-sidebar {
    left: auto;
    right: 0;
    transform: translateX(100%);
  }

  .admin-sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay.open {
    display: block;
  }

  .admin-header {
    padding: 0 1rem;
  }

  .admin-body {
    padding: 1.25rem 1rem;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
