/* ==========================================================================
   RECON ERP — Mobile & Tablet Responsive Transformation
   Additive-only stylesheet. Desktop markup is completely unchanged at >= 1024px.
   Mobile (< 768px) enhancements only. No sidebar/main-wrapper overrides here —
   the existing CSS in index.html (@media max-width: 991.98px) already handles
   the mobile sidebar correctly.
   ========================================================================== */

:root {
  --recon-break-mobile: 767.98px;
  --recon-touch-min: 44px;
  --recon-touch-android: 48px;
  --recon-z-bottom-nav: 1040;
  --recon-z-mobile-header: 1030;
  --recon-z-bottom-sheet: 1050;
}

/* Safe area utilities (safe everywhere, no media query) */
.recon-safe-top { padding-top: max(12px, env(safe-area-inset-top)); }
.recon-safe-bottom { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
.recon-safe-both { padding-top: max(12px, env(safe-area-inset-top)); padding-bottom: max(12px, env(safe-area-inset-bottom)); }

/* Mobile Header (hidden by default, shown on mobile via media query) */
.recon-mobile-header {
  position: sticky; top: 0; z-index: var(--recon-z-mobile-header);
  display: none; align-items: center; justify-content: space-between;
  height: 56px; padding: 0 max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
  background: #212529; color: #fff;
}
.recon-mobile-header .recon-hamburger { background: none; border: none; color: #fff; font-size: 1.5rem; padding: 6px; line-height: 1; cursor: pointer; }
.recon-mobile-header .recon-module-title { flex: 1; text-align: center; font-size: 0.95rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 8px; color: #fff; }
.recon-mobile-header .recon-actions { display: flex; align-items: center; gap: 6px; }
.recon-mobile-header .recon-btn-icon { background: rgba(255,255,255,0.1); border: none; color: #fff; width: 36px; height: 36px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 1.1rem; cursor: pointer; }
.recon-mobile-header .recon-btn-icon:hover { background: rgba(255,255,255,0.2); }
.recon-mobile-header .recon-site-badge { font-size: 0.7rem; padding: 2px 8px; border-radius: 10px; background: rgba(255,255,255,0.15); color: #fff; border: 1px solid rgba(255,255,255,0.3); }

/* Bottom Navigation Bar (hidden by default, shown on mobile) */
.recon-bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0;
  z-index: var(--recon-z-bottom-nav); display: none;
  height: max(68px, env(safe-area-inset-bottom) + 56px);
  align-items: center; justify-content: space-around;
  background: #212529; border-top: 1px solid rgba(255,255,255,0.1);
  padding-bottom: max(8px, env(safe-area-inset-bottom)); padding-top: 6px;
}
.recon-bottom-nav .recon-nav-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: auto; flex: 1; color: rgba(255,255,255,0.5); text-decoration: none;
  font-size: 0.65rem; font-weight: 600; min-height: var(--recon-touch-android); min-width: var(--recon-touch-android);
  padding: 4px 6px;
}
.recon-bottom-nav .recon-nav-item.active, .recon-bottom-nav .recon-nav-item[data-active="true"] { color: #0d6efd; }
.recon-bottom-nav .recon-nav-item i { font-size: 1.25rem; margin-bottom: 2px; line-height: 1; }
.recon-bottom-nav .recon-nav-item span { line-height: 1.1; }

/* Touch target utility class */
.recon-touch { min-height: var(--recon-touch-min); min-width: var(--recon-touch-min); }

/* Bottom Sheet (hidden by default) */
.recon-bottom-sheet {
  position: fixed; left: 0; right: 0; bottom: 0;
  z-index: var(--recon-z-bottom-sheet); display: none;
  height: 85dvh; max-height: 85dvh; background: #fff;
  border-top: 1px solid #dee2e6; border-top-left-radius: 1rem; border-top-right-radius: 1rem;
  box-shadow: 0 -8px 24px rgba(0,0,0,0.15); overflow-y: auto;
  padding: 1rem max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}
.recon-bottom-sheet.open { display: block; }
.recon-bottom-sheet .recon-sheet-handle { width: 36px; height: 4px; background: #ced4da; border-radius: 2px; margin: 0 auto 1rem auto; display: block; }
.recon-bottom-sheet .recon-sheet-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; padding-bottom: 0.75rem; border-bottom: 1px solid #f1f3f5; }
.recon-bottom-sheet .recon-sheet-close { background: none; border: none; font-size: 1.5rem; color: #6c757d; cursor: pointer; line-height: 1; min-height: 44px; min-width: 44px; padding: 0; }

/* ==========================================================================
   MOBILE ONLY (< 768px) — additive enhancements, no sidebar/main-wrapper overrides
   ========================================================================== */
@media (max-width: 767.98px) {

  /* Show mobile header */
  .recon-mobile-header { display: flex; }

  /* Show bottom navigation */
  .recon-bottom-nav { display: flex; }

  /* Touch-friendly form controls (prevents iOS zoom on focus) */
  .form-control, .form-select, .btn, input, select, textarea, button {
    min-height: 44px !important; font-size: 16px !important;
  }
  .form-select { padding-right: 2.5rem !important; }
  .form-label { margin-bottom: 0.35rem !important; font-size: 0.85rem !important; font-weight: 600 !important; }
  .input-group > .form-control, .input-group > .form-select { min-height: 48px; }

  /* Stack multi-column form rows vertically on mobile */
  .row.mobile-stack > *, .row.g-3.mobile-stack > *, .row.g-2.mobile-stack > * {
    flex: 0 0 100% !important; max-width: 100% !important;
  }
  .btn.mobile-full { width: 100%; }

  /* Table → Responsive Card Pattern */
  .recon-responsive-table { width: 100%; border-collapse: separate; border-spacing: 0 0.75rem; }
  .recon-responsive-table thead { display: none; }
  .recon-responsive-table tbody, .recon-responsive-table tr, .recon-responsive-table td {
    display: block; width: 100%;
  }
  .recon-responsive-table tr {
    background: #fff; border: 1px solid #dee2e6; border-radius: 0.75rem;
    margin-bottom: 0.75rem; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  }
  .recon-responsive-table td {
    padding: 0.6rem 0.9rem; border: none; position: relative; text-align: left;
  }
  .recon-responsive-table td::before {
    content: attr(data-label); position: absolute; top: 0.4rem; left: 0.9rem;
    width: 45%; font-size: 0.7rem; font-weight: 700; color: #6c757d;
    text-transform: uppercase; letter-spacing: 0.03em; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis; padding-right: 0.5rem;
  }
  .recon-responsive-table td:first-child::before { content: ""; width: 0; }
  .recon-responsive-table .recon-card-actions {
    margin-top: 0.5rem; padding-top: 0.5rem; border-top: 1px solid #f1f3f5;
    display: flex; gap: 0.4rem;
  }
  .recon-responsive-table .recon-card-actions .btn {
    flex: 1; min-height: 40px; font-size: 0.8rem; padding: 0.25rem 0.5rem;
  }

  /* Full-viewport modals on mobile with sticky action bar */
  .modal-dialog.modal-full-mobile { margin: 0; width: 100vw; height: 100dvh; max-width: 100vw; }
  .modal-dialog.modal-full-mobile .modal-content {
    border-radius: 0; height: 100dvh; display: flex; flex-direction: column;
  }
  .modal-dialog.modal-full-mobile .modal-header {
    position: sticky; top: 0; z-index: 1; background: #fff; border-bottom: 1px solid #dee2e6;
  }
  .modal-dialog.modal-full-mobile .modal-body { overflow-y: auto; flex: 1; padding: 1rem; }
  .modal-dialog.modal-full-mobile .modal-footer {
    position: sticky; bottom: 0; z-index: 1; background: #fff;
    border-top: 1px solid #dee2e6; padding: 1rem;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.08);
  }

  /* Prevent horizontal scroll */
  .card { overflow-x: hidden; }
  body { overflow-x: hidden; max-width: 100vw; }

  /* Virtual keyboard input mode hints */
  input[inputmode="decimal"]::-webkit-input-placeholder,
  input[inputmode="numeric"]::-webkit-input-placeholder,
  input[inputmode="email"]::-webkit-input-placeholder,
  input[inputmode="tel"]::-webkit-input-placeholder { opacity: 0.6; }
}

/* ==========================================================================
   DESKTOP & TABLET (>= 768px) — standard layout, full table width
   ========================================================================== */
@media (min-width: 768px) {
  .recon-mobile-header, .recon-bottom-nav, .recon-bottom-sheet { display: none !important; }

  /* Restore standard table rendering for recon-responsive-table */
  table.recon-responsive-table {
    display: table !important;
    width: 100% !important;
    border-collapse: collapse !important;
  }
  table.recon-responsive-table thead {
    display: table-header-group !important;
  }
  table.recon-responsive-table tbody {
    display: table-row-group !important;
    width: 100% !important;
  }
  table.recon-responsive-table tr {
    display: table-row !important;
    width: auto !important;
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    margin-bottom: 0 !important;
    box-shadow: none !important;
  }
  table.recon-responsive-table th,
  table.recon-responsive-table td {
    display: table-cell !important;
    width: auto !important;
    text-align: inherit !important;
    position: static !important;
  }
  table.recon-responsive-table td::before {
    content: none !important;
    display: none !important;
  }
}

/* End of responsive.css */