/* 
  ===================================================================
  OFFICIAL EXECUTIVE SOVEREIGN MOBILE & MULTI-DEVICE RESPONSIVE SYSTEM
  جمهورية مصر العربية - المنظومة الوطنية للمتابعة الاستراتيجية
  ===================================================================
*/

/* Core Mobile-First Touch & Overflow Protections */
html,
body {
  overflow-x: hidden !important;
  width: 100%;
  max-width: 100vw;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-primary);
  color: var(--text-main);
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Glassmorphic Dark Backdrop Overlay */
.mobile-backdrop-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: rgba(10, 25, 47, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 9990 !important; /* Positioned below header & side drawer nav */
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.mobile-backdrop-overlay.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Base Hidden Utility Classes */
.mobile-drawer-header,
.mobile-drawer-actions,
.mobile-executive-bottom-bar {
  display: none;
}

/* --------------------------------------------------
   TABLET & SMALL LAPTOP RESPONSIVE (<= 1024px)
   -------------------------------------------------- */
@media (max-width: 1024px) {

  /* Floating Executive Header Positioning */
  .floating-executive-header {
    position: sticky;
    top: 8px;
    z-index: 9999 !important; /* Elevated above mobile-backdrop-overlay */
    padding: 0 0.75rem;
    max-width: 100%;
  }

  .header-glass-capsule {
    padding: 0.5rem 1rem;
    border-radius: 99px;
  }

  /* Native-App Slide-Over Drawer Navigation */
  .header-nav {
    position: fixed;
    top: 0;
    right: 0;
    width: 85vw;
    max-width: 360px;
    height: 100vh;
    height: 100dvh;
    background: #0a192f;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 100000 !important; /* Elevated above backdrop overlay */
    isolation: isolate;
    padding: 1.5rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    border-left: 2px solid var(--gold-primary);
    box-shadow: -15px 0 50px rgba(0, 0, 0, 0.8);
    transform: translate3d(100%, 0, 0);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    will-change: transform;
  }

  body.dark-theme .header-nav {
    background: #070e17;
  }

  .header-nav.mobile-active {
    transform: translate3d(0, 0, 0);
  }

  .mobile-drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(184, 134, 11, 0.35);
    padding-bottom: 0.85rem;
    margin-bottom: 0.75rem;
  }

  .mobile-drawer-close-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.25s ease;
  }

  .mobile-drawer-close-btn:active,
  .mobile-drawer-close-btn:hover {
    background: var(--gold-primary);
    color: #ffffff;
    transform: scale(1.05);
  }

  .mobile-drawer-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: auto;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    padding-top: 1.1rem;
  }

  .header-nav .nav-link {
    width: 100%;
    padding: 0.85rem 1.1rem;
    border-radius: 12px;
    color: #e2e8f0;
    font-size: 0.92rem;
    font-weight: 800;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.25s ease;
  }

  .header-nav .nav-link:hover,
  .header-nav .nav-link.active {
    background: var(--gold-primary);
    color: #ffffff;
    border-color: var(--gold-light);
    box-shadow: 0 4px 15px rgba(184, 134, 11, 0.3);
  }

  .mobile-nav-toggle {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(27, 54, 93, 0.08);
    border: 1px solid rgba(184, 134, 11, 0.35);
    color: var(--navy-primary);
    font-size: 1.15rem;
    cursor: pointer;
    transition: all 0.25s ease;
  }

  body.dark-theme .mobile-nav-toggle {
    background: rgba(255, 255, 255, 0.1);
    color: var(--gold-primary);
    border-color: rgba(184, 134, 11, 0.4);
  }

  /* Hero Section Responsiveness */
  .hero-container {
    grid-template-columns: 1fr;
    gap: 2.25rem;
    text-align: center;
  }

  .hero-subtitle {
    margin-left: auto;
    margin-right: auto;
  }

  .hero-cta-group {
    justify-content: center;
  }

  .pillars-grid,
  .features-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.1rem;
  }

  .executive-cta-banner {
    flex-direction: column;
    text-align: center;
    gap: 1.75rem;
    padding: 2.25rem 1.5rem;
  }
}

/* --------------------------------------------------
   ULTRA-CLEAN SMARTPHONE RESPONSIVE (<= 768px)
   -------------------------------------------------- */
