/* Base Layout & Page Isolation */
html {
  scroll-behavior: auto !important;
}

body {
  margin: 0;
  padding-top: var(--header-height);
  padding-bottom: var(--total-bottom-offset);
  background-color: var(--color-surface-base);
  color: var(--color-text-primary);
  font-family: var(--font-family-base);
  direction: rtl;
  text-align: right;
  -webkit-font-smoothing: antialiased;
}

.app-page {
  display: none !important;
}

.app-page.active-page {
  display: block !important;
}

#portalSection.active-page {
  display: flex !important;
  flex-direction: column !important;
}

/* Header */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background-color: var(--color-surface-card);
  border-bottom: 1px solid var(--color-border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-md);
  z-index: 1000;
  box-shadow: var(--shadow-sm);
}

.app-header-brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.app-header-logo {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  object-fit: contain;
}

.app-header-title {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-primary);
  margin: 0;
}

/* Hero Section */
.portal-hero-card {
  background: var(--color-surface-card);
  border: 1px solid var(--color-border-medium);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  text-align: center;
  box-shadow: var(--shadow-md);
  margin-bottom: var(--space-sm);
}

.portal-hero-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-md);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-pill);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-sm);
}

.portal-hero-badge i {
  color: #38BDF8;
}

.portal-hero-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-primary);
  margin: 0 0 var(--space-xs);
  line-height: 1.35;
}

.portal-hero-desc {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  line-height: 1.5;
  margin: 0 0 var(--space-md);
}

.portal-hero-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.portal-hero-cta,
.portal-hero-sec {
  width: 100%;
  box-sizing: border-box;
  min-height: 48px;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  font-family: var(--font-family-base);
  font-weight: var(--font-weight-bold);
  font-size: var(--font-size-base);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform var(--transition-fast), background var(--transition-fast);
}

.portal-hero-cta {
  background-color: #1E293B;
  border: 1px solid #334155;
  color: var(--color-text-primary);
  box-shadow: var(--shadow-sm);
}

.portal-hero-cta:active {
  transform: scale(0.98);
  background-color: #24344D;
}

.portal-hero-sec {
  background-color: transparent;
  border: 1px solid var(--color-border-subtle);
  color: var(--color-text-secondary);
}

.portal-hero-sec:active {
  transform: scale(0.98);
  background-color: rgba(255, 255, 255, 0.05);
}

/* Quick Inquiry Card */
.portal-quick-card {
  background: var(--color-surface-card);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-md) var(--space-lg);
  box-shadow: var(--shadow-sm);
}

.portal-quick-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-primary);
  margin-bottom: var(--space-sm);
}

.portal-quick-header i {
  color: var(--color-text-secondary);
  font-size: 1.1rem;
}

.portal-quick-form {
  display: flex;
  gap: var(--space-sm);
}

.portal-quick-form input {
  flex: 1;
  background: #0F172A;
  border: 1px solid var(--color-border-medium);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--color-text-primary);
  font-family: var(--font-family-base);
  font-size: var(--font-size-sm);
  outline: none;
  transition: border-color var(--transition-fast);
}

.portal-quick-form input:focus {
  border-color: var(--color-border-focus);
}

.portal-quick-btn {
  background: var(--color-primary);
  border: 1px solid var(--color-border-medium);
  border-radius: var(--radius-sm);
  color: #FFFFFF;
  font-family: var(--font-family-base);
  font-weight: var(--font-weight-bold);
  font-size: var(--font-size-sm);
  padding: 0 var(--space-xl);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.portal-quick-btn:hover {
  background: var(--color-primary-hover);
}

/* Steps & Required Documents Cards */
.portal-steps-card,
.portal-docs-card {
  background: var(--color-surface-card);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-md) var(--space-lg);
  box-shadow: var(--shadow-sm);
}

.portal-section-title {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-primary);
  margin-bottom: var(--space-md);
}

.portal-section-title i {
  color: var(--color-text-secondary);
  font-size: 1.15rem;
}

