/* =====================================================
   MaisonWifi - Mobile Optimization
   Responsive Design for Staff Dashboard
   ===================================================== */

/* MOBILE FIRST - Base styles for all devices */

:root {
  --mobile-padding: 0.75rem;
  --mobile-gap: 0.5rem;
  --touch-min: 44px;
}

/* ===== MOBILE (< 768px) ===== */

@media (max-width: 767px) {

  /* General */
  body {
    font-size: 14px;
    line-height: 1.4;
  }

  .content-card {
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    border-radius: 8px;
  }

  h1 { font-size: 1.4rem; margin: 0.5rem 0; }
  h2 { font-size: 1.2rem; margin: 0.5rem 0; }
  h3 { font-size: 1rem; margin: 0.25rem 0; }
  small { font-size: 0.75rem; }

  /* Layout */
  .flex-container {
    flex-direction: column;
    gap: 0.5rem;
  }

  /* ===== ACCUEIL.PHP ===== */

  /* Header Section */
  .page-header {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
  }

  .page-header h2 {
    margin-bottom: 0;
  }

  .page-header small {
    margin-bottom: 0;
  }

  .page-header div {
    text-align: left;
  }

  /* Stats Grid - One Column */
  .stats-grid,
  .inventory-summary {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
    margin-bottom: 1rem;
  }

  .secretariat-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.6rem;
  }

  .secretariat-stat-card {
    min-width: 0;
    padding: 0.75rem 0.65rem;
  }

  .secretariat-stat-label {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.35;
    white-space: normal;
  }

  .secretariat-stat-amount {
    margin: 0.35rem 0 0;
    color: var(--text-main);
    font-size: clamp(0.95rem, 4.5vw, 1.2rem);
    line-height: 1.3;
    overflow-wrap: anywhere;
  }

  .stat-card,
  .inventory-stat {
    padding: 0.75rem;
    border-radius: 8px;
  }

  .inventory-stat-icon {
    width: 36px;
    height: 36px;
    font-size: 0.9rem;
  }

  .inventory-stat-body small {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.75rem;
  }

  .inventory-stat-body strong {
    font-size: 1.1rem;
    display: block;
  }

  /* Quick Buttons */
  .nav-quick-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
    font-size: 0.9rem;
    width: 100%;
    margin-bottom: 0.5rem;
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s;
    min-height: 44px;
  }

  .nav-quick-btn span {
    display: inline-flex;
    align-items: center;
  }

  /* Table Wrapper */
  .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: -0.75rem;
    padding: 0 0.75rem;
  }

  table {
    font-size: 0.9rem;
    width: 100%;
  }

  /* ===== SALES.PHP ===== */

  /* Form Layout */
  .form-row,
  .form-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 0.75rem;
  }

  .form-control,
  input[type="text"],
  input[type="date"],
  input[type="email"],
  input[type="number"],
  select,
  textarea {
    width: 100%;
    padding: 0.75rem;
    font-size: 16px; /* Prevent zoom on iOS */
    border: 1px solid var(--border);
    border-radius: 6px;
    box-sizing: border-box;
    margin-bottom: 0.5rem;
  }

  label {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    display: block;
  }

  /* DataTables: preserve headings and use deliberate horizontal scrolling.
     The application creates rows through AJAX, so card labels are not reliable. */
  table { min-width: 680px; }
  .content-card { overflow-x: auto; }

  /* ===== TICKETS.PHP ===== */

  /* Filter Bar */
  .filter-bar,
  .inv-filter-bar {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem;
    margin-bottom: 1rem;
  }

  .filter-bar label {
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
  }

  .filter-bar input[type="date"],
  .inv-filter-bar input[type="date"] {
    width: 100%;
    padding: 0.75rem;
    font-size: 16px;
  }

  /* Shortcuts */
  .inv-shortcut {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    white-space: normal;
    flex: 1;
    min-height: 44px;
  }

  /* ===== BUTTONS ===== */

  .btn {
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    min-height: 44px;
    margin-bottom: 0.5rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
  }

  .btn-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }

  .btn-group .btn { width: 100%; }

  .btn-group-horizontal {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }

  /* ===== MODALS ===== */

  .modal-content {
    border-radius: 12px;
  }

  /* ===== UTILITIES ===== */

  .hide-mobile {
    display: none !important;
  }

  .show-mobile {
    display: block !important;
  }

  .mobile-stack {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }

  .mobile-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 6px;
  }

  .touch-target {
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Badges */
  .badge {
    font-size: 0.8rem;
    padding: 0.35rem 0.6rem;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
  }

  .stock-badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
  }

  /* ===== SPACING ADJUSTMENTS ===== */

  .container,
  .page-container {
    padding: 0.5rem;
  }

  margin-top-1 { margin-top: 0.5rem; }
  margin-bottom-1 { margin-bottom: 0.5rem; }
  padding-1 { padding: 0.5rem; }

}

/* ===== TABLET (768px - 1024px) ===== */

@media (min-width: 768px) and (max-width: 1024px) {

  .stats-grid,
  .inventory-summary {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.9rem;
  }

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

  .show-mobile {
    display: none !important;
  }

  .btn {
    width: auto;
  }

}

/* ===== DESKTOP (1025px+) ===== */

@media (min-width: 1025px) {

  .stats-grid,
  .inventory-summary {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  }

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

  .show-mobile {
    display: none !important;
  }

  .form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }

}

/* ===== SPECIFIC OPTIMIZATIONS ===== */

/* DataTables Mobile Support */
.dataTables_wrapper {
  font-size: 0.9rem;
}

.dataTables_length,
.dataTables_filter {
  margin-bottom: 0.75rem;
}

.dataTables_length label,
.dataTables_filter label {
  display: flex;
  flex-direction: column;
  font-size: 0.9rem;
}

.dataTables_length select,
.dataTables_filter input {
  width: 100%;
  padding: 0.5rem;
  font-size: 14px;
  margin-top: 0.25rem;
}

/* Prevents layout shift */
* {
  box-sizing: border-box;
}

/* Smooth scrolling */
html {
  scroll-behavior: smooth;
}

/* Ensure inputs don't get zoomed on iOS */
input, textarea, select {
  font-size: 16px;
}

/* Link padding for mobile */
a {
  padding: 0.25rem;
}

/* Animation optimization for mobile */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
