/* =====================================================
   NATIVE MOBILE APP EXPERIENCE
   Complete redesign for mobile-first native feel
   ===================================================== */

/* =====================================================
   MOBILE BOTTOM NAVIGATION (iOS/Android Style)
   ===================================================== */

.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 65px;
  background: white;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  padding: 0;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.mobile-bottom-nav-wrapper {
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: 5px 10px;
}

.mobile-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: #666;
  transition: all 0.2s ease;
  padding: 5px;
  border-radius: 12px;
  position: relative;
  min-width: 60px;
}

.mobile-nav-item:active {
  background: rgba(75, 73, 172, 0.1);
  transform: scale(0.95);
}

.mobile-nav-item.active {
  color: #4B49AC;
}

.mobile-nav-item.active .mobile-nav-icon {
  transform: scale(1.1);
}

.mobile-nav-icon {
  font-size: 24px;
  margin-bottom: 3px;
  transition: transform 0.2s ease;
}

.mobile-nav-item.home .mobile-nav-icon {
  font-size: 32px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 15px rgba(75, 73, 172, 0.3);
  margin-bottom: 0;
}

.mobile-nav-item.home.active .mobile-nav-icon {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(75, 73, 172, 0.4);
}

.mobile-nav-label {
  font-size: 11px;
  font-weight: 500;
  margin-top: 2px;
  white-space: nowrap;
}

.mobile-nav-item.home .mobile-nav-label {
  display: none;
}

/* Badge for notifications */
.mobile-nav-badge {
  position: absolute;
  top: 2px;
  right: 15px;
  background: #ff4444;
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 10px;
  min-width: 16px;
  text-align: center;
}

/* =====================================================
   MOBILE-ONLY STYLES
   ===================================================== */

@media only screen and (max-width: 768px) {
  
  /* Show bottom navigation */
  .mobile-bottom-nav {
    display: block !important;
  }

  /* ========== HIDE DESKTOP ELEMENTS ========== */
  
  /* Hide desktop sidebar completely on mobile */
  .sidebar {
    display: none !important;
  }

  /* Simplify navbar for mobile */
  .navbar {
    height: 56px;
    padding: 0 15px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  }

  .navbar-brand-wrapper {
    width: auto;
    min-width: 50px;
  }

  .navbar-brand-mini {
    display: none !important;
  }

  /* Hide navbar menu items except user profile */
  .navbar-menu-wrapper .navbar-nav:first-child {
    display: none;
  }

  /* Hide settings panels */
  .theme-setting-wrapper,
  #right-sidebar,
  .settings-panel {
    display: none !important;
  }

  /* ========== MAIN CONTENT ADJUSTMENTS ========== */
  
  .main-panel {
    width: 100% !important;
    margin-left: 0 !important;
    margin-top: 56px;
    padding-bottom: 75px; /* Space for bottom nav */
  }

  .content-wrapper {
    padding: 15px 12px;
    padding-bottom: 85px; /* Extra space for bottom nav */
    min-height: calc(100vh - 56px - 75px);
  }

  /* ========== CARDS - NATIVE APP STYLE ========== */
  
  .card {
    border-radius: 16px;
    border: none;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    margin-bottom: 16px;
    overflow: hidden;
  }

  .card-body {
    padding: 20px;
  }

  /* Status cards with gradient backgrounds */
  .card.bg-gradient-primary,
  .card.bg-gradient-warning,
  .card.bg-gradient-success,
  .card.bg-gradient-danger {
    color: white;
    border: none;
  }

  /* ========== FULL-WIDTH MOBILE LAYOUT ========== */
  
  .row {
    margin-left: -6px;
    margin-right: -6px;
  }

  .row > [class*="col-"] {
    padding-left: 6px;
    padding-right: 6px;
    width: 100%;
    flex: 0 0 100%;
    max-width: 100%;
  }

  /* Two columns for small cards in landscape */
  @media (orientation: landscape) {
    .row > .col-md-6 {
      flex: 0 0 50%;
      max-width: 50%;
    }
  }

  /* ========== TYPOGRAPHY - MOBILE OPTIMIZED ========== */
  
  h1, .h1 {
    font-size: 28px;
    font-weight: 700;
  }

  h2, .h2 {
    font-size: 24px;
    font-weight: 700;
  }

  h3, .h3 {
    font-size: 20px;
    font-weight: 600;
  }

  h4, .h4 {
    font-size: 18px;
    font-weight: 600;
  }

  h5, .h5 {
    font-size: 16px;
    font-weight: 600;
  }

  h6, .h6 {
    font-size: 14px;
    font-weight: 600;
  }

  p {
    font-size: 15px;
    line-height: 1.6;
  }

  /* ========== BUTTONS - NATIVE APP STYLE ========== */
  
  .btn {
    min-height: 50px;
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 12px;
    border: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
  }

  .btn:active {
    transform: scale(0.97);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
  }

  .btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  }

  .btn-success {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
  }

  .btn-danger {
    background: linear-gradient(135deg, #ee0979 0%, #ff6a00 100%);
  }

  .btn-warning {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  }

  /* ========== TABLES - MOBILE OPTIMIZED ========== */
  
  .table-responsive {
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  }

  table {
    font-size: 14px;
  }

  thead {
    background: #f8f9fa;
  }

  th {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.5px;
    padding: 15px 10px !important;
  }

  td {
    padding: 15px 10px !important;
  }

  /* Smaller action buttons in tables */
  table .btn {
    min-height: 36px;
    padding: 8px 12px;
    font-size: 13px;
    border-radius: 8px;
    width: auto;
    display: inline-flex;
    margin: 2px;
  }

  /* ========== FORMS - NATIVE APP STYLE ========== */
  
  input,
  select,
  textarea,
  .form-control {
    min-height: 52px;
    padding: 14px 18px;
    font-size: 16px;
    border-radius: 12px;
    border: 2px solid #e0e0e0;
    background: white;
    transition: all 0.2s ease;
  }

  input:focus,
  select:focus,
  textarea:focus,
  .form-control:focus {
    border-color: #4B49AC;
    box-shadow: 0 0 0 3px rgba(75, 73, 172, 0.1);
    outline: none;
  }

  label {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
    display: block;
  }

  .form-group {
    margin-bottom: 20px;
  }

  /* ========== FOOTER - SIMPLIFIED ========== */
  
  .footer {
    display: none; /* Hide on mobile, we have bottom nav */
  }

  /* ========== DROPDOWNS - TOUCH FRIENDLY ========== */
  
  .dropdown-menu {
    border-radius: 16px;
    border: none;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    padding: 8px;
  }

  .dropdown-item {
    padding: 14px 18px;
    font-size: 15px;
    border-radius: 10px;
    transition: background 0.2s ease;
  }

  .dropdown-item:active {
    background: #f0f0f0;
  }

  /* ========== STATS/METRICS - BIG & BOLD ========== */
  
  .card-body h1,
  .card-body h2,
  .card-body h3 {
    font-weight: 700;
    margin-bottom: 5px;
  }

  /* Make numbers pop */
  .card-body h1 {
    font-size: 36px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
  }

  /* ========== ONLINE STATUS BADGE - TOP CENTER ========== */
  
  #online-status {
    top: 5px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    padding: 4px 12px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 20px;
    z-index: 9999;
  }

  /* ========== PULL TO REFRESH INDICATOR ========== */
  
  .pull-to-refresh {
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transform: translateY(-100%);
    transition: transform 0.3s ease;
    z-index: 999;
  }

  .pull-to-refresh.active {
    transform: translateY(0);
  }

  /* ========== SMOOTH SCROLLING ========== */
  
  * {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
  }

  /* ========== PREVENT TEXT SELECTION ON UI ELEMENTS ========== */
  
  .mobile-bottom-nav,
  .navbar,
  .btn,
  .card {
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
  }

  /* Text content should be selectable */
  p, span, h1, h2, h3, h4, h5, h6, td, th {
    -webkit-user-select: text;
    user-select: text;
  }
}