.portal-steps-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.portal-step-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
}

.portal-step-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--color-text-primary);
  font-weight: 800;
  font-size: var(--font-size-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.portal-step-content h4 {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-primary);
  margin: 0 0 2px;
}

.portal-step-content p {
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
  margin: 0;
  line-height: 1.4;
}

.portal-docs-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.portal-docs-list li {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  line-height: 1.5;
}

.portal-docs-list li i {
  color: var(--color-status-info);
  font-size: 1.1rem;
  flex-shrink: 0;
}

/* WhatsApp Support */
.wa-contact-section {
  margin-top: var(--space-md);
  margin-bottom: var(--space-md);
}

.wa-contact-card {
  background: var(--color-surface-card);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}

.wa-card-icon {
  font-size: 1.6rem;
  color: #25D366;
  flex-shrink: 0;
}

.wa-card-info h4 {
  margin: 0 0 var(--space-2xs);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-primary);
}

.wa-card-info p {
  margin: 0;
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
}

.wa-card-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 var(--space-md);
  background-color: #25D366;
  color: #0F172A;
  border-radius: var(--radius-sm);
  font-weight: var(--font-weight-bold);
  font-size: var(--font-size-sm);
  text-decoration: none;
  flex-shrink: 0;
  transition: transform var(--transition-fast);
}

.wa-card-btn:active {
  transform: scale(0.96);
}

/* Bottom Navigation */
#appBottomNav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--bottom-nav-height) + var(--safe-area-bottom));
  padding-bottom: var(--safe-area-bottom);
  background-color: #0F172A;
  border-top: 1px solid #1E293B;
  display: flex;
  align-items: stretch;
  z-index: 1050;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.4);
}
body.admin-mode #appBottomNav {
  display: none !important;
}

.bnav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  background: none;
  border: none;
  color: #64748B;
  font-family: var(--font-family-base);
  font-size: var(--font-size-xs);
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  position: relative;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  transition: color var(--transition-fast);
}

.bnav-item i {
  font-size: 1.2rem;
  transition: transform var(--transition-fast), color var(--transition-fast);
}

.bnav-item:active {
  background-color: rgba(255, 255, 255, 0.03);
}

.bnav-item.active {
  color: #38BDF8;
}

.bnav-item.active i {
  transform: translateY(-2px);
}

.bnav-item.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 2px;
  background-color: #38BDF8;
  border-radius: var(--radius-xs) var(--radius-xs) 0 0;
}

.bnav-item.bnav-login.active {
  color: #38BDF8;
}

.bnav-item.bnav-login.active::after {
  background-color: #38BDF8;
}

/* Login Modal */
#loginModal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  overflow-y: auto;
  padding: var(--space-md);
  box-sizing: border-box;
}

#loginModal[style*="display: block"],
#loginModal[style*="display: flex"] {
  display: flex !important;
  align-items: center;
  justify-content: center;
}

.gov-login-overlay {
  position: fixed;
  inset: 0;
  z-index: 1;
}

.gov-login-card {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 420px;
  background: #1E293B;
  border: 1px solid #334155;
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  box-shadow: var(--shadow-lg);
  box-sizing: border-box;
  direction: rtl;
  text-align: right;
}

.gov-login-close-btn {
  position: absolute;
  top: 14px;
  left: 14px;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-pill);
  background: transparent;
  border: 1px solid #334155;
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.gov-login-close-btn:hover {
  background: #334155;
  color: #F8FAFC;
}

.gov-login-header {
  text-align: center;
  margin-bottom: 20px;
}

.gov-login-emblems {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}

.gov-emblem-wrap {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: #086948;
  border: 2px solid rgba(212, 175, 55, 0.7);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.1);
  padding: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.25s ease;
}

.gov-emblem-wrap:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(8, 105, 72, 0.4), 0 0 0 2px rgba(212, 175, 55, 0.85);
}

.gov-emblem-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  border-radius: 50%;
  display: block;
}

.gov-login-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--color-text-primary);
  margin: 0 0 4px;
}

