/* ============================================
   VCONSYST360 - MOBILE FIX & UI IMPROVEMENTS
   Safe CSS-only patches for mobile UX
   ============================================ */

/* ============================================
   GOAL 1: MOBILE MENU FIX (CRITICAL)
   Full screen overlay, no horizontal slide
   ============================================ */

@media (max-width: 768px) {
  
  /* Mobile Drawer - Full Screen Overlay */
  .m-drawer {
    position: fixed !important;
    inset: 0 !important;
    z-index: 99999 !important;
    display: none !important;
  }
  
  .m-drawer.open {
    display: flex !important;
    flex-direction: column !important;
  }
  
  /* Backdrop - Full screen, clickable to close */
  .m-drawer-backdrop {
    position: absolute !important;
    inset: 0 !important;
    background: rgba(0, 0, 0, 0.5) !important;
    backdrop-filter: blur(4px) !important;
    z-index: 1 !important;
  }
  
  /* Panel - Full screen, NO horizontal slide */
  .m-drawer-panel {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    background: #fff !important;
    color: #111 !important;
    transform: none !important;
    transition: none !important;
    z-index: 2 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
  }
  
  /* Header - Minimal padding */
  .m-drawer-head {
    flex-shrink: 0 !important;
    padding: 16px !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
  }
  
  /* Body - Scrollable menu items */
  .m-drawer-body {
    flex: 1 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 12px !important;
    -webkit-overflow-scrolling: touch !important;
  }
  
  /* Menu Items - Touch friendly */
  .m-item {
    min-height: 48px !important;
    padding: 14px 16px !important;
    margin: 6px 0 !important;
    font-size: 16px !important;
    display: flex !important;
    align-items: center !important;
    border-radius: 12px !important;
  }
  
  /* Close button - Larger touch target */
  .m-drawer-close {
    width: 44px !important;
    height: 44px !important;
    font-size: 28px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
  
}

/* ============================================
   GOAL 2: GLOBAL MOBILE USABILITY
   ============================================ */

@media (max-width: 768px) {
  
  /* Touch-friendly buttons */
  .btn, button, .navlink {
    min-height: 44px !important;
    font-size: 16px !important;
    padding: 12px 16px !important;
  }
  
  /* Touch-friendly inputs */
  input, select, textarea {
    min-height: 44px !important;
    font-size: 16px !important;
    padding: 12px !important;
  }
  
  /* Labels readable */
  label {
    font-size: 14px !important;
    margin-bottom: 6px !important;
  }
  
  /* Tables - Horizontal scroll */
  .tablewrap {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    margin: 0 -12px !important;
    padding: 0 12px !important;
  }
  
  .tablewrap table {
    min-width: 600px !important;
  }
  
  /* Cards - Better spacing */
  .card {
    padding: 16px !important;
    margin-bottom: 12px !important;
  }
  
  /* Page headers - Stack vertically */
  .pagehead {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 12px !important;
  }
  
  .pagehead .actions {
    width: 100% !important;
  }
  
  /* Grids - Single column on mobile */
  .kpis,
  .cards,
  .grid2,
  .grid3,
  .filters-grid {
    grid-template-columns: 1fr !important;
  }
  
  /* Form grids - Single column */
  .form.grid {
    grid-template-columns: 1fr !important;
  }
  
  /* No horizontal overflow */
  body {
    overflow-x: hidden !important;
  }
  
  * {
    max-width: 100% !important;
  }
  
  img, svg, video {
    max-width: 100% !important;
    height: auto !important;
  }
  
}

/* ============================================
   GOAL 3: UNIFIED DESIGN SYSTEM
   Mobile & Desktop consistency
   ============================================ */

/* Buttons - Unified */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.1));
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  font-weight: 500;
  transition: all 0.15s ease;
}

.btn:hover {
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.btn-primary,
.btn.primary {
  background: rgba(79, 124, 255, 0.18);
  border-color: rgba(79, 124, 255, 0.45);
  color: #4f7cff;
}

.btn-danger,
.btn.danger {
  background: rgba(255, 79, 109, 0.14);
  border-color: rgba(255, 79, 109, 0.35);
  color: #ff4f6d;
}

/* Page Structure - Unified */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0 16px;
}

.page-title {
  font-size: 28px;
  font-weight: 700;
  margin: 0;
}

.page-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Cards - Unified */
.card {
  border: 1px solid var(--border, rgba(255, 255, 255, 0.08));
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  padding: 16px;
}

.card-title {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 12px 0;
}

/* KPIs - Unified */
.kpi {
  border: 1px solid var(--border, rgba(255, 255, 255, 0.08));
  border-radius: 16px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.02);
}

.kpi-label {
  font-size: 12px;
  color: var(--muted, #9aa4c7);
  margin-bottom: 4px;
}

.kpi-val {
  font-size: 20px;
  font-weight: 700;
}

/* Muted text */
.muted {
  color: var(--muted, #9aa4c7);
}

/* Forms - Unified */
.field {
  margin-bottom: 12px;
}

.label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--muted, #9aa4c7);
}

.input,
.select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border, rgba(255, 255, 255, 0.08));
  background: rgba(255, 255, 255, 0.03);
  outline: none;
}

.input:focus,
.select:focus {
  border-color: rgba(79, 124, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(79, 124, 255, 0.18);
}

/* Table wrapper - Safe scrolling */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 14px;
}

/* Hamburger button - Mobile only */
.m-menu-btn {
  display: none;
  width: 44px;
  height: 44px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 8px;
}

.m-menu-btn span {
  width: 20px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  transition: all 0.2s ease;
}

@media (max-width: 768px) {
  .m-menu-btn {
    display: flex !important;
  }
  
  /* Hide desktop nav on mobile */
  .nav {
    display: none !important;
  }
}

@media (min-width: 769px) {
  /* Hide mobile elements on desktop */
  .m-drawer,
  .m-menu-btn,
  .mnav {
    display: none !important;
  }
}

/* Prevent body scroll when menu open */
body.m-lock,
html.m-lock {
  overflow: hidden !important;
  position: fixed !important;
  width: 100% !important;
  height: 100% !important;
}

/* ============================================
   ACCESSIBILITY & POLISH
   ============================================ */

/* Focus visible for keyboard navigation */
*:focus-visible {
  outline: 2px solid rgba(79, 124, 255, 0.6) !important;
  outline-offset: 2px !important;
}

/* Smooth scrolling */
html {
  scroll-behavior: smooth;
}

/* Tap highlight color */
* {
  -webkit-tap-highlight-color: rgba(79, 124, 255, 0.1);
}
