/* Page isolation */
.app-page {
  display: none !important;
}
.app-page.active-page {
  display: block !important;
}
#portalSection.active-page {
  display: flex !important;
  flex-direction: column !important;
}
[style*="display: none"] {
  display: none !important;
}

/* Theme overrides */
@media (max-width: 768px) {
  :root {
    --bg:         #0F172A !important;
    --bg2:        #1E293B !important;
    --bg3:        #263548 !important;
    --bg4:        #2D3F56 !important;
    --c-bg:       #0F172A !important;
    --c-surface:  #1E293B !important;
    --c-card:     #1E293B !important;

    --border:     rgba(148,163,184,0.08) !important;
    --border2:    rgba(148,163,184,0.13) !important;
    --c-border:   rgba(148,163,184,0.08) !important;
    --glass-border: rgba(148,163,184,0.1) !important;

    --text:       #F1F5F9 !important;
    --text2:      #94A3B8 !important;
    --text3:      #64748B !important;
    --c-text:     #F1F5F9 !important;
    --c-muted:    #64748B !important;

    --shadow-gold: none !important;
    --gold-bg:     transparent !important;
    --gold-border: rgba(148,163,184,0.15) !important;

    --shadow-sm:  0 1px 4px rgba(0,0,0,0.3) !important;
    --shadow-md:  0 4px 12px rgba(0,0,0,0.35) !important;
    --shadow-lg:  0 8px 24px rgba(0,0,0,0.4) !important;

    --h-header:   50px;
    --h-leaders:  0px;
    --h-total:    50px;
    --app-bottom-nav: 62px;
    --mob-pad:    14px;
    --mob-r:      14px;
  }
}

/* Body */
@media (max-width: 768px) {
  body {
    padding-top: 50px !important;
    padding-bottom: 70px !important;
    background: #0F172A !important;
  }
  body.admin-mode {
    padding-top: 50px !important;
    padding-bottom: 0 !important;
  }
  .orb, body::before { display: none !important; }
}

/* Header */
@media (max-width: 768px) {
  header {
    height: 50px !important;
    background: #0D1525 !important;
    border-bottom: 1px solid rgba(148,163,184,0.15) !important;
    box-shadow: 0 1px 6px rgba(0,0,0,0.4) !important;
  }
  header > div { padding: 0 14px !important; gap: 10px !important; }
  .header-logos { gap: 0 !important; }
  .header-logos img, .gov-emblem-header {
    width: 34px !important; height: 34px !important;
    border-radius: 50% !important; border: 1.5px solid rgba(212, 175, 55, 0.7) !important;
    background: #086948 !important; padding: 0 !important;
    object-fit: cover !important; object-position: center !important;
    box-shadow: 0 1px 6px rgba(0,0,0,0.3) !important;
  }
  .header-title h1 { font-size: 0.75rem !important; }
  .header-title small { display: none !important; }
  .header-actions, #loginBtn, #headerAdminBtn, #headerLogoutBtn { display: none !important; }

  .flag-stripe { display: none !important; }
  #leadershipSection { display: none !important; }
}

/* FAB */
@media (max-width: 768px) {
  .fab-button { display: none !important; }
  .fab-back-admin-btn {
    bottom: calc(var(--app-bottom-nav) + 10px) !important;
    left: 14px !important;
    z-index: 1100 !important;
    width: 42px !important; height: 42px !important;
  }
  .fab-sidebar-btn {
    display: none !important;
  }
}

/* Bottom navigation */
#appBottomNav { display: none; }
#adminBottomNav { display: none; }

