/* =========================================================
   Mips – Mobile-friendly enhancements
   Loaded AFTER dash.css / styleUser.css so it can safely
   override/extend the existing rules.
   ========================================================= */

/* -------------------- Dashboard cards -------------------- */
.dash-grid{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 20px;
  padding: 0 20px;
  margin-bottom: 10px;
}

.dashcard{
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 22px;
  border-radius: 16px;
  color: #fff;
  box-shadow: 0 6px 16px rgba(0,0,0,0.12);
  min-width: 0;
}

.dashcard .icon-badge{
  flex: 0 0 auto;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.2);
  font-size: 26px;
  line-height: 1;
}

.dashcard .dash-body{
  flex: 1;
  min-width: 0;
}

.dashcard .dash-label{
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .5px;
  text-transform: uppercase;
  opacity: .85;
  margin: 0 0 4px;
}

.dashcard .dash-value{
  font-size: 21px;
  font-weight: 700;
  margin: 0;
  word-break: break-word;
  line-height: 1.25;
}

.dashcard .dash-sub{
  font-size: 13px;
  margin: 3px 0 0;
  opacity: .92;
}

.dashcard.color-one{  background: linear-gradient(135deg, #0A2558, #17418f); }
.dashcard.color-two{  background: linear-gradient(135deg, #b30000, #e63946); }
.dashcard.color-three{background: linear-gradient(135deg, #ff6600, #ff9142); }
.dashcard.color-four{ background: linear-gradient(135deg, #006666, #00999e); }

.chart-card{
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 6px 16px rgba(0,0,0,0.08);
  padding: 24px;
  margin: 24px 20px 0;
}
.chart-card .chart-wrap{
  position: relative;
  width: 100%;
  height: 360px;
}
@media (max-width: 640px){
  .chart-card .chart-wrap{ height: 260px; }
}

/* -------------------- Responsive tables -------------------- */
.table-responsive-wrap{
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 10px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.08);
  background: #fff;
  margin-bottom: 10px;
}
.table-responsive-wrap table{
  width: 100%;
  min-width: 640px;
  margin: 0;
}

/* Toolbar above tables: stacks nicely on mobile */
.table-toolbar{
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

/* Card-style table for small screens */
@media (max-width: 640px){
  .table-responsive-wrap table{ min-width: 0; }
  .table-responsive-wrap table thead{ display: none; }
  .table-responsive-wrap table,
  .table-responsive-wrap tbody,
  .table-responsive-wrap tr,
  .table-responsive-wrap td{
    display: block;
    width: 100%;
  }
  .table-responsive-wrap tr{
    margin-bottom: 12px;
    border: 1px solid #eaeaea;
    border-radius: 10px;
    padding: 6px 14px;
  }
  .table-responsive-wrap tr:last-child{ margin-bottom: 0; }
  .table-responsive-wrap td{
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    text-align: right;
    border: none !important;
    border-bottom: 1px solid #f2f2f2 !important;
    padding: 9px 0;
  }
  .table-responsive-wrap td:last-child{ border-bottom: none !important; }
  .table-responsive-wrap td::before{
    content: attr(data-label);
    font-weight: 600;
    color: #0A2558;
    text-align: left;
    margin-right: 10px;
    flex: 0 0 auto;
  }
}

/* -------------------- Pagination -------------------- */
.pagination{
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  list-style: none;
  padding: 16px 0 4px;
  margin: 0;
  justify-content: center;
}
.pagination a,
.pagination span.page-ellipsis{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 38px;
  padding: 0 10px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid #ddd;
  color: #0A2558;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all .2s ease;
}
.pagination a:hover{
  background: #0A2558;
  color: #fff;
  border-color: #0A2558;
}
.pagination a.active-page{
  background: #0A2558;
  color: #fff;
  border-color: #0A2558;
  cursor: default;
}
.pagination a.disabled{
  opacity: .4;
  pointer-events: none;
}
.pagination-info{
  text-align: center;
  font-size: 13px;
  color: #666;
  margin-top: 4px;
}

/* -------------------- Off-canvas sidebar for mobile -------------------- */
.sidebar-overlay{
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 1500;
}

@media (max-width: 800px){
  .sidebar{
    width: 260px !important;
    transform: translateX(-100%);
    z-index: 2000;
    box-shadow: 3px 0 16px rgba(0,0,0,.3);
  }
  .sidebar.active{
    width: 260px !important;
    transform: translateX(0);
  }
  .sidebar .logo_name,
  .sidebar .links_name{
    display: inline-block !important;
  }

  .home-section,
  .sidebar.active ~ .home-section{
    width: 100% !important;
    left: 0 !important;
  }
  .home-section nav,
  .sidebar.active ~ .home-section nav{
    width: 100% !important;
    left: 0 !important;
  }

  .sidebar-overlay.show{ display: block; }

  .home-section nav .sidebar-button .dashboard{
    display: inline-block !important;
    font-size: 18px;
  }

  .dash-grid{
    padding: 0 12px;
    grid-template-columns: 1fr 1fr;
  }
  .chart-card{ margin: 20px 12px 0; padding: 16px; }
}

@media (max-width: 480px){
  .dash-grid{ grid-template-columns: 1fr; }
  .dashcard{ padding: 18px; }
  .dashcard .icon-badge{ width: 48px; height: 48px; font-size: 22px; }
  .dashcard .dash-value{ font-size: 18px; }
}

/* Scanner pages - ensure camera viewport works on mobile */
#scanner { max-width: 100%; }
#scanner video { max-width: 100% !important; width: 100% !important; }

/* Fix form spacing on mobile */
@media (max-width: 640px){
  form { padding: 20px 15px !important; margin: 20px 10px !important; }
  .home-content .container { padding: 0 10px; }
  button, .button-container button { width: 100%; margin: 5px 0 !important; }
  .table-toolbar { flex-direction: column; align-items: stretch; }
  .table-toolbar .pagination-info { text-align: center; }
  h2 { font-size: 18px; }
}

/* Better login mobile */
@media (max-width: 480px){
  .login-container { padding: 20px 15px !important; }
  .login-container img { width: 80px !important; }
}

/* Dashboard stat cards touch-friendly */
.dashcard, .dashcounter { cursor: default; }
.dashcard:active, .dashcounter:active { transform: scale(0.98); }

/* Activity log responsive */
.activity-feed { padding: 0 12px; }
.activity-item { flex-wrap: wrap; }

/* Charts in dashboard */
.charts-grid { padding: 0 12px; gap: 12px; }
.dashboard-row { padding: 0 12px; gap: 12px; }
