/* ============================================
   C-SKel SC Portal — Mobile-First Custom CSS
   Enhanced for Smartphones, Tablets & Desktop
   ============================================ */

/* ---- Base & Safe Areas ---- */
:root {
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

body {
  font-family: 'Plus Jakarta Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* ---- Bottom Mobile Nav Bar ---- */
#mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 999;
  display: none;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
  padding-bottom: max(6px, env(safe-area-inset-bottom, 0px));
}

#mobile-bottom-nav a,
#mobile-bottom-nav button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 4px 6px;
  font-size: 10px;
  font-weight: 700;
  color: #64748b;
  text-decoration: none;
  background: transparent;
  border: none;
  cursor: pointer;
  letter-spacing: 0.02em;
  min-width: 0;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s, background 0.15s;
  border-radius: 12px 12px 0 0;
}

#mobile-bottom-nav a[data-active="true"] {
  color: #2563eb;
  background: #eff6ff;
}

#mobile-bottom-nav .nav-icon {
  font-size: 22px;
  line-height: 1;
}

/* Show bottom nav on small screens only */
@media (max-width: 767px) {
  #mobile-bottom-nav {
    display: flex;
  }
  /* Extra bottom padding so content isn't covered by bottom nav */
  main {
    padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  }
  footer {
    padding-bottom: calc(84px + 16px + env(safe-area-inset-bottom, 0px));
  }
}

/* ---- Mobile Screen Specific Enhancements ---- */
@media (max-width: 640px) {
  /* Prevent side-scrolling container overflows */
  .max-w-4xl, .max-w-5xl, .max-w-6xl, .max-w-7xl {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  /* Compact paper on mobile phone screens */
  .paper {
    padding: 16px 12px !important;
    border-radius: 14px !important;
    box-shadow: 0 2px 12px rgba(0,0,0,0.05) !important;
  }
  .paper-opr {
    padding: 14px 10px !important;
  }

  /* Touch buttons minimum comfortable tap target */
  button, a.btn, input[type="submit"], input[type="button"] {
    min-height: 40px;
  }

  /* Score buttons — touch friendly (40px x 40px) */
  .crit-btn,
  [class*="crit-btn-"] {
    width: 40px !important;
    height: 40px !important;
    font-size: 15px !important;
    font-weight: 800 !important;
    touch-action: manipulation;
  }

  /* Form inputs text size: 16px prevents mobile browser auto-zooming on focus */
  input[type="text"],
  input[type="password"],
  input[type="email"],
  input[type="date"],
  input[type="time"],
  select,
  textarea {
    font-size: 15px !important;
  }

  /* Modals — responsive behavior for mobile keyboards */
  .modal-dialog,
  #addModal > div:last-child,
  #editModal > div:last-child,
  #delUserModal > div:last-child,
  #deleteModal > div:last-child,
  #cropModal > div:last-child {
    max-height: 90vh;
    overflow-y: auto;
    margin: 12px;
    padding: 18px !important;
    border-radius: 20px !important;
  }
}

/* ---- Smooth Table Horizontal Scrolling on Mobile ---- */
.overflow-x-auto {
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

/* ---- Canvas Signature Touch Configuration ---- */
canvas {
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

/* ---- PWA Install Prompt Bar ---- */
#pwa-install-bar {
  position: fixed;
  bottom: 0;
  left: 0; right: 0;
  z-index: 10000;
  background: linear-gradient(135deg, #1e3a5f, #2563eb);
  color: white;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  font-weight: 600;
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.3);
  padding-bottom: max(14px, env(safe-area-inset-bottom, 0px));
}

#pwa-install-bar.show {
  transform: translateY(0);
}

#pwa-install-bar button {
  font-weight: 700;
  font-size: 12px;
  border-radius: 20px;
  padding: 6px 18px;
  cursor: pointer;
  transition: opacity 0.2s;
}

/* Hide navigation and bars during printing */
@media print {
  header, footer, nav, #mobile-bottom-nav, #quickAddOverlay, #quickAddPanel, #pwa-install-bar, #pwa-install-bar * {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
  }
}

/* ---- Custom Scrollbar ---- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ---- Smooth Page Transition ---- */
main {
  animation: fadeIn 0.18s ease-out;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(3px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- Card Hover & Active Taps ---- */
.stat-card {
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.stat-card:active {
  transform: scale(0.98);
}

/* ---- Dropdown Bridge & Hover Hit-Area ---- */
.dropdown-container {
  position: relative;
}
.dropdown-menu::before {
  content: '';
  position: absolute;
  top: -14px;
  left: 0;
  right: 0;
  height: 14px;
  background: transparent;
}
