/* ==========================================================================
   NBFSA GOVERNMENT & RECRUITMENT WEB PORTAL
   ULTRA-RESPONSIVE STYLESHEET (css/responsive.css)
   Fully Optimized for Smart Phones, Foldables, Tablets, Laptops & Desktops
   Tested for Mobile-First, WCAG 2.1 AA, Touch-Friendly & Fluid Typography
   ========================================================================== */

/* --------------------------------------------------------------------------
   0. UNIVERSAL RESPONSIVE BASE & FLUID RULES
   -------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

img, svg, video, canvas, audio, iframe {
  max-width: 100%;
  height: auto;
  display: inline-block;
  vertical-align: middle;
}

/* Fluid Container Padding */
.container {
  width: 100%;
  max-width: 1280px;
  margin-left: auto;
  margin-right: auto;
  padding-left: clamp(1rem, 3.5vw, 1.75rem);
  padding-right: clamp(1rem, 3.5vw, 1.75rem);
}

/* Universal Table Wrapper for Mobile Scrolling */
.gov-table-wrapper,
.table-container,
.table-responsive,
.app-table-container {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 1.5rem;
  position: relative;
  border-radius: 8px;
}

/* Custom Smooth Touch Scrollbar for Tables */
.gov-table-wrapper::-webkit-scrollbar,
.table-container::-webkit-scrollbar,
.table-responsive::-webkit-scrollbar,
.app-table-container::-webkit-scrollbar {
  height: 6px;
}

.gov-table-wrapper::-webkit-scrollbar-thumb,
.table-container::-webkit-scrollbar-thumb,
.table-responsive::-webkit-scrollbar-thumb,
.app-table-container::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 9999px;
}

.gov-table-wrapper::-webkit-scrollbar-thumb:hover,
.table-container::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* --------------------------------------------------------------------------
   1. LARGE DESKTOP DISPLAYS (1200px and up)
   -------------------------------------------------------------------------- */
@media (min-width: 1200px) {
  .hero-heading {
    font-size: 2.5rem;
    line-height: 1.25;
  }

  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .services-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .footer-grid {
    grid-template-columns: 2fr 1fr 1fr 1.2fr;
  }
}

/* --------------------------------------------------------------------------
   2. LAPTOPS & DESKTOPS (993px to 1199px)
   -------------------------------------------------------------------------- */
@media (min-width: 993px) and (max-width: 1199px) {
  .header-branding {
    gap: 0.85rem;
  }

  .emblem-svg, .nbfsa-logo-img {
    width: 60px;
    height: 60px;
  }

  .board-title-hi {
    font-size: 1.15rem;
  }

  .board-title-en {
    font-size: 1.25rem;
  }

  .nav-link {
    padding: 0.75rem 0.55rem;
    font-size: 0.825rem;
  }

  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
  }

  .services-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
  }
}

/* --------------------------------------------------------------------------
   3. TABLETS & MEDIUM SCREENS (Under 992px)
   -------------------------------------------------------------------------- */
@media (max-width: 992px) {
  /* Top Accessibility Bar */
  .top-gov-bar {
    padding: 0.4rem 0;
  }

  .top-bar-flex {
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: space-between;
  }

  .gov-tools-right {
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-end;
  }

  /* Main Header Area */
  .main-header {
    padding: 0.75rem 0;
  }

  .header-inner {
    flex-wrap: wrap;
    gap: 1rem;
  }

  .header-branding {
    flex: 1 1 auto;
    min-width: 0;
    gap: 0.75rem;
  }

  .emblem-svg, .nbfsa-logo-img {
    width: 56px;
    height: 56px;
  }

  .header-actions-right {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
  }

  .header-search {
    flex: 1;
    width: auto;
    max-width: 100%;
  }

  /* Navigation Bar Mobile Layout */
  .nav-container {
    position: relative;
    padding-top: 0.35rem;
    padding-bottom: 0.35rem;
  }

  .mobile-menu-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: #0d47a1;
    color: #ffffff;
    border: 1.5px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    padding: 0.55rem 0.95rem;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
    margin: 0.25rem 0;
    width: 100%;
    justify-content: center;
  }

  .mobile-menu-toggle:hover,
  .mobile-menu-toggle:focus {
    background: #1565c0;
    border-color: #ff9933;
    outline: none;
  }

  .nav-menu {
    display: none;
    flex-direction: column;
    width: 100%;
    background: #04172a;
    border-top: 2px solid #ff9933;
    padding: 0.5rem 0 1rem 0;
    max-height: 80vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
  }

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

  .nav-item {
    width: 100%;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .nav-item:last-child {
    border-bottom: none;
  }

  .nav-link {
    width: 100%;
    padding: 0.85rem 1rem;
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #f1f5f9;
    min-height: 44px;
  }

  .nav-link:hover,
  .nav-link:focus,
  .nav-item.active .nav-link {
    background: rgba(255, 255, 255, 0.1);
    color: #ff9933;
  }

  .nav-link .dropdown-arrow {
    display: inline-block;
    transition: transform 0.25s ease;
  }

  .nav-item.dropdown-open > .nav-link .dropdown-arrow {
    transform: rotate(180deg);
    color: #ff9933;
  }

  .dropdown-menu {
    display: none;
    position: static;
    box-shadow: none;
    background: #020d18;
    border-radius: 0;
    border: none;
    border-left: 4px solid #ff9933;
    margin: 0;
    padding: 0.35rem 0;
    min-width: 100%;
  }

  .nav-item.dropdown-open .dropdown-menu {
    display: block;
  }

  .dropdown-item a {
    color: #cbd5e1;
    padding: 0.75rem 1rem 0.75rem 1.75rem;
    font-size: 0.875rem;
    display: block;
    min-height: 42px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
  }

  .dropdown-item a:hover {
    color: #ffffff;
    background: rgba(255, 153, 51, 0.15);
    padding-left: 2rem;
  }

  /* CTAs in mobile menu */
  .nav-cta-reg,
  .nav-cta-complaint {
    display: block;
    text-align: center;
    margin: 0.5rem 1rem !important;
    padding: 0.65rem 1rem !important;
    border-radius: 6px;
    min-height: 44px;
  }

  /* Content Grids */
  .hero-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
  }

  .services-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
  }

  .leadership-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
  }

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

  .page-layout-sidebar {
    grid-template-columns: 1fr;
    gap: 2rem;
  }
}

