/* ================================================================
   UPAYOG PRO — Component Styles (Ultimate Centered Modal Edition)
   Cards · Buttons · Forms · Tables · Modals · Badges · Toasts
================================================================ */

/* ═══════════════════════════════════════════════════
   UTILITY CLASSES
═══════════════════════════════════════════════════ */
.flex { display: flex; } .col { flex-direction: column; }
.ic { align-items: center; } .jb { justify-content: space-between; }
.je { justify-content: flex-end; } .jc { justify-content: center; }
.wrap { flex-wrap: wrap; }
.g4 { gap: 4px; } .g6 { gap: 6px; } .g8 { gap: 8px; } .g10 { gap: 10px; }
.g12 { gap: 12px; } .g14 { gap: 14px; } .g16 { gap: 16px; } .g20 { gap: 20px; }
.mt4 { margin-top: 4px; } .mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; }
.mt16 { margin-top: 16px; } .mb4 { margin-bottom: 4px; } .mb8 { margin-bottom: 8px; }
.mb12 { margin-bottom: 12px; } .mb16 { margin-bottom: 16px; } .mb20 { margin-bottom: 20px; }
.fw5 { font-weight: 500; } .fw6 { font-weight: 600; } .fw7 { font-weight: 700; } .fw8 { font-weight: 800; }
.text-sm { font-size: 13px; } .text-xs { font-size: 11.5px; }
.muted { color: var(--text3); } .mono { font-family: var(--mono); }
.cursor-pointer { cursor: pointer; } .text-center { text-align: center; } .text-right { text-align: right; }
.text-accent { color: var(--accent); }

/* ═══════════════════════════════════════════════════
   CARD (Premium UI)
═══════════════════════════════════════════════════ */
.card {
  background: #ffffff;
  border-radius: 16px;
  border: 1px solid rgba(0,0,0,0.04);
  box-shadow: 0 4px 20px -5px rgba(0,0,0,0.05);
  padding: 24px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.sec-head { font-size: 13px; font-weight: 700; color: var(--text2); letter-spacing: -.1px; margin-bottom: 14px; }

/* ═══════════════════════════════════════════════════
   BUTTONS
═══════════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; padding: 10px 16px; border-radius: var(--radius-sm);
  border: 1.5px solid transparent; font-family: var(--font); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: opacity .15s, transform .1s, box-shadow .15s;
  white-space: nowrap; user-select: none; text-decoration: none; min-height: 40px;
}
.btn:active { transform: scale(.97); } .btn:disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent-d); box-shadow: 0 2px 8px rgba(37,99,235,.28); }
.btn-ghost { background: var(--bg); color: var(--text2); border-color: var(--border); }
.btn-danger { background: var(--red-l); color: var(--red); border-color: var(--red-m); }
.btn-green { background: var(--green-l); color: var(--green); border-color: var(--green-m); }
.btn-amber { background: var(--amber-l); color: var(--amber); border-color: var(--amber-m); }
.btn-sm { padding: 8px 14px; font-size: 12.5px; min-height: 36px; }
.btn-xs { padding: 6px 11px; font-size: 12px; border-radius: 6px; min-height: 32px; }

/* ═══════════════════════════════════════════════════
   BADGES & INFO BOXES
═══════════════════════════════════════════════════ */
.badge { display: inline-flex; padding: 3px 9px; border-radius: 99px; font-size: 11px; font-weight: 600; }
.b-green { background: var(--green-l); color: var(--green); border: 1px solid var(--green-m); }
.b-red { background: var(--red-l); color: var(--red); border: 1px solid var(--red-m); }
.b-blue { background: var(--accent-l); color: var(--accent); border: 1px solid var(--accent-m); }
.info-box { padding: 10px 13px; border-radius: var(--radius-sm); border: 1px solid; line-height: 1.6; }
.ib-blue { background: var(--accent-l); border-color: var(--accent-m); color: var(--accent-d); }
.ib-green { background: var(--green-l); border-color: var(--green-m); color: #065f46; }

/* ═══════════════════════════════════════════════════
   FORMS & TABLES
═══════════════════════════════════════════════════ */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.fg { display: flex; flex-direction: column; gap: 5px; }
.fl { font-size: 12px; font-weight: 600; color: var(--text2); }
.fi {
  background: var(--bg); border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  padding: 11px 13px; font-size: 14px; font-family: var(--font); color: var(--text); width: 100%;
}
.fi:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.12); outline: none; }
.tbl-wrap { overflow-x: auto; border-radius: var(--radius-sm); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 10px 12px; text-align: left; font-size: 11px; font-weight: 700; color: var(--text3); text-transform: uppercase; background: var(--surface2); }
td { padding: 10px 12px; border-bottom: 1px solid var(--border); }

