/* ==========================================================================
   HexCrypt Admin — Mobile View Stylesheet (mobile.css)
   PWA-optimized with bottom navigation, top app bar, compact student cards
   ========================================================================== */

/* Desktop defaults: hide mobile cells, show table cells */
.mobile-only-cell {
  display: none !important;
}
.desktop-only {
  display: table-cell;
}

@media (max-width: 768px) {
  /* ===== 1. Body & Layout with App Bars ===== */
  body {
    padding: calc(58px + env(safe-area-inset-top, 0px)) 6px calc(72px + env(safe-area-inset-bottom, 0px)) 6px !important;
    font-size: 13px !important;
    overflow-x: hidden !important;
  }

  /* Show mobile nav elements */
  .top-app-bar {
    display: flex !important;
  }

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

  .mob-platform-bar {
    display: flex !important;
  }

  /* Hide desktop tab bar on mobile */
  #desktopTabBar {
    display: none !important;
  }

  /* Hide desktop footer on mobile (actions are in bottom nav / more sheet) */
  .panel-footer {
    display: none !important;
  }

  /* Hide elements that are duplicated in the More sheet on mobile */
  .mob-hide {
    display: none !important;
  }

  /* ===== 2. Cards ===== */
  .card {
    padding: 10px 8px !important;
    margin: 6px auto !important;
    border-radius: 12px !important;
    max-width: 100% !important;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.4) !important;
  }

  h2 {
    font-size: 15px !important;
    margin-bottom: 8px !important;
    font-weight: 700 !important;
  }

  /* ===== 3. Sub Tabs (LPUNEST / LPUNEST Locked / Python Locked) ===== */
  .sub-tab-bar {
    max-width: 100% !important;
    gap: 4px !important;
    margin-top: 5px !important;
    padding: 0 2px !important;
    justify-content: center !important;
  }

  .sub-tab-btn {
    padding: 5px 8px !important;
    font-size: 10.5px !important;
    border-radius: 14px !important;
    flex: 1 1 auto !important;
    text-align: center !important;
    max-width: 48% !important;
  }

  /* ===== 4. Stats Summary Bar ===== */
  .total-bar {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(54px, 1fr)) !important;
    gap: 3px !important;
    padding: 4px 6px !important;
    margin-bottom: 8px !important;
    border-radius: 8px !important;
    background: rgba(0, 0, 0, 0.3) !important;
  }

  .total-item {
    background: rgba(255, 255, 255, 0.03) !important;
    border: 1px solid rgba(255, 255, 255, 0.04) !important;
    border-radius: 6px !important;
    padding: 3px 2px !important;
    text-align: center !important;
  }

  .total-num {
    font-size: 13.5px !important;
    line-height: 1.1 !important;
    font-weight: 700 !important;
  }

  .total-label {
    font-size: 8px !important;
    letter-spacing: 0.2px !important;
    margin-top: 1px !important;
    text-transform: uppercase !important;
    color: #64748b !important;
  }

  /* ===== 5. Compact Form Inputs ===== */
  label {
    margin-top: 5px !important;
    font-size: 10px !important;
    margin-bottom: 2px !important;
  }

  input {
    padding: 7px 9px !important;
    font-size: 14px !important;
    border-radius: 6px !important;
  }

  .form-row-compact {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 6px !important;
  }

  button[type="submit"] {
    padding: 8px !important;
    margin-top: 8px !important;
    font-size: 12.5px !important;
    border-radius: 7px !important;
  }

  /* ===== 6. Search Bar ===== */
  .search-container {
    margin-bottom: 6px !important;
  }

  .search-input {
    padding: 6px 10px 6px 28px !important;
    font-size: 12px !important;
    border-radius: 6px !important;
  }

  .search-icon {
    left: 8px !important;
    font-size: 12px !important;
  }

  /* ===== 7. Student Card Layout (Ultra-Compact) ===== */
  table {
    display: block !important;
    width: 100% !important;
    border-spacing: 0 !important;
  }

  thead {
    display: none !important;
  }

  tbody {
    display: block !important;
    width: 100% !important;
  }

  tr {
    display: block !important;
    background: rgba(14, 18, 34, 0.85) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: 8px !important;
    padding: 0 !important;
    margin-bottom: 4px !important;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25) !important;
    position: relative !important;
    transition: transform 0.15s ease, border-color 0.15s ease !important;
  }

  tr:hover {
    border-color: rgba(0, 240, 255, 0.35) !important;
  }

  .desktop-only {
    display: none !important;
  }

  .mobile-only-cell {
    display: block !important;
    width: 100% !important;
    padding: 5px 8px !important;
    box-sizing: border-box !important;
    background: transparent !important;
    border-radius: 8px !important;
  }

  /* --- Line 1: Name + Key | Credits + Badge --- */
  .mob-line-1 {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    width: 100% !important;
    gap: 5px !important;
    min-height: 18px !important;
  }

  .mob-left {
    display: flex !important;
    align-items: center !important;
    gap: 5px !important;
    flex: 1 !important;
    min-width: 0 !important;
    overflow: hidden !important;
  }

  .mob-name {
    font-size: 13px !important;
    font-weight: 700 !important;
    color: #fff !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    max-width: 140px !important;
  }

  .mob-reg {
    background: rgba(0, 240, 255, 0.08) !important;
    color: #00f0ff !important;
    padding: 1px 5px !important;
    border-radius: 4px !important;
    font-family: Consolas, monospace !important;
    font-size: 10px !important;
    letter-spacing: 0.2px !important;
    border: 1px solid rgba(0, 240, 255, 0.2) !important;
    flex-shrink: 0 !important;
  }

  .mob-device-icon {
    font-size: 11px !important;
    flex-shrink: 0 !important;
  }

  .mob-right {
    display: flex !important;
    align-items: center !important;
    gap: 4px !important;
    flex-shrink: 0 !important;
  }

  .mob-cred {
    background: rgba(33, 150, 243, 0.12) !important;
    color: #2196F3 !important;
    padding: 1px 5px !important;
    border-radius: 4px !important;
    font-weight: 700 !important;
    font-size: 10px !important;
    border: 1px solid rgba(33, 150, 243, 0.25) !important;
    white-space: nowrap !important;
  }

  .mob-badge {
    padding: 1px 5px !important;
    font-size: 9px !important;
    border-radius: 8px !important;
    font-weight: 700 !important;
    white-space: nowrap !important;
  }

  /* --- Line 2: Date | Action Buttons --- */
  .mob-line-2 {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    width: 100% !important;
    margin-top: 3px !important;
    padding-top: 3px !important;
    border-top: 1px solid rgba(255, 255, 255, 0.04) !important;
    gap: 4px !important;
    min-height: 24px !important;
  }

  .mob-meta {
    font-size: 9.5px !important;
    color: #64748b !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    flex: 1 !important;
    min-width: 0 !important;
  }

  .mob-actions {
    display: flex !important;
    align-items: center !important;
    gap: 3px !important;
    flex-shrink: 0 !important;
  }

  .mob-actions .act-btn {
    height: 24px !important;
    min-height: 24px !important;
    padding: 1px 6px !important;
    font-size: 10px !important;
    font-weight: 700 !important;
    border-radius: 4px !important;
    margin: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    white-space: nowrap !important;
  }

  .mob-actions .btn-edit {
    background: rgba(0, 240, 255, 0.12) !important;
    color: #00f0ff !important;
    border: 1px solid rgba(0, 240, 255, 0.3) !important;
  }

  .mob-actions .btn-pause {
    background: rgba(255, 170, 0, 0.12) !important;
    color: #ffaa00 !important;
    border: 1px solid rgba(255, 170, 0, 0.35) !important;
  }

  .mob-actions .btn-resume {
    background: rgba(0, 230, 118, 0.12) !important;
    color: #00e676 !important;
    border: 1px solid rgba(0, 230, 118, 0.35) !important;
  }

  .mob-actions .btn-unbind {
    background: rgba(255, 193, 7, 0.12) !important;
    color: #ffc107 !important;
    border: 1px solid rgba(255, 193, 7, 0.3) !important;
  }

  .mob-actions .btn-del {
    background: rgba(255, 82, 82, 0.12) !important;
    color: #ff5252 !important;
    border: 1px solid rgba(255, 82, 82, 0.3) !important;
  }

  /* ===== 8. Toast (above bottom nav) ===== */
  #toast {
    left: 8px !important;
    right: 8px !important;
    bottom: calc(72px + env(safe-area-inset-bottom, 0px)) !important;
    text-align: center !important;
    padding: 8px 12px !important;
    font-size: 11px !important;
    border-radius: 8px !important;
  }

  /* ===== 9. Modals ===== */
  .modal-backdrop {
    padding: 10px !important;
  }

  .modal-card {
    padding: 14px 12px !important;
    max-width: 100% !important;
    width: 100% !important;
    border-radius: 12px !important;
    max-height: 85vh !important;
    overflow-y: auto !important;
  }

  .modal-header h3 {
    font-size: 14px !important;
  }

  /* ===== 10. Modal Tables (Reseller Detail, Deleted History, Transactions) ===== */
  .modal-card table,
  #txContent table {
    display: table !important;
    width: max-content !important;
    min-width: 100% !important;
    font-size: 10px !important;
    border-spacing: 0 2px !important;
  }
  .modal-card thead,
  #txContent thead {
    display: table-header-group !important;
  }
  .modal-card tbody,
  #txContent tbody {
    display: table-row-group !important;
  }
  .modal-card tr,
  #txContent tr {
    display: table-row !important;
    background: rgba(14, 18, 34, 0.6) !important;
    border: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    position: static !important;
  }
  .modal-card th,
  #txContent th {
    display: table-cell !important;
    padding: 4px 5px !important;
    font-size: 9px !important;
    white-space: nowrap !important;
    color: #64748b !important;
    text-transform: uppercase !important;
    letter-spacing: 0.3px !important;
    border-bottom: 1px solid rgba(255,255,255,0.06) !important;
  }
  .modal-card td,
  #txContent td {
    display: table-cell !important;
    padding: 5px 5px !important;
    font-size: 10px !important;
    white-space: nowrap !important;
    vertical-align: middle !important;
  }
  .modal-card .act-btn,
  #txContent .act-btn {
    padding: 2px 6px !important;
    font-size: 9px !important;
  }
  #resDetailStudents,
  #deletedHistoryContent,
  #txContent {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  /* ===== 11. Reseller Paused Banner (compact on mobile) ===== */
  .top-app-bar + div > div[style*="background:linear-gradient"] {
    font-size: 12px !important;
    padding: 12px 14px !important;
    line-height: 1.5 !important;
  }
}