/* =====================================================
   STANDALONE MODE (Installed PWA)
   ===================================================== */

@media all and (display-mode: standalone) {
  
  /* Remove any browser chrome indicators */
  body {
    background: #f5f5f5;
  }

  /* Add safe area support for notched devices */
  .navbar {
    padding-top: max(env(safe-area-inset-top), 10px);
  }

  .mobile-bottom-nav {
    padding-bottom: max(env(safe-area-inset-bottom), 10px);
  }

  /* Hide install button when already installed */
  #pwa-install-container {
    display: none !important;
  }

  /* Native app feel */
  .main-panel {
    background: #f5f5f5;
  }

  /* Add subtle app animations */
  .card {
    animation: fadeInUp 0.3s ease;
  }

  @keyframes fadeInUp {
    from {
      opacity: 0;
      transform: translateY(20px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
}

/* =====================================================
   LANDSCAPE MODE OPTIMIZATIONS
   ===================================================== */

@media only screen and (max-width: 768px) and (orientation: landscape) {
  
  .navbar {
    height: 48px;
  }

  .main-panel {
    margin-top: 48px;
  }

  .content-wrapper {
    padding: 12px;
  }

  .mobile-bottom-nav {
    height: 55px;
  }

  .mobile-nav-item {
    padding: 3px;
  }

  .mobile-nav-icon {
    font-size: 20px;
    margin-bottom: 2px;
  }

  .mobile-nav-item.home .mobile-nav-icon {
    width: 42px;
    height: 42px;
    font-size: 28px;
  }

  .mobile-nav-label {
    font-size: 10px;
  }
}

/* =====================================================
   SMALL DEVICES (< 360px)
   ===================================================== */

@media only screen and (max-width: 360px) {
  
  .mobile-nav-label {
    font-size: 10px;
  }

  .mobile-nav-icon {
    font-size: 20px;
  }

  .mobile-nav-item.home .mobile-nav-icon {
    width: 45px;
    height: 45px;
  }

  .btn {
    padding: 12px 20px;
    font-size: 15px;
  }

  .card-body {
    padding: 16px;
  }
}

/* =====================================================
   DARK MODE SUPPORT
   ===================================================== */

@media (prefers-color-scheme: dark) and (max-width: 768px) {
  
  body,
  .main-panel,
  .content-wrapper {
    background: #121212;
    color: #ffffff;
  }

  .mobile-bottom-nav {
    background: #1e1e1e;
    border-top-color: #333;
  }

  .mobile-nav-item {
    color: #999;
  }

  .mobile-nav-item.active {
    color: #8b89e6;
  }

  .card {
    background: #1e1e1e;
    border-color: #333;
  }

  .navbar {
    background: #1e1e1e !important;
  }

  input,
  select,
  textarea,
  .form-control {
    background: #2a2a2a;
    color: white;
    border-color: #444;
  }

  .dropdown-menu {
    background: #1e1e1e;
  }

  .dropdown-item {
    color: #fff;
  }

  table th {
    background: #2a2a2a;
  }
}

/* =====================================================
   LOADING ANIMATION
   ===================================================== */

@media only screen and (max-width: 768px) {
  
  .page-loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
  }

  .loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
  }

  @keyframes spin {
    to { transform: rotate(360deg); }
  }
}

