/* ============================================================
   STAROVIA — COMPREHENSIVE MOBILE & CONTRAST FIX v2
   Deep scan fix: contrast, mobile nav, forms, admin, all pages
   ============================================================ */

/* ── 1. FORCE MOBILE-MENU-BTN VISIBLE ON SMALL SCREENS ────── */
@media (max-width: 768px) {
  .mobile-menu-btn {
    display: flex !important;
    flex-direction: column;
    gap: 5px;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    min-width: 40px;
    min-height: 40px;
    transition: background 0.2s;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
  }
  .mobile-menu-btn:hover { background: rgba(0,0,0,0.08); }
  .hamburger-line {
    display: block !important;
    width: 22px;
    height: 2.5px;
    background: var(--primary-color, #1a365d);
    border-radius: 2px;
    transition: all 0.3s ease;
    pointer-events: none;
  }
  /* Animated X */
  .mobile-menu-btn.open .hamburger-line:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
  }
  .mobile-menu-btn.open .hamburger-line:nth-child(2) {
    opacity: 0; transform: scaleX(0);
  }
  .mobile-menu-btn.open .hamburger-line:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
  }
  /* Hide desktop nav */
  header nav,
  header .user-menu { display: none !important; }
  .theme-toggle-btn { display: none !important; }
}

/* ── 2. MOBILE NAV DRAWER ──────────────────────────────────── */
.mobile-nav {
  position: fixed !important;
  top: 0 !important;
  left: -100% !important;
  width: min(320px, 85vw) !important;
  height: 100vh !important;
  background: #ffffff !important;
  z-index: 10000 !important;
  transition: left 0.35s cubic-bezier(0.4,0,0.2,1) !important;
  box-shadow: 6px 0 40px rgba(0,0,0,0.25) !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  display: flex !important;
  flex-direction: column !important;
  -webkit-overflow-scrolling: touch !important;
}
.mobile-nav.active { left: 0 !important; }

