/* =============================================
   MISTER CLEAN — MOBILE APP UI
   True mobile application experience
   ============================================= */

@media (max-width: 768px) {

  /* === RESET DESKTOP LAYOUT === */
  .sidebar { display: none !important; }
  .topbar { display: none !important; }
  .main-content {
    margin-left: 0 !important;
    margin-top: 0 !important;
    padding: 0 !important;
    padding-bottom: 80px !important;
    width: 100% !important;
    min-height: 100vh;
  }

  /* === MOBILE HEADER === */
  .mobile-header {
    position: fixed; top: 0; left: 0; right: 0; z-index: 900;
    height: 56px;
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 16px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
  }
  .mobile-header .mh-title {
    font-size: 17px; font-weight: 700; color: var(--text);
  }
  .mobile-header .mh-logo {
    width: 32px; height: 32px; border-radius: 8px;
  }
  .mobile-header .mh-actions { display: flex; gap: 8px; align-items: center; }
  .mobile-header .mh-btn {
    width: 36px; height: 36px; border-radius: 10px;
    border: 1px solid var(--border2); background: var(--bg3);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 16px; position: relative;
  }

  /* === BOTTOM TAB BAR === */
  .mobile-tabbar {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 900;
    height: 64px;
    background: var(--bg2);
    border-top: 1px solid var(--border);
    display: flex; align-items: stretch;
    padding-bottom: env(safe-area-inset-bottom, 0);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
  }
  .mobile-tabbar .tab-item {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 2px; cursor: pointer;
    color: var(--text3); text-decoration: none;
    transition: all 0.15s; position: relative;
    -webkit-tap-highlight-color: transparent;
  }
  .mobile-tabbar .tab-item.active { color: var(--accent); }
  .mobile-tabbar .tab-item.active::before {
    content: ''; position: absolute; top: 0; left: 25%; right: 25%;
    height: 2px; background: var(--accent); border-radius: 0 0 2px 2px;
  }
  .mobile-tabbar .tab-icon { font-size: 20px; line-height: 1; }
  .mobile-tabbar .tab-label { font-size: 10px; font-weight: 600; }
  .mobile-tabbar .tab-badge {
    position: absolute; top: 4px; right: calc(50% - 18px);
    min-width: 16px; height: 16px; border-radius: 8px;
    background: #ef4444; color: white; font-size: 9px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    padding: 0 4px;
  }

  /* === PAGE CONTENT === */
  #mainContent {
    padding-top: 64px !important;
    padding-left: 12px !important;
    padding-right: 12px !important;
  }
  .page { padding: 0 !important; }
  .page-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 10px !important;
    padding: 12px 0 !important;
  }
  .page-title { font-size: 20px !important; }
  .page-sub { font-size: 12px !important; }
  .page-actions {
    width: 100% !important;
    display: flex !important;
    gap: 8px !important;
  }
  .page-actions input[type="text"] {
    flex: 1 !important; width: auto !important;
  }
  .page-actions .btn-primary {
    display: none !important; /* Replaced by FAB */
  }

  /* === FLOATING ACTION BUTTON === */
  .mobile-fab {
    position: fixed; bottom: 80px; right: 16px; z-index: 800;
    width: 56px; height: 56px; border-radius: 16px;
    background: var(--accent); color: white;
    border: none; box-shadow: 0 4px 16px rgba(6,182,212,0.4);
    font-size: 28px; font-weight: 300; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
    -webkit-tap-highlight-color: transparent;
  }
  .mobile-fab:active { transform: scale(0.92); }

  /* === CARDS instead of TABLES === */
  .section-card table { display: none !important; }
  .section-card { padding: 0 !important; border: none !important; background: transparent !important; box-shadow: none !important; }

  .mobile-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px;
    margin-bottom: 10px;
    transition: transform 0.1s;
    -webkit-tap-highlight-color: transparent;
  }
  .mobile-card:active { transform: scale(0.98); }
  .mobile-card-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 8px;
  }
  .mobile-card-title { font-weight: 700; font-size: 15px; color: var(--text); }
  .mobile-card-sub { font-size: 12px; color: var(--text3); margin-top: 2px; }
  .mobile-card-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 4px 0;
  }
  .mobile-card-label { font-size: 12px; color: var(--text3); }
  .mobile-card-value { font-size: 13px; font-weight: 600; color: var(--text); }
  .mobile-card-actions {
    display: flex; gap: 6px; margin-top: 10px; padding-top: 10px;
    border-top: 1px solid var(--border);
  }
  .mobile-card-actions .btn { flex: 1; font-size: 12px; padding: 8px !important; }

  /* === FULL SCREEN MODALS === */
  .modal-overlay {
    align-items: flex-end !important;
    padding: 0 !important;
  }
  .modal-box {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 95vh !important;
    min-height: 50vh;
    border-radius: 20px 20px 0 0 !important;
    animation: slideUp 0.3s ease !important;
  }
  @keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }
  .modal-header {
    position: sticky; top: 0; z-index: 10;
    background: var(--bg2);
    padding: 16px 20px !important;
    border-bottom: 1px solid var(--border);
  }
  .modal-header::before {
    content: ''; display: block;
    width: 36px; height: 4px; border-radius: 2px;
    background: var(--bg4); margin: 0 auto 12px;
  }
  .modal-body { padding: 16px !important; }
  .modal-footer {
    position: sticky; bottom: 0;
    background: var(--bg2);
    padding: 12px 16px !important;
    border-top: 1px solid var(--border);
    display: flex; gap: 8px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0)) !important;
  }
  .modal-footer .btn { flex: 1; padding: 14px !important; font-size: 14px !important; border-radius: 12px !important; }

  /* === MOBILE FORMS === */
  .form-grid {
    display: flex !important; flex-direction: column !important; gap: 12px !important;
  }
  .form-group { width: 100% !important; }
  .form-group.full { width: 100% !important; }
  .form-group label {
    font-size: 13px !important; font-weight: 600 !important;
    margin-bottom: 6px !important; display: block;
  }
  .form-group input, .form-group select, .form-group textarea {
    width: 100% !important;
    padding: 14px 16px !important;
    font-size: 16px !important; /* Prevents iOS zoom */
    border-radius: 12px !important;
    border: 1.5px solid var(--border2) !important;
    background: var(--bg3) !important;
  }
  .form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    border-color: var(--accent) !important;
    outline: none;
  }

  /* === BUTTONS === */
  .btn { border-radius: 10px !important; font-size: 13px !important; }
  .btn-primary { padding: 12px 20px !important; }
  .btn-xs { padding: 8px 12px !important; font-size: 12px !important; border-radius: 8px !important; }

  /* === BADGES === */
  .badge { font-size: 11px !important; padding: 4px 10px !important; border-radius: 8px !important; }

  /* === STATS GRID === */
  .stat-grid, [style*="grid-template-columns: repeat(4"] {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }
  [style*="grid-template-columns: repeat(3"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  [style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* === NOTIFICATION PANEL === */
  #notifPanel, .notif-panel {
    width: 100% !important;
    right: -110% !important;
    border-radius: 0 !important;
    border-left: none !important;
  }
  #notifPanel.open, .notif-panel.open {
    right: 0 !important;
  }

  /* === SWITCHER TABS === */
  [style*="display:flex;gap:0;margin-bottom:20px;border-radius:10px"] {
    border-radius: 12px !important;
    overflow: hidden !important;
  }
  [style*="display:flex;gap:0;margin-bottom:20px;border-radius:10px"] button {
    padding: 10px 12px !important; font-size: 13px !important;
  }

  /* === CHARTS === */
  canvas { max-height: 200px !important; }

  /* === HIDE DESKTOP ELEMENTS === */
  .hide-mobile, .desktop-only { display: none !important; }
  th.hide-mobile, td.hide-mobile { display: none !important; }

  /* === PULL DOWN INDICATOR === */
  .pull-indicator {
    text-align: center; padding: 8px;
    font-size: 12px; color: var(--text3);
    display: none;
  }

  /* === SKELETON === */
  @keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
  }
  .skeleton-card {
    background: linear-gradient(90deg, var(--bg3) 25%, var(--bg4) 50%, var(--bg3) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 14px; height: 80px; margin-bottom: 10px;
  }

  /* === SAFE AREAS (iOS notch) === */
  body {
    padding-top: env(safe-area-inset-top, 0);
  }
}

/* === EXTRA SMALL SCREENS === */
@media (max-width: 380px) {
  .mobile-header { padding: 0 12px; }
  .mobile-header .mh-title { font-size: 15px; }
  #mainContent { padding-left: 8px !important; padding-right: 8px !important; }
  .mobile-card { padding: 12px; }
  .mobile-fab { width: 48px; height: 48px; font-size: 24px; border-radius: 14px; }
}