/* --------------------------------------------------------------------------
   4. SMARTPHONES & SMALL TABLETS (Under 768px)
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  /* Body typography & spacing */
  body {
    font-size: 0.9375rem;
    line-height: 1.55;
  }

  /* Top Bar */
  .gov-identity-left {
    width: 100%;
    font-size: 0.75rem;
    justify-content: flex-start;
  }

  .gov-tools-right {
    width: 100%;
    justify-content: flex-start;
    gap: 0.35rem;
  }

  .gov-tool-btn, .gov-tool-link {
    font-size: 0.75rem;
    padding: 3px 6px;
  }

  /* Branding */
  .header-branding {
    align-items: center;
  }

  .emblem-svg, .nbfsa-logo-img {
    width: 48px;
    height: 48px;
  }

  .ministry-title {
    font-size: 0.65rem;
    line-height: 1.2;
  }

  .board-title-hi {
    font-size: 0.95rem;
    line-height: 1.25;
  }

  .board-title-en {
    font-size: 1.05rem;
    line-height: 1.2;
  }

  .board-tagline {
    font-size: 0.65rem;
  }

  /* Emergency Helpline */
  .emergency-helpline-card {
    padding: 0.4rem 0.65rem;
    gap: 0.5rem;
  }

  .emergency-icon-wrap {
    width: 32px;
    height: 32px;
    font-size: 0.95rem;
  }

  .emergency-text small {
    font-size: 0.625rem;
  }

  .emergency-text strong {
    font-size: 0.875rem;
  }

  /* News Ticker */
  .ticker-inner {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .ticker-badge {
    padding: 3px 8px;
    font-size: 0.7rem;
  }

  .ticker-content-area {
    width: 100%;
    height: 22px;
  }

  /* Hero Section */
  .hero-section, .page-hero, .ngo-hero {
    padding: 2rem 0 1.5rem 0;
  }

  .hero-heading, .page-hero-title, .ngo-hero-title {
    font-size: clamp(1.45rem, 5.5vw, 1.85rem) !important;
    line-height: 1.25;
  }

  .hero-subtitle, .page-hero-desc, .ngo-hero-desc {
    font-size: 0.9rem;
    line-height: 1.5;
  }

  .hero-cta-group {
    flex-direction: column;
    width: 100%;
    gap: 0.75rem;
  }

  .hero-cta-group .btn {
    width: 100%;
    text-align: center;
    justify-content: center;
  }

  /* Single Column Layouts on Mobile */
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .stat-box {
    border-right: none;
    border-bottom: 1px solid var(--gov-border-light);
    padding-bottom: 0.85rem;
  }

  .stat-box:last-child {
    border-bottom: none;
    padding-bottom: 0;
  }

  .services-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .leadership-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }

  .features-grid, .info-cards-grid, .district-grid {
    grid-template-columns: 1fr !important;
  }

  .footer-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .footer-bottom-flex {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  /* Form Layouts */
  .form-grid-3,
  .form-grid-2 {
    grid-template-columns: 1fr !important;
    gap: 0.85rem;
  }

  .form-input,
  .form-select,
  .form-textarea {
    font-size: 16px !important; /* Prevents auto-zoom on iOS Safari */
    padding: 0.65rem 0.75rem;
  }

  .form-nav-buttons {
    flex-direction: column;
    width: 100%;
    gap: 0.75rem;
  }

  .form-nav-buttons .btn,
  .form-nav-buttons button {
    width: 100%;
    justify-content: center;
  }

  /* Recruitment Step Wizard on Mobile */
  .form-step-wizard {
    padding: 0 !important;
    margin-bottom: 1.5rem !important;
  }

  .wizard-step-title {
    display: none !important; /* Hide step names on small screens, keep step circles */
  }

  .wizard-step-circle {
    width: 36px !important;
    height: 36px !important;
    font-size: 0.85rem !important;
    margin-bottom: 0 !important;
  }

  .form-step-wizard::before,
  .step-progress-bar {
    top: 18px !important;
    left: 1.5rem !important;
    right: 1.5rem !important;
  }

  .gov-form-container {
    padding: 1.25rem 1rem !important;
    border-radius: 8px;
  }

  /* Official Application Slip / Admit Card */
  .official-slip-container {
    padding: 1rem !important;
    border-width: 1.5px !important;
  }

  .slip-watermark {
    font-size: 2.75rem !important;
  }

  .slip-header-grid {
    grid-template-columns: 1fr !important;
    text-align: center;
    gap: 0.75rem;
  }

  /* Table Filters & Toolbar */
  .table-filter-bar,
  .table-toolbar {
    flex-direction: column;
    align-items: stretch !important;
    gap: 0.75rem;
  }

  .filter-input,
  .table-search-input,
  .table-select-filter {
    width: 100% !important;
    min-width: 100% !important;
  }

  /* Tabbed Panels */
  .tab-button-group {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    gap: 0.35rem;
  }

  .tab-btn {
    flex-shrink: 0;
    padding: 0.6rem 0.85rem;
    font-size: 0.825rem;
    white-space: nowrap;
  }

  /* Admin Portal Responsive on Mobile */
  .admin-navbar {
    padding: 0.65rem 1rem;
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .admin-brand img {
    height: 36px;
    width: 36px;
  }

  .admin-title-wrap h1 {
    font-size: 0.95rem;
  }

  .admin-title-wrap small {
    font-size: 0.7rem;
  }

  .kpi-grid {
    grid-template-columns: 1fr !important;
    gap: 0.85rem !important;
  }

  .kpi-card {
    padding: 1rem;
  }

  .modal-content {
    max-width: 96vw !important;
    max-height: 94vh !important;
    margin: 0.5rem;
  }

  .modal-header {
    padding: 0.75rem 1rem;
  }

  .modal-body {
    padding: 1rem !important;
  }

  .login-container {
    margin: 30px auto !important;
    padding: 1.5rem 1.25rem !important;
    width: calc(100% - 2rem);
  }
}

/* --------------------------------------------------------------------------
   5. EXTRA SMALL PHONES & COMPACT SCREENS (Under 480px / 360px)
   -------------------------------------------------------------------------- */
@media (max-width: 480px) {
  .container {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  .top-gov-bar {
    font-size: 0.7rem;
  }

  .font-resizer-group {
    display: none; /* Keep screen clean on ultra-compact phones */
  }

  .header-actions-right {
    flex-direction: column;
    align-items: stretch;
  }

  .emergency-helpline-card {
    justify-content: center;
    width: 100%;
  }

  .header-search {
    width: 100%;
  }

  .search-input {
    font-size: 16px;
    padding: 0.55rem 0.65rem;
  }

  .search-submit-btn {
    padding: 0 0.85rem;
  }

  .btn {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
  }

  .card-header,
  .card-body,
  .card-footer {
    padding: 1rem;
  }

  /* Table styling on tiny screens */
  .gov-table th,
  .gov-table td,
  .admin-table th,
  .admin-table td {
    padding: 0.55rem 0.65rem;
    font-size: 0.775rem;
  }

  .badge-status {
    font-size: 0.6875rem;
    padding: 2px 6px;
  }

  /* Upload dropzones */
  .upload-box {
    padding: 1rem 0.75rem;
  }

  /* Sticky Application Bar for Mobile */
  .mobile-apply-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #0a2540;
    border-top: 2px solid #ff9933;
    padding: 0.65rem 1rem;
    z-index: 999;
    display: flex;
    gap: 0.5rem;
    box-shadow: 0 -4px 15px rgba(0,0,0,0.25);
  }

  .mobile-apply-bar a {
    flex: 1;
    text-align: center;
  }
}

/* --------------------------------------------------------------------------
   6. PRINT STYLESHEET (For Application Forms, Receipts & Admit Cards)
   -------------------------------------------------------------------------- */
@media print {
  .top-gov-bar,
  .main-header,
  .main-nav,
  .mobile-menu-toggle,
  .news-ticker-bar,
  .footer-main,
  .footer-bottom,
  .form-nav-buttons,
  .no-print,
  .btn-print,
  .table-filter-bar,
  .admin-navbar {
    display: none !important;
  }

  body {
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 11pt !important;
  }

  .container {
    max-width: 100% !important;
    padding: 0 !important;
  }

  .official-slip-container {
    border: 2px solid #000000 !important;
    box-shadow: none !important;
    padding: 1rem !important;
    page-break-inside: avoid;
  }

  .gov-table, .admin-table {
    border-collapse: collapse !important;
    width: 100% !important;
  }

  .gov-table th, .gov-table td,
  .admin-table th, .admin-table td {
    border: 1px solid #333333 !important;
  }
}