/* ═══════════════════════════════════════════════════
   MODAL ENGINE (BULLETPROOF CENTERED)
═══════════════════════════════════════════════════ */
#modalWrap {
  position: fixed !important; 
  inset: 0 !important; 
  z-index: 99999 !important;
  display: flex !important;
  align-items: center !important;     /* FORCES VERTICAL CENTER */
  justify-content: center !important; /* FORCES HORIZONTAL CENTER */
  padding: 20px !important;
  pointer-events: none; opacity: 0;
  transition: opacity 0.25s ease;
}
#modalWrap.active { pointer-events: auto !important; opacity: 1 !important; }

.modal-bg {
  position: absolute !important; inset: 0 !important;
  background: rgba(15, 23, 42, 0.6) !important;
  backdrop-filter: blur(5px) !important;
  z-index: 1 !important;
}

.modal {
  position: relative !important; z-index: 2 !important;
  background: var(--surface) !important;
  border-radius: 16px !important;
  width: 100% !important;
  max-width: 520px !important;
  height: auto !important;
  max-height: 85vh !important;
  display: flex !important; flex-direction: column !important;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.4) !important;
  margin: auto !important; /* OVERRIDES ANY EXTERNAL MARGINS */
  top: 0 !important; bottom: 0 !important; left: 0 !important; right: 0 !important; /* CANCELS DOCKING */
  transform: scale(0.95) !important;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
  overflow: hidden !important;
}
#modalWrap.active .modal { transform: scale(1) !important; }