.mobile-nav .mobile-nav-header {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  padding: 20px !important;
  background: var(--primary-color, #1a365d) !important;
  color: #fff !important;
  min-height: 70px;
  flex-shrink: 0;
}
.mobile-nav .mobile-nav-header .nav-logo,
.mobile-nav .mobile-nav-header span.nav-logo {
  color: #fff !important;
  font-size: 1.1rem !important;
  font-weight: 800 !important;
  letter-spacing: 1px;
}
.mobile-nav .mobile-nav-header img {
  height: 36px !important;
  filter: brightness(10) !important;
  max-width: 140px;
  object-fit: contain;
}
.mobile-nav .mobile-nav-close {
  background: rgba(255,255,255,0.2) !important;
  border: none !important;
  color: #fff !important;
  width: 36px !important;
  height: 36px !important;
  border-radius: 50% !important;
  font-size: 20px !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex-shrink: 0;
  transition: background 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.mobile-nav .mobile-nav-close:hover {
  background: rgba(255,255,255,0.35) !important;
}
.mobile-nav .mobile-nav-menu {
  flex: 1 !important;
  padding: 8px 0 !important;
}
.mobile-nav .mobile-nav-menu a {
  display: flex !important;
  align-items: center !important;
  gap: 14px !important;
  padding: 16px 24px !important;
  color: #1a202c !important;
  font-size: 0.95rem !important;
  font-weight: 500 !important;
  text-decoration: none !important;
  border-bottom: 1px solid #f0f0f0 !important;
  transition: all 0.2s !important;
  background: transparent !important;
  -webkit-tap-highlight-color: transparent;
}
.mobile-nav .mobile-nav-menu a i {
  width: 20px !important;
  color: #e53e3e !important;
  font-size: 0.9rem !important;
}
.mobile-nav .mobile-nav-menu a:hover,
.mobile-nav .mobile-nav-menu a.active {
  background: #fef2f2 !important;
  color: #e53e3e !important;
  padding-left: 30px !important;
}
.mobile-nav .mobile-nav-footer {
  padding: 20px !important;
  border-top: 1px solid #f0f0f0 !important;
  flex-shrink: 0;
}
.mobile-nav .mobile-apply-btn {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 8px !important;
  padding: 14px !important;
  background: #e53e3e !important;
  color: #fff !important;
  border-radius: 10px !important;
  font-weight: 600 !important;
  font-size: 0.95rem !important;
  text-decoration: none !important;
  transition: background 0.2s !important;
}
.mobile-nav .mobile-apply-btn:hover {
  background: #c53030 !important;
  padding-left: 14px !important;
}

/* Overlay */
.mobile-nav-overlay {
  position: fixed !important;
  top: 0 !important; left: 0 !important;
  right: 0 !important; bottom: 0 !important;
  background: rgba(0,0,0,0.55) !important;
  z-index: 9999 !important;
  opacity: 0 !important;
  pointer-events: none !important;
  transition: opacity 0.3s ease !important;
  backdrop-filter: blur(3px) !important;
  -webkit-backdrop-filter: blur(3px) !important;
}
.mobile-nav-overlay.active {
  opacity: 1 !important;
  pointer-events: all !important;
}

/* ── 3. TEXT CONTRAST — FORM INPUTS ─────────────────────────── */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
input[type="date"],
input[type="number"],
input[type="search"],
input[type="url"],
select,
textarea,
.form-group input,
.form-group select,
.form-group textarea,
.filter-group input,
.filter-group select,
.filter-input,
.filter-select,
.form-control {
  color: #1a202c !important;
  background-color: #ffffff !important;
  border-color: #cbd5e0 !important;
  -webkit-text-fill-color: #1a202c !important;
}
input::placeholder, textarea::placeholder {
  color: #718096 !important;
  -webkit-text-fill-color: #718096 !important;
  opacity: 1 !important;
}
input:focus, select:focus, textarea:focus {
  color: #1a202c !important;
  -webkit-text-fill-color: #1a202c !important;
  background-color: #ffffff !important;
}

/* Dark mode inputs */
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="email"],
[data-theme="dark"] input[type="tel"],
[data-theme="dark"] input[type="password"],
[data-theme="dark"] input[type="date"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] input[type="search"],
[data-theme="dark"] select,
[data-theme="dark"] textarea,
[data-theme="dark"] .form-group input,
[data-theme="dark"] .form-group select,
[data-theme="dark"] .form-group textarea,
[data-theme="dark"] .filter-input,
[data-theme="dark"] .filter-select {
  color: #f0f2f8 !important;
  background-color: #1e2330 !important;
  border-color: rgba(255,255,255,0.18) !important;
  -webkit-text-fill-color: #f0f2f8 !important;
}
[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder {
  color: #6b7280 !important;
  -webkit-text-fill-color: #6b7280 !important;
  opacity: 1 !important;
}
[data-theme="dark"] select option {
  background: #1e2330 !important;
  color: #f0f2f8 !important;
}

/* ── 4. SEARCH INPUTS CONTRAST FIX ─────────────────────────── */
.search-input-group input,
.search-input-group select {
  color: #1a202c !important;
  -webkit-text-fill-color: #1a202c !important;
}
.advanced-search .search-input-group input,
.advanced-search .search-input-group select {
  background: #f8fafc !important;
  color: #1a202c !important;
  -webkit-text-fill-color: #1a202c !important;
}
.advanced-search .search-input-group input::placeholder {
  color: #718096 !important;
  -webkit-text-fill-color: #718096 !important;
}

/* ── 5. USER MENU (support/my-applications nav) ─────────────── */
.user-menu {
  display: flex;
  align-items: center;
  gap: 20px;
}
.user-menu a {
  color: rgba(255,255,255,0.85) !important;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9rem;
  transition: color 0.2s;
}
.user-menu a:hover { color: #ffffff !important; }
@media (max-width: 768px) {
  .user-menu { display: none !important; }
}

/* ── 6. FLUID TYPOGRAPHY ────────────────────────────────────── */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
.hero h1 { font-size: clamp(1.75rem, 5vw, 3.5rem) !important; line-height: 1.2; }
.section-title h2 { font-size: clamp(1.5rem, 4vw, 2.5rem) !important; }
.search-hero h1 { font-size: clamp(1.5rem, 4vw, 2.4rem) !important; }
.page-header h1 { font-size: clamp(1.6rem, 4vw, 3rem) !important; }

/* ── 7. HERO ────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .hero { min-height: 80vh; padding-top: 80px; padding-bottom: 40px; }
  .hero p { font-size: clamp(0.95rem, 3vw, 1.2rem); }
  .hero-buttons { flex-direction: column !important; align-items: center !important; gap: 14px !important; }
  .hero-buttons .btn { width: 100% !important; max-width: 300px !important; justify-content: center !important; }
}

/* ── 8. SEARCH FORM RESPONSIVE ─────────────────────────────── */
@media (max-width: 992px) {
  .search-form-grid { grid-template-columns: 1fr 1fr !important; }
  .search-form-grid .search-btn { grid-column: span 2 !important; }
}
@media (max-width: 576px) {
  .search-form-grid { grid-template-columns: 1fr !important; padding: 12px !important; }
  .search-form-grid .search-btn { grid-column: 1 !important; width: 100% !important; justify-content: center !important; }
}

/* ── 9. CONTENT GRIDS ───────────────────────────────────────── */
@media (max-width: 768px) {
  .jobs-grid { grid-template-columns: 1fr !important; gap: 16px !important; }
  .categories-grid { grid-template-columns: repeat(2,1fr) !important; gap: 12px !important; }
  .why-choose-grid { grid-template-columns: repeat(2,1fr) !important; gap: 16px !important; }
  .footer-grid { grid-template-columns: repeat(2,1fr) !important; gap: 24px !important; }
  .stats-grid { grid-template-columns: repeat(2,1fr) !important; gap: 16px !important; }
}
@media (max-width: 480px) {
  .categories-grid,
  .why-choose-grid { grid-template-columns: 1fr !important; }
  .footer-grid { grid-template-columns: 1fr !important; }
  .container { padding: 0 16px !important; }
}

/* ── 10. APPLY FORM ─────────────────────────────────────────── */
@media (max-width: 992px) {
  .apply-container { grid-template-columns: 1fr !important; gap: 20px !important; }
  .apply-info { position: static !important; }
}
@media (max-width: 768px) {
  .form-grid { grid-template-columns: 1fr !important; gap: 16px !important; }
  .form-group.full-width { grid-column: span 1 !important; }
  .apply-form { padding: 24px !important; }
  .form-group input,
  .form-group select,
  .form-group textarea { font-size: 16px !important; }
}

/* ── 11. LOGIN PAGE ─────────────────────────────────────────── */
@media (max-width: 576px) {
  .login-box, .auth-card, .login-card {
    padding: 28px 20px !important;
    margin: 10px !important;
    border-radius: 14px !important;
    max-width: calc(100vw - 20px) !important;
  }
}

/* ── 12. TABLE RESPONSIVE ───────────────────────────────────── */
.applications-table,
.table-wrap { overflow-x: auto !important; -webkit-overflow-scrolling: touch !important; }
.applications-table table,
.table-wrap table { min-width: 600px; }
@media (max-width: 768px) {
  .table-filters { flex-direction: column !important; padding: 14px !important; gap: 10px !important; }
  .table-filters input, .table-filters select { width: 100% !important; font-size: 16px !important; }
}

/* ── 13. PAGINATION ─────────────────────────────────────────── */
@media (max-width: 576px) {
  .pagination { flex-wrap: wrap !important; gap: 8px !important; }
  .pagination a { padding: 8px 12px !important; font-size: 0.85rem !important; }
}

/* ── 14. PAGE HEADER ────────────────────────────────────────── */
@media (max-width: 768px) {
  .page-header { padding: 110px 0 50px !important; }
}

/* ── 15. TOAST MOBILE ───────────────────────────────────────── */
@media (max-width: 576px) {
  .toast-container { top: auto !important; bottom: 20px !important; right: 12px !important; left: 12px !important; }
  .toast { min-width: auto !important; max-width: 100% !important; }
}

/* ── 16. MODAL MOBILE ───────────────────────────────────────── */
@media (max-width: 576px) {
  .modal-overlay { align-items: flex-end !important; padding: 0 !important; }
  .modal { width: 100% !important; max-width: 100% !important; border-radius: 20px 20px 0 0 !important; max-height: 90vh !important; }
  .modal-footer { flex-direction: column-reverse !important; gap: 10px !important; }
  .modal-footer .btn { width: 100% !important; justify-content: center !important; }
}

/* ── 17. SECTION SPACING ────────────────────────────────────── */
@media (max-width: 768px) {
  .categories, .why-choose, .cta, .jobs-section, .apply-section { padding: 50px 0 !important; }
  .section-title { margin-bottom: 30px !important; }
  footer { padding: 40px 0 16px !important; }
}

/* ── 18. SCROLL TO TOP ──────────────────────────────────────── */
@media (max-width: 576px) {
  .scroll-top { bottom: 16px !important; right: 16px !important; width: 44px !important; height: 44px !important; }
}

/* ── 19. MIN TAP TARGETS ────────────────────────────────────── */
button, .btn, a.btn, .action-btn, .apply-btn, .submit-btn, .status-btn {
  min-height: 44px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* ── 20. SAFE OVERFLOW ──────────────────────────────────────── */
body { overflow-x: hidden; }

/* ===========================================================
   ADMIN PANEL FIXES
   =========================================================== */

/* ── 21. ADMIN SIDEBAR TOGGLE BTN ───────────────────────────── */
.sidebar-toggle-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  color: var(--text-dark, #111);
  font-size: 20px;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  margin-right: 8px;
  transition: background 0.2s;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}
.sidebar-toggle-btn:hover { background: var(--bg-raised, #f0f4f8); }
@media (max-width: 900px) {
  .sidebar-toggle-btn { display: flex !important; }
}

/* ── 22. ADMIN SIDEBAR ICON-ONLY (medium) ────────────────────── */
@media (max-width: 900px) and (min-width: 481px) {
  .sidebar { width: 68px !important; overflow: hidden !important; }
  .sidebar-logo h2,
  .sidebar-logo .logo-sub,
  .sidebar-nav ul li a > span:not(.nav-icon),
  .nav-section-label,
  .nav-badge,
  .sidebar-footer .user-info { display: none !important; }
  .sidebar-logo { padding: 16px 10px !important; }
  .sidebar-logo .logo-mark { justify-content: center !important; }
  .sidebar-nav ul li a { justify-content: center !important; padding: 10px 8px !important; }
  .sidebar-nav ul li a .nav-icon { width: 36px !important; height: 36px !important; }
  .main-content { margin-left: 68px !important; }
}

/* ── 23. ADMIN SIDEBAR DRAWER (small mobile) ─────────────────── */
@media (max-width: 480px) {
  .sidebar {
    display: flex !important;
    width: 270px !important;
    transform: translateX(-270px) !important;
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1) !important;
    overflow-y: auto !important; overflow-x: hidden !important;
    z-index: 9999 !important;
  }
  .sidebar.mobile-open {
    transform: translateX(0) !important;
    box-shadow: 4px 0 30px rgba(0,0,0,0.4) !important;
  }
  /* Always show full text labels when drawer is open */
  .sidebar .sidebar-logo h2,
  .sidebar .sidebar-logo .logo-sub,
  .sidebar .sidebar-nav ul li a > span,
  .sidebar .nav-section-label,
  .sidebar .sidebar-footer .user-info { display: unset !important; }
  .sidebar .sidebar-nav ul li a {
    justify-content: flex-start !important;
    padding: 10px 16px !important;
  }
  .main-content { margin-left: 0 !important; }
  .sidebar-overlay {
    position: fixed !important; inset: 0 !important;
    background: rgba(0,0,0,0.55) !important;
    z-index: 9998 !important;
    opacity: 0 !important; pointer-events: none !important;
    transition: opacity 0.3s !important;
    backdrop-filter: blur(2px) !important;
    -webkit-backdrop-filter: blur(2px) !important;
  }
  .sidebar-overlay.active { opacity: 1 !important; pointer-events: all !important; }
}

/* ── 24. ADMIN TOPBAR ────────────────────────────────────────── */
@media (max-width: 768px) {
  .topbar { padding: 0 14px !important; }
  .topbar-left { display: flex !important; align-items: center !important; gap: 0 !important; }
  .topbar-left h1 { font-size: 0.95rem !important; }
  .topbar-left .breadcrumb { display: none !important; }
}
@media (max-width: 480px) {
  .topbar { padding: 0 10px !important; }
  .topbar-left h1 { font-size: 0.88rem !important; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar-right .btn span, .topbar-right .btn-text { display: none; }
  .topbar-right .btn { padding: 0 10px !important; min-width: 36px; }
  .page-body { padding: 12px !important; }
}

/* ── 25. ADMIN STATS ─────────────────────────────────────────── */
@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2,1fr) !important; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: repeat(2,1fr) !important; gap: 12px !important; }
  .stat-card { padding: 16px !important; }
  .stat-number { font-size: 1.8rem !important; }
}

/* ── 26. ADMIN TABLE ─────────────────────────────────────────── */
@media (max-width: 900px) {
  .card { overflow-x: auto !important; -webkit-overflow-scrolling: touch !important; }
  .card table { min-width: 580px !important; }
  table th { white-space: nowrap; }
}
@media (max-width: 576px) {
  .filters-row { flex-direction: column !important; padding: 12px !important; gap: 10px !important; }
  .filter-input, .filter-select { width: 100% !important; font-size: 16px !important; min-width: auto !important; }
}

/* ── 27. ADMIN FORMS ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .form-grid { grid-template-columns: 1fr !important; }
}

/* ── 28. ADMIN SETTINGS ──────────────────────────────────────── */
@media (max-width: 900px) { .settings-cards-grid { grid-template-columns: repeat(2,1fr) !important; } }
@media (max-width: 576px) {
  .settings-cards-grid { grid-template-columns: 1fr !important; }
  .settings-tabs { flex-direction: column !important; }
}

/* ── 29. ADMIN VIEW APPLICATION ──────────────────────────────── */
@media (max-width: 768px) {
  .application-detail { padding: 20px !important; }
  .detail-grid { grid-template-columns: 1fr !important; }
  .status-actions { flex-direction: column !important; gap: 12px !important; }
  .status-btn { width: 100% !important; text-align: center !important; }
  .file-downloads { flex-direction: column !important; gap: 10px !important; }
}
@media (max-width: 576px) {
  .card-header { flex-direction: column !important; align-items: flex-start !important; gap: 12px !important; }
}

/* ── 30. ADMIN INPUT CONTRAST ────────────────────────────────── */
.admin-wrapper input[type="text"],
.admin-wrapper input[type="email"],
.admin-wrapper input[type="search"],
.admin-wrapper input[type="password"],
.admin-wrapper input[type="number"],
.admin-wrapper select,
.admin-wrapper textarea {
  color: #111827 !important;
  background: #ffffff !important;
  -webkit-text-fill-color: #111827 !important;
}
.admin-wrapper input::placeholder,
.admin-wrapper textarea::placeholder {
  color: #9ca3af !important;
  -webkit-text-fill-color: #9ca3af !important;
  opacity: 1 !important;
}

/* ── 31. DARK MODE MOBILE NAV ─────────────────────────────────── */
[data-theme="dark"] .mobile-nav { background: #111318 !important; }
[data-theme="dark"] .mobile-nav .mobile-nav-menu a {
  color: rgba(255,255,255,0.85) !important;
  border-bottom-color: rgba(255,255,255,0.06) !important;
  background: transparent !important;
}
[data-theme="dark"] .mobile-nav .mobile-nav-menu a:hover {
  background: rgba(255,255,255,0.06) !important;
  color: #fff !important;
  padding-left: 30px !important;
}
[data-theme="dark"] .mobile-nav .mobile-nav-footer { border-top-color: rgba(255,255,255,0.08) !important; }

/* ── 32. LANDSCAPE MODE ──────────────────────────────────────── */
@media (max-height: 500px) and (orientation: landscape) {
  .hero { min-height: auto !important; padding: 80px 0 40px !important; }
  .mobile-nav { overflow-y: auto !important; }
}

/* ── 33. SAFE AREA SUPPORT (NOTCHED PHONES) ──────────────────── */
@supports (padding: env(safe-area-inset-left)) {
  .mobile-nav { padding-bottom: env(safe-area-inset-bottom); }
}

/* ── 34. ACCESSIBILITY ────────────────────────────────────────── */
*:focus-visible {
  outline: 3px solid var(--primary-color, #1a365d) !important;
  outline-offset: 2px !important;
}