/* Mobile Native-App Style Layouts & Responsive Media Queries */

/* Bottom Navigation Bar (Mobile Only) */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--mobile-nav-height);
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.08);
  z-index: 50;
  justify-content: space-around;
  align-items: center;
  padding: 0 0.25rem;
}

@media (max-width: 768px) {
  html, body, #app-container, .main-wrapper {
    max-width: 100vw !important;
    overflow-x: hidden !important;
  }

  .sidebar {
    display: none !important;
  }
  
  .mobile-bottom-nav {
    display: flex !important;
  }

  .main-wrapper {
    margin-bottom: var(--mobile-nav-height);
    width: 100vw;
  }

  .content-body {
    padding: 0.85rem;
    overflow-x: hidden;
  }

  .top-header {
    padding: 0 0.85rem;
    height: auto;
    min-height: 58px;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
  }

  .header-left {
    width: 100%;
    justify-content: space-between;
  }

  .header-right {
    width: 100%;
    justify-content: space-between;
  }

  .global-search-box {
    flex: 1;
  }

  .global-search-input:focus {
    width: 100%;
  }

  /* Responsive Grid Breakdown on Mobile */
  .grid-cols-4, .grid-cols-3, .grid-cols-2 {
    grid-template-columns: repeat(1, minmax(0, 1fr)) !important;
  }

  /* Hide Desktop Table, Show Mobile Cards */
  .hide-mobile {
    display: none !important;
  }

  .hide-desktop {
    display: block !important;
  }

  /* Touch-Friendly Modal Sizing on Mobile */
  .modal {
    width: 94vw !important;
    max-height: 88vh !important;
    margin: auto;
    border-radius: var(--radius-lg);
  }

  .modal-body {
    padding: 1rem;
  }

  .form-grid {
    grid-template-columns: 1fr !important;
  }
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 500;
  flex: 1;
  height: 100%;
  transition: color var(--transition-fast);
  padding: 4px 0;
}

.mobile-nav-item.active {
  color: var(--primary);
  font-weight: 600;
}

.mobile-nav-item svg {
  width: 22px;
  height: 22px;
}

/* Center Floating Action Button (FAB) */
.mobile-fab-container {
  position: relative;
  top: -14px;
  flex: 0 0 54px;
  display: flex;
  justify-content: center;
}

.mobile-fab-btn {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 16px rgba(79, 70, 229, 0.4);
  transition: transform var(--transition-fast);
}

.mobile-fab-btn:active {
  transform: scale(0.92);
}

/* Mobile Bottom Sheet Drawer */
.bottom-sheet-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.bottom-sheet-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border-top-left-radius: var(--radius-xl);
  border-top-right-radius: var(--radius-xl);
  padding: 1.5rem 1.25rem 2rem;
  z-index: 101;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 -10px 25px rgba(0, 0, 0, 0.15);
  max-height: 85vh;
  overflow-y: auto;
}

.bottom-sheet.show {
  transform: translateY(0);
}

.bottom-sheet-handle {
  width: 40px;
  height: 5px;
  background: var(--border-color);
  border-radius: var(--radius-full);
  margin: 0 auto 1.25rem;
}

.bottom-sheet-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1rem;
  text-align: center;
}

.bottom-sheet-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.85rem;
}

.sheet-action-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 0.5rem;
  border-radius: var(--radius-md);
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  text-align: center;
  transition: background var(--transition-fast);
}

.sheet-action-item:active {
  background: var(--primary-light);
  border-color: var(--primary-border);
}

.sheet-action-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.2rem;
}

.sheet-action-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-main);
}

/* Responsive Card-Based Data View (Mobile Tables -> Mobile Cards) */
.mobile-card-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.mobile-data-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  position: relative;
  transition: transform var(--transition-fast);
}

.mobile-data-card:active {
  transform: scale(0.99);
}

.mobile-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.mobile-card-title-box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.mobile-card-thumb {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  object-fit: cover;
  background: var(--border-light);
  flex-shrink: 0;
}

.mobile-card-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-main);
}

.mobile-card-code {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: monospace;
}

.mobile-card-body {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  font-size: 0.8rem;
  padding: 0.5rem 0;
  border-top: 1px dashed var(--border-color);
  border-bottom: 1px dashed var(--border-color);
}

.mobile-field-label {
  color: var(--text-muted);
  font-size: 0.72rem;
}

.mobile-field-value {
  font-weight: 500;
  color: var(--text-main);
}

.mobile-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding-top: 0.25rem;
}