.modal-head { padding: 16px 20px !important; border-bottom: 1px solid var(--border) !important; display: flex !important; align-items: center !important; justify-content: space-between !important; flex-shrink: 0 !important; }
.modal-title { font-size: 16px !important; font-weight: 700 !important; color: var(--text) !important; }
.modal-close { width: 32px; height: 32px; border-radius: 6px; border: 1px solid var(--border); background: var(--bg); cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.modal-body { padding: 20px !important; overflow-y: auto !important; flex: 1 1 auto !important; }
.modal-foot { padding: 16px 20px !important; border-top: 1px solid var(--border) !important; display: flex !important; justify-content: flex-end !important; gap: 10px !important; background: var(--surface2) !important; flex-shrink: 0 !important; }

.modal-lg { max-width: 760px !important; }
.modal-xl { max-width: 960px !important; }

/* ═══════════════════════════════════════════════════
   TOAST NOTIFICATIONS
═══════════════════════════════════════════════════ */
#toastWrap { position: fixed; bottom: 24px; right: 24px; z-index: 999999; display: flex; flex-direction: column-reverse; gap: 8px; pointer-events: none; }
.toast { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; max-width: 340px; border: 1.5px solid; background: var(--surface); opacity: 0; transition: opacity .25s, transform .25s; }
.toast.vis { opacity: 1; transform: none; }
.toast.success { background: var(--green-l); border-color: var(--green-m); color: #065f46; }
.toast.error { background: var(--red-l); border-color: var(--red-m); color: #991b1b; }

/* ═══════════════════════════════════════════════════
   📱 UPAYOG PRO - NATIVE MOBILE APP UPGRADE
═══════════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* 1. Kill Desktop Layouts (Hamburger and Sidebar are preserved for mobile drawer) */
  /* Aggressive hiding removed to restore hamburger functionality */
  
  /* 2. Lock App Dimensions (Prevents website bounce scrolling) */
  body, html { overflow: hidden; height: 100vh; width: 100vw; background: var(--bg); }
  #app.active { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
  #app:not(.active) { display: none !important; }
  
  /* 3. Main Content Scroll Area (Padding for Top/Bottom bars) */
  .main { flex: 1; overflow-y: auto; overflow-x: hidden; padding-bottom: 90px; padding-top: 70px; -webkit-overflow-scrolling: touch; }

  /* 4. Native Top App Bar */
  .topbar { position: fixed; top: 0; left: 0; right: 0; height: 60px; z-index: 100; background: rgba(255,255,255,0.95); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); box-shadow: 0 2px 10px rgba(0,0,0,0.05); padding: 0 16px; padding-top: env(safe-area-inset-top); display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); }
  .topbar-title { font-size: 18px; font-weight: 800; text-align: left; flex: 1; }
  
  /* Fix Topbar Buttons for Mobile */
  #topbar-actions { display: flex; flex-direction: row !important; width: auto !important; gap: 8px !important; margin-top: 0 !important; overflow-x: auto; }
  #topbar-actions .btn { min-height: 32px !important; border-radius: 8px !important; font-size: 12px !important; padding: 6px 12px !important; box-shadow: none !important; white-space: nowrap; }

  /* 5. Native Bottom Navigation */
  .mobile-only-nav { display: block !important; position: fixed; bottom: 0; left: 0; right: 0; background: rgba(255,255,255,0.95); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-top: 1px solid var(--border); z-index: 1000; padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -4px 20px rgba(0,0,0,0.05); }
  .bottom-nav-inner { display: flex; justify-content: space-around; align-items: center; height: 65px; padding: 0 5px; }
  .bnav-item { background: transparent; border: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--text3); width: 20%; cursor: pointer; transition: color 0.2s; outline: none; padding: 0; }
  .bnav-item.active { color: var(--accent); }
  .bnav-icon { font-size: 22px; transition: transform 0.2s; }
  .bnav-item.active .bnav-icon { transform: translateY(-2px) scale(1.15); }
  .bnav-text { font-size: 10px; font-weight: 700; }

  /* Center Floating Action Button (FAB) */
  .center-fab { position: relative; top: -15px; }
  .fab-inner { width: 54px; height: 54px; background: linear-gradient(135deg, var(--accent), #1e3a8a); color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 24px; box-shadow: 0 8px 20px rgba(37,99,235,0.4); border: 4px solid var(--bg); transition: transform 0.2s; }
  .center-fab:active .fab-inner { transform: scale(0.9); }

  /* 6. MODAL FIXES: Perfect edge-to-edge popups sliding from bottom */
  .modal { 
    position: absolute !important; bottom: 0 !important; left: 0 !important; right: 0 !important; top: auto !important; 
    transform: translateY(100%) !important; width: 100% !important; max-width: 100% !important; 
    border-radius: 24px 24px 0 0 !important; max-height: 90vh !important; margin: 0 !important;
    animation: slideUp 0.35s cubic-bezier(0.1, 0.9, 0.2, 1) forwards !important;
  }
  @keyframes slideUp { to { transform: translateY(0) !important; } }
  
  .modal-foot { flex-direction: column-reverse !important; }
  .modal-foot .btn { width: 100% !important; }
  #toastWrap { left: 16px; right: 16px; bottom: 80px; } /* Lift above bottom nav */

  /* 7. THE NATIVE FEEL: Kill tap delays and stop accidental zooming */
  * { touch-action: manipulation; }
  .btn, .sidebar-link, .badge, th, .sec-head { -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }

  /* 8. SWIPEABLE TABLES */
  .tbl-wrap { overflow-x: auto !important; -webkit-overflow-scrolling: touch; border-radius: 12px; border: 1px solid var(--border); }
  .tbl-wrap::-webkit-scrollbar { display: none; }
  table { width: 100%; display: table !important; min-width: 600px; }

  /* 9. CHUNKY TAP TARGETS & FORMS */
  .fi { min-height: 48px !important; border-radius: 10px; font-size: 16px !important; padding: 12px; }
  .form-grid { grid-template-columns: 1fr !important; gap: 14px !important; }
  .card { border-radius: 16px !important; padding: 16px !important; margin-bottom: 16px !important; }
}

/* Hide Mobile Nav on Desktop */
@media (min-width: 769px) {
  .mobile-only-nav { display: none !important; }
}