.gov-login-subtitle {
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  margin: 0;
}

.gov-login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.gov-form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.gov-form-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-text-secondary);
}

.gov-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.gov-input-icon {
  position: absolute;
  right: 12px;
  color: var(--color-text-muted);
  font-size: 1rem;
  pointer-events: none;
}

.gov-input {
  width: 100%;
  height: 44px;
  padding: 0 38px 0 12px;
  background-color: #0F172A;
  border: 1px solid #334155;
  border-radius: var(--radius-sm);
  color: var(--color-text-primary);
  font-family: var(--font-family-base);
  font-size: 0.9rem;
  box-sizing: border-box;
  outline: none;
  transition: border-color var(--transition-fast);
}

.gov-input-wrap:focus-within .gov-input {
  border-color: #2563EB;
}

.gov-input::placeholder {
  color: var(--color-text-muted);
  font-size: 0.82rem;
}

.gov-pwd-toggle {
  position: absolute;
  left: 8px;
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  color: var(--color-text-muted);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gov-pwd-toggle:hover {
  color: var(--color-text-primary);
}

/* Lockout */
.gov-lockout-banner {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: #F87171;
  font-size: 0.8rem;
  text-align: center;
}

.gov-lockout-btn {
  margin-top: 6px;
  background: transparent;
  border: 1px solid rgba(239, 68, 68, 0.5);
  color: #FFFFFF;
  padding: 4px 10px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  font-family: var(--font-family-base);
  font-size: 0.76rem;
}

/* Captcha */
.gov-captcha-group {
  background: #0F172A;
  border: 1px solid #334155;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.gov-captcha-box {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 6px;
}

.gov-captcha-quest {
  padding: 8px 14px;
  background: #1E293B;
  border: 1px solid #334155;
  color: #F8FAFC;
  border-radius: var(--radius-xs);
  font-size: 1rem;
  font-weight: 700;
  direction: ltr;
}

.gov-captcha-input {
  flex: 1;
  height: 40px;
  text-align: center;
  font-size: 0.95rem;
}

/* Submit */
.gov-login-submit-btn {
  width: 100%;
  height: 46px;
  margin-top: 6px;
  background: #1D4ED8;
  border: 1px solid #2563EB;
  border-radius: var(--radius-sm);
  color: #FFFFFF;
  font-family: var(--font-family-base);
  font-weight: 700;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.gov-login-submit-btn:hover {
  background: #1E40AF;
}

.gov-login-submit-btn:active {
  background: #1E3A8A;
  transform: scale(0.99);
}

/* ══════════════════════════════════════════════════════
   UNIFIED MODAL COMPONENT SYSTEM
══════════════════════════════════════════════════════ */
.gov-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(11, 19, 32, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  overflow-y: auto;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.gov-modal[style*="display: block"],
.gov-modal[style*="display: flex"],
.gov-modal.open {
  display: flex !important;
}

.gov-modal-dialog {
  background: #131D2D;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 16px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  width: 100%;
  max-width: 520px;
  position: relative;
  overflow: hidden;
  margin: auto;
  animation: modalFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.gov-modal-dialog--lg { max-width: 720px; }
.gov-modal-dialog--sm { max-width: 420px; }

.gov-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
  background: rgba(255, 255, 255, 0.02);
}

.gov-modal-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  color: #F8FAFC;
  display: flex;
  align-items: center;
  gap: 8px;
}

.gov-modal-close {
  background: transparent;
  border: none;
  color: #94A3B8;
  font-size: 1.3rem;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: color 0.15s ease, background 0.15s ease;
}

.gov-modal-close:hover {
  color: #F8FAFC;
  background: rgba(255, 255, 255, 0.08);
}

.gov-modal-body {
  padding: 20px;
  max-height: 80vh;
  overflow-y: auto;
}

.gov-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid rgba(148, 163, 184, 0.12);
  background: rgba(0, 0, 0, 0.18);
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.96) translateY(-6px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