@media (max-width: 768px) {

  /* HIDE NON-ESSENTIAL TOP CLUTTER ON MOBILE */
  .presidential-ticker-bar,
  .official-crest-strip,
  .hero-badge-top,
  .btn-hero-secondary,
  .header-desktop-btn {
    display: none !important;
  }

  /* Add Safe Area Padding to Body for Mobile Bottom Action Bar */
  body {
    padding-bottom: calc(68px + env(safe-area-inset-bottom, 0px)) !important;
  }

  /* Ultra-Clean Minimalist Header Capsule */
  .floating-executive-header {
    position: sticky;
    top: 6px;
    z-index: 9999 !important;
    padding: 0 0.5rem;
  }

  .header-glass-capsule {
    padding: 0.45rem 0.85rem;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid rgba(184, 134, 11, 0.35);
    box-shadow: 0 8px 24px rgba(10, 25, 47, 0.12);
  }

  body.dark-theme .header-glass-capsule {
    background: rgba(10, 25, 47, 0.94);
    border-color: rgba(184, 134, 11, 0.45);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5);
  }

  .brand-text h1 {
    font-size: clamp(0.9rem, 2.5vw + 0.5rem, 1.05rem);
    font-weight: 900;
    line-height: 1.2;
  }

  .brand-subtext {
    display: none !important;
    /* Hide secondary subtext on header capsule for mobile */
  }

  .gold-eagle-emblem-svg {
    width: 28px;
    height: 28px;
    min-width: 28px;
  }

  .vision-tag {
    font-size: 0.65rem;
    padding: 0.1rem 0.45rem;
  }

  /* Native-App Mobile Floating Executive Bottom Action Bar */
  .mobile-executive-bottom-bar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9997;
    background: rgba(10, 25, 47, 0.95);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border-top: 1px solid rgba(184, 134, 11, 0.4);
    padding: 0.45rem 0.5rem;
    padding-bottom: max(0.45rem, env(safe-area-inset-bottom, 0px));
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.5);
  }

  .mobile-bottom-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    text-decoration: none;
    color: #cbd5e1;
    font-size: 0.68rem;
    font-weight: 800;
    border: none;
    background: none;
    cursor: pointer;
    padding: 0.35rem 0.55rem;
    border-radius: 10px;
    transition: all 0.25s ease;
  }

  .mobile-bottom-btn i {
    font-size: 1.15rem;
  }

  .mobile-bottom-btn:active {
    transform: scale(0.92);
    color: var(--gold-light);
  }

  .mobile-bottom-btn.primary {
    background: linear-gradient(135deg, #1b365d 0%, #b8860b 100%);
    color: #ffffff;
    padding: 0.5rem 1.15rem;
    border-radius: 99px;
    box-shadow: 0 4px 15px rgba(184, 134, 11, 0.4);
    border: 1px solid rgba(254, 240, 138, 0.4);
  }

  .mobile-bottom-btn.primary i {
    font-size: 0.95rem;
  }

  /* Ultra-Clean Sovereign Hero Section */
  .hero-landing {
    padding: clamp(2rem, 4vw, 3rem) 1rem 2rem;
  }

  .hero-title {
    font-size: clamp(1.45rem, 5vw + 0.5rem, 1.85rem);
    line-height: 1.35;
    margin-bottom: 1rem;
    text-align: center;
  }

  .hero-subtitle {
    font-size: 0.88rem;
    line-height: 1.55;
    margin-bottom: 1.35rem;
    color: #e2e8f0;
  }

  .hero-cta-group {
    flex-direction: column;
    width: 100%;
    gap: 0.65rem;
    margin-bottom: 1.5rem;
  }

  .btn-hero-primary {
    width: 100%;
    justify-content: center;
    padding: 0.85rem 1rem;
    font-size: 0.95rem;
    border-radius: 99px;
    box-shadow: 0 6px 20px rgba(184, 134, 11, 0.4);
  }

  /* High-Contrast 2x2 Hero Metric Stats Grid */
  .hero-stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.65rem;
    margin-top: 1rem;
  }

  .hero-stat-card {
    padding: 0.85rem 0.6rem;
    border-radius: 14px;
    background: rgba(15, 23, 42, 0.75);
    border: 1px solid rgba(184, 134, 11, 0.4);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(12px);
    position: relative;
    overflow: hidden;
  }

  .hero-stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    height: 3px;
    background: var(--gold-foil);
  }

  .hero-stat-val {
    font-size: clamp(1.35rem, 4vw, 1.65rem);
    font-weight: 900;
    color: #fef08a;
    line-height: 1.1;
  }

  .hero-stat-lbl {
    font-size: 0.72rem;
    font-weight: 800;
    color: #cbd5e1;
    margin-top: 0.25rem;
  }

  /* Swiper Marquee Showcase Section */
  .logos-showcase-section {
    padding: 1.75rem 0.85rem;
  }

  .ministry-logo-card {
    min-width: unset;
    padding: 0.85rem 1rem;
    border-radius: 12px;
    border: 1px solid rgba(184, 134, 11, 0.3);
  }

  /* High-Contrast 1-Column Touch Cards for Pillars & Features */
  .pillars-grid,
  .features-grid {
    grid-template-columns: 1fr !important;
    gap: 0.85rem;
  }

  .pillar-card,
  .feature-box {
    padding: 1.15rem;
    border-radius: 14px;
    border: 1px solid rgba(184, 134, 11, 0.35);
    background: var(--bg-card);
    box-shadow: 0 4px 14px rgba(10, 25, 47, 0.05);
  }

  body.dark-theme .pillar-card,
  body.dark-theme .feature-box {
    background: var(--bg-surface);
    border-color: rgba(184, 134, 11, 0.4);
  }

  /* Touch-Optimized 1-Column Sectors Matrix Grid Stack */
  .sectors-grid,
  .sectors-matrix-grid {
    grid-template-columns: 1fr !important;
    gap: 0.85rem;
  }

  .sector-card {
    padding: 1.15rem;
    border-radius: 14px;
    border: 1px solid rgba(184, 134, 11, 0.35);
    background: var(--bg-card);
    box-shadow: 0 4px 14px rgba(10, 25, 47, 0.05);
    transition: transform 0.2s ease, border-color 0.2s ease;
  }

  body.dark-theme .sector-card {
    background: var(--bg-surface);
    border-color: rgba(184, 134, 11, 0.4);
  }

  .sector-card:active {
    transform: scale(0.98);
    border-color: var(--gold-primary);
  }

  .drilldown-btn {
    width: 100%;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: rgba(27, 54, 93, 0.06);
    border: 1px solid rgba(27, 54, 93, 0.2);
    border-radius: 10px;
    font-weight: 800;
    font-size: 0.85rem;
    color: var(--navy-primary);
    margin-top: 0.65rem;
  }

  body.dark-theme .drilldown-btn {
    background: rgba(184, 134, 11, 0.12);
    border-color: rgba(184, 134, 11, 0.3);
    color: var(--gold-primary);
  }

  /* Modal Styling on Mobile */
  .modal-card {
    width: 92% !important;
    max-height: 90vh;
    overflow-y: auto;
    padding: 1.25rem !important;
    border-radius: 16px !important;
  }

  /* Dashboard Main Components Responsiveness */
  .dashboard-main {
    padding: 1rem 0.75rem !important;
    gap: 1.5rem !important;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.75rem !important;
  }

  .charts-grid-expanded {
    grid-template-columns: 1fr !important;
    gap: 1rem !important;
  }

  .map-layout {
    grid-template-columns: 1fr !important;
    gap: 1rem !important;
  }

  .filter-bar {
    padding: 0.75rem 1rem !important;
  }

  .filter-bar-inner {
    flex-direction: column !important;
    gap: 0.75rem !important;
  }

  .filter-group {
    width: 100% !important;
    min-width: 100% !important;
  }

  .table-actions {
    flex-direction: column !important;
    align-items: stretch !important;
    width: 100% !important;
  }

  .official-search {
    width: 100% !important;
    min-width: 100% !important;
  }

  .table-actions button {
    width: 100% !important;
    justify-content: center !important;
  }

  /* Footer Layout */
  .footer-inner {
    flex-direction: column;
    text-align: center;
    gap: 1rem;
    padding: 1.75rem 1rem;
  }
}

/* --------------------------------------------------
   EXTRA SMALL PHONE VIEWPORTS (< 380px)
   -------------------------------------------------- */
@media (max-width: 380px) {
  .hero-title {
    font-size: 1.35rem;
  }

  .hero-stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.5rem;
  }

  .hero-stat-val {
    font-size: 1.25rem;
  }

  .mobile-bottom-btn {
    padding: 0.3rem 0.35rem;
    font-size: 0.64rem;
  }

  .mobile-bottom-btn.primary {
    padding: 0.45rem 0.85rem;
  }
}

/* --------------------------------------------------
   ULTRA-WIDE & 4K DISPLAYS (>= 1800px)
   -------------------------------------------------- */
@media (min-width: 1800px) {

  .hero-container,
  .features-container,
  .pillars-grid,
  .sectors-grid,
  .header-inner {
    max-width: 1720px !important;
  }

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

  .hero-subtitle {
    font-size: 1.25rem;
    max-width: 780px;
  }
}