@media (max-width: 768px) {
  /* Citizen Bottom Nav (Hidden in admin mode) */
  #appBottomNav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: var(--app-bottom-nav);
    background: #080F1E;
    border-top: 1px solid rgba(148,163,184,0.08);
    z-index: 1050;
    align-items: stretch;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.4);
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  body.admin-mode #appBottomNav {
    display: none !important;
  }
  body:not(.admin-mode) #adminBottomNav {
    display: none !important;
  }
  body.admin-mode #adminBottomNav {
    display: flex !important;
  }

  .bnav-item {
    flex: 1;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 3px;
    background: none; border: none;
    color: #475569;
    font-family: 'Cairo', sans-serif;
    font-size: 0.65rem; font-weight: 600;
    cursor: pointer;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation; user-select: none;
    transition: color 0.15s;
    padding: 0;
    text-decoration: none;
  }
  .bnav-item i {
    font-size: 1.2rem; line-height: 1;
    transition: transform 0.15s, color 0.15s;
  }
  .bnav-item span { font-size: 0.62rem; }
  .bnav-item:active { background: rgba(255,255,255,0.03); }

  .bnav-item.active { color: #10B981; }
  .bnav-item.active i {
    color: #10B981; transform: translateY(-2px);
  }
  .bnav-item.active::after {
    content: ''; position: absolute;
    bottom: 0; left: 50%; transform: translateX(-50%);
    width: 20px; height: 2px;
    background: #10B981; border-radius: 2px 2px 0 0;
  }
  .bnav-item.bnav-login { color: #475569; }
  .bnav-item.bnav-login.active { color: #10B981; }
  .bnav-item.bnav-login.active i { color: #10B981; }
  .bnav-item.bnav-login.active::after { background: #10B981; }

  .engineer-footer,
  .fixed-dev-badge,
  .egypt-flag-footer-stripe,
  [class*="engineer"],
  [id*="engineer"],
  [class*="dev-footer"],
  [id*="dev-footer"],
  footer { display: none !important; }

  /* بصمة التطوير في أسفل الموبايل (موحدة فوق شريط التنقل) */
  footer.gov-developer-footer,
  .gov-developer-footer {
    display: flex !important;
    margin: 18px auto 85px auto !important;
    padding: 0 10px !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
  .dev-footer-inner {
    padding: 8px 14px !important;
    font-size: 0.72rem !important;
    gap: 8px !important;
  }
}

/* ══════════════════════════════════════════════════════════
   CONTAINER
══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .container { padding: 0 !important; max-width: 100% !important; }
}

/* ══════════════════════════════════════════════════════════
   PORTAL SECTION — Mobile Container Spacing
══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  #portalSection {
    padding: 10px var(--mob-pad) 14px !important;
    flex-direction: column !important;
    gap: 10px !important;
  }
}



/* ══════════════════════════════════════════════════════════
   FIX 3: WHATSAPP — زر واحد + Bottom Sheet
══════════════════════════════════════════════════════════ */
/* Desktop: مخفي */
.mob-only { display: none; }
.desk-only { display: block; }

@media (max-width: 768px) {
  /* الـ section container */
  .wa-contact-section {
    padding: 14px var(--mob-pad) 12px !important;
  }

  /* إخفاء desktop 3 buttons */
  .desk-only { display: none !important; }

  /* إظهار mobile single button */
  .mob-only { display: flex !important; }

  /* زر "تواصل مع الدعم" الواحد */
  .wa-single-btn {
    width: 100%;
    display: flex !important;
    align-items: center;
    gap: 10px;
    padding: 13px 16px;
    background: rgba(37,211,102,0.08);
    border: 1px solid rgba(37,211,102,0.2);
    border-radius: 12px;
    color: #4ADE80;
    font-family: 'Cairo', sans-serif;
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.2s;
  }
  .wa-single-btn:active { background: rgba(37,211,102,0.14); }
  .wa-single-btn i:first-child { font-size: 1.2rem; color: #25D366; }
  .wa-single-btn i:last-child { font-size: 1rem; color: #64748B; }
}

/* WhatsApp Bottom Sheet */
#waBottomSheet {
  display: none;
  position: fixed; inset: 0;
  z-index: 9999;
  align-items: flex-end;
  justify-content: stretch;
}
#waBottomSheet[style*="flex"] { display: flex !important; }

.wa-sheet-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
}
.wa-sheet-inner {
  position: relative; z-index: 1;
  width: 100%;
  background: #1E293B;
  border-radius: 22px 22px 0 0;
  padding: 8px 0 24px;
  box-shadow: 0 -8px 40px rgba(0,0,0,0.6);
  animation: sheetSlideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes sheetSlideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
.wa-sheet-handle {
  width: 36px; height: 4px;
  background: rgba(148,163,184,0.25);
  border-radius: 2px;
  margin: 0 auto 16px;
}
.wa-sheet-header {
  display: flex; align-items: center; gap: 10px;
  padding: 0 20px 14px;
  border-bottom: 1px solid rgba(148,163,184,0.08);
  font-family: 'Cairo', sans-serif;
  font-size: 1rem; font-weight: 800;
  color: #F1F5F9;
}
.wa-sheet-list { padding: 8px 0; }
.wa-contact-row {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 20px;
  text-decoration: none;
  border-bottom: 1px solid rgba(148,163,184,0.06);
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.wa-contact-row:last-child { border-bottom: none; }
.wa-contact-row:active { background: rgba(255,255,255,0.04); }
.wa-contact-icon {
  width: 42px; height: 42px;
  background: rgba(37,211,102,0.1);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  color: #25D366; font-size: 1.1rem; flex-shrink: 0;
}
.wa-contact-info {
  flex: 1; display: flex; flex-direction: column; gap: 2px;
}
.wa-contact-name {
  font-family: 'Cairo', sans-serif;
  font-size: 0.88rem; font-weight: 700;
  color: #F1F5F9;
}
.wa-contact-num {
  font-size: 0.72rem; color: #64748B;
  direction: ltr; text-align: right;
}
.wa-contact-arrow { font-size: 1.1rem; color: #475569; flex-shrink: 0; }

/* ══════════════════════════════════════════════════════════
   CARDS — بطاقات داخلية بدون neon
══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .card, .card-blue {
    background: #1E293B !important;
    border: 1px solid rgba(148,163,184,0.08) !important;
    border-color: rgba(148,163,184,0.08) !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3) !important;
    padding: 16px !important; border-radius: var(--mob-r) !important;
    margin: 10px var(--mob-pad) !important;
  }
  .page-header {
    margin-bottom: 14px !important; padding-bottom: 10px !important;
    border-bottom-color: rgba(148,163,184,0.08) !important;
  }
  .page-header h2 { font-size: 0.9rem !important; }
  .btn-back { padding: 5px 10px !important; font-size: 0.7rem !important; height: 30px !important; min-height: 30px !important; }
}

/* ══════════════════════════════════════════════════════════
   ADMIN PANEL
══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .search-row { padding: 8px var(--mob-pad) !important; gap: 6px !important; }
  .search-input {
    font-size: 0.85rem !important; padding: 8px 10px !important;
    height: 38px !important; border-radius: 10px !important;
    background: #1E293B !important; border-color: rgba(148,163,184,0.12) !important;
    color: #F1F5F9 !important;
  }
  .search-select {
    font-size: 0.78rem !important; padding: 6px 8px !important;
    height: 38px !important; border-radius: 10px !important;
    background: #1E293B !important; border-color: rgba(148,163,184,0.12) !important;
    color: #F1F5F9 !important;
  }
  .filter-chips { gap: 8px !important; padding: 6px var(--mob-pad) !important; flex-wrap: nowrap !important; overflow-x: auto !important; scrollbar-width: none !important; }
  .filter-chips::-webkit-scrollbar { display: none; }
  .chip {
    font-size: 0.8rem !important; padding: 6px 16px !important;
    height: 36px !important; min-height: 36px !important;
    border-radius: 18px !important; flex-shrink: 0 !important; white-space: nowrap !important;
    background: #1E293B !important; border: 1px solid rgba(148,163,184,0.18) !important;
    color: #94A3B8 !important; display: inline-flex !important; align-items: center !important; gap: 6px !important;
    font-weight: 700 !important;
  }
  .chip.active, .chip:active {
    background: rgba(201,168,76,0.18) !important;
    border-color: rgba(201,168,76,0.4) !important; color: #E5C368 !important;
  }
  .chip.yellow.active {
    background: rgba(201,168,76,0.2) !important;
    border-color: rgba(201,168,76,0.5) !important; color: #F59E0B !important;
  }
  .chip.blue.active {
    background: rgba(59,130,246,0.2) !important;
    border-color: rgba(59,130,246,0.5) !important; color: #60A5FA !important;
  }
}

/* ══════════════════════════════════════════════════════════
   PAGINATION
══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .pagination-bar {
    padding: 8px 10px !important;
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 8px !important;
    background: #1E293B !important;
    border: none !important;
    border-top: 1px solid rgba(148,163,184,0.12) !important;
    border-radius: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }
  .pagination-bar .btn.btn-info {
    padding: 5px 10px !important;
    font-size: 0.76rem !important;
    height: 32px !important;
    min-height: 32px !important;
    border-radius: 8px !important;
  }
  .page-info {
    font-size: 0.74rem !important;
    padding: 4px 10px !important;
    background: rgba(148,163,184,0.08) !important;
    border-radius: 6px !important;
    border: 1px solid rgba(148,163,184,0.12) !important;
    white-space: nowrap !important;
    color: #F1F5F9 !important;
    font-weight: 700 !important;
  }
}

/* ══════════════════════════════════════════════════════════
   TABLE — No Horizontal Scroll (Strict 100% Fit)
══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .table-wrap {
    width: 100% !important;
    margin: 0 !important;
    border-radius: 12px !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
    background: #151D2A !important;
    border: 1px solid rgba(148,163,184,0.15) !important;
  }
  .table-container, [id$="TableContainer"] {
    overflow-x: hidden !important; /* STRICTLY NO HORIZONTAL SCROLL */
    border-radius: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }
  table, table.gov-responsive-table {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    table-layout: fixed !important;
    border-collapse: collapse !important;
  }
  table th {
    font-size: 0.72rem !important;
    padding: 10px 4px !important;
    white-space: nowrap !important;
    background: #0F172A !important;
    color: #94A3B8 !important;
    text-align: right;
  }
  table td {
    font-size: 0.75rem !important;
    padding: 10px 4px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    vertical-align: middle !important;
  }
  table td.td-actions {
    text-align: center !important;
    padding: 6px 2px !important;
    overflow: visible !important;
  }
  .btn-dossier {
    width: 32px !important;
    height: 32px !important;
    font-size: 1.1rem !important;
  }
  table .btn {
    padding: 4px 8px !important;
    font-size: 0.68rem !important;
    border-radius: 6px !important;
    min-height: 28px !important;
  }
}

/* ══════════════════════════════════════════════════════════
   INPUT GROUPS
══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .input-group { margin-bottom: 12px !important; }
  .input-group label { font-size: 0.75rem !important; margin-bottom: 5px !important; color: #94A3B8 !important; }
  .input-group input, .input-group select, .input-group textarea {
    font-size: 16px !important; padding: 10px 12px !important;
    border-radius: 10px !important; min-height: 42px !important; height: auto !important;
    background: #263548 !important; border-color: rgba(148,163,184,0.12) !important;
    color: #F1F5F9 !important;
  }
}

/* ══════════════════════════════════════════════════════════
   MODALS — Bottom Sheet style
══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .gov-login-card {
    width: 92% !important;
    max-width: 400px !important;
    border-radius: 18px !important;
    padding: 24px 18px !important;
  }

  .gov-modal {
    align-items: flex-end !important;
    padding: 0 !important;
  }
  .gov-modal-dialog {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 88vh !important;
    overflow-y: auto !important;
    border-radius: 20px 20px 0 0 !important;
    margin: 0 !important;
  }
}

/* ══════════════════════════════════════════════════════════
   TOAST
══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  #toastContainer {
    bottom: calc(var(--app-bottom-nav) + 8px) !important;
    right: 10px !important; left: 10px !important;
    max-width: 100% !important; transform: none !important; width: auto !important;
  }
}

/* ══════════════════════════════════════════════════════════
   STATS
══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .stats-dashboard-grid, .stats-grid { grid-template-columns: 1fr 1fr !important; gap: 8px !important; padding: 10px var(--mob-pad) !important; }
  .stat-card { padding: 12px 10px !important; border-radius: 12px !important; background: #1E293B !important; border-color: rgba(148,163,184,0.08) !important; }
}

/* ══════════════════════════════════════════════════════════
   ADMIN LAYOUT
══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .admin-layout { margin-top: 0 !important; width: 100% !important; }
  .admin-main { margin-right: 0 !important; padding: 6px 4px !important; width: 100% !important; box-sizing: border-box !important; }
  .admin-page-bar { padding: 8px 10px !important; margin: 0 0 6px 0 !important; border-radius: 10px !important; width: 100% !important; box-sizing: border-box !important; }
  .admin-top-bar { padding: 0 10px !important; height: 46px !important; gap: 5px !important; }
  .admin-top-bar .btn { font-size: 0.68rem !important; padding: 4px 8px !important; height: 30px !important; min-height: 30px !important; }
}

/* ══════════════════════════════════════════════════════════
   TOUCH + GENERAL
══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  html { scroll-behavior: auto !important; -webkit-overflow-scrolling: touch; }
  button, a, [onclick] { touch-action: manipulation; }
}
