/* Blair Auto Cares — responsive layer V7.2
   Loaded after per-page styles so every admin screen adapts consistently. */

html { -webkit-text-size-adjust: 100%; }
body { min-width: 0 !important; overflow-x: hidden !important; }
img, svg, canvas, video { max-width: 100%; }
button, input, select, textarea { max-width: 100%; }

/* Prevent long values from breaking layouts */
.card, .panel, .ops-metric, .stat, .sum, .main-wrapper, .main-content, main.main, .main,
.left-panel, .right-panel, .workspace > *, .ops-grid-2 > *, .ops-grid-3 > * { min-width: 0; }
.card, .panel { overflow-wrap: anywhere; }

/* Desktop / laptop scaling */
@media (max-width: 1366px) and (min-width: 1101px) {
  .sidebar { width: 205px !important; }
  .main-wrapper, .main-content, main.main, .main { margin-left: 205px !important; width: calc(100% - 205px) !important; }
  .content { padding: 22px !important; }
  .ops-nav .nav-item, .ops-nav a { padding-left: 12px !important; padding-right: 10px !important; font-size: .78rem !important; }
  .nav-section { padding-left: 12px !important; }
  .ops-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
}

/* Medium laptop / landscape tablet */
@media (max-width: 1100px) {
  .ops-metrics, .stats, .summary-cards { grid-template-columns: repeat(2, minmax(0,1fr)) !important; }
  .ops-grid-2, .ops-grid-3, .reports-grid { grid-template-columns: 1fr !important; }
  .workspace { grid-template-columns: 1fr !important; min-height: 0 !important; }
  .product-grid { grid-template-columns: repeat(auto-fill, minmax(135px, 1fr)) !important; }
  .header, .top, .top-header { padding-left: 18px !important; padding-right: 18px !important; }
}

/* Off-canvas navigation starts here so tablets have the full content width. */
@media (max-width: 900px) {
  body { display: block !important; height: auto !important; min-height: 100vh !important; overflow-y: auto !important; }
  .sidebar {
    position: fixed !important; inset: 0 auto 0 0 !important;
    width: min(82vw, 300px) !important; height: 100dvh !important;
    transform: translateX(-105%) !important; transition: transform .24s ease !important;
    box-shadow: 14px 0 35px rgba(0,0,0,.45); z-index: 3000 !important;
  }
  .sidebar.open { transform: translateX(0) !important; }
  .sidebar .logo-container img, .sidebar .sidebar-header img { max-width: 110px !important; }
  .sidebar-nav { padding-bottom: 88px !important; }
  .ops-nav .nav-item, .ops-nav a, .nav-item {
    font-size: .86rem !important; padding: 11px 16px !important; min-height: 42px !important;
  }
  .ops-nav .nav-item span, .ops-nav a span, .nav-item span { display: inline !important; }
  .nav-section { display: block !important; padding: 17px 16px 7px !important; }
  .user-info { display: flex !important; }

  .main-wrapper, .main-content, main.main, .main {
    margin-left: 0 !important; width: 100% !important; min-width: 0 !important; min-height: 100dvh !important;
  }
  .mobile-toggle { display: inline-flex !important; align-items: center; justify-content: center; }
  .sidebar-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.56); z-index: 2990;
    opacity: 0; visibility: hidden; transition: .2s ease;
  }
  .sidebar-overlay.show { opacity: 1; visibility: visible; }

  .header, .top, .top-header {
    min-height: 58px !important; height: auto !important; position: sticky !important; top: 0 !important;
    z-index: 1200 !important; padding: 9px 14px !important; gap: 10px !important;
  }
  .header h1, .header h2, .header-title { font-size: 1.05rem !important; line-height: 1.2; }
  .header-right { gap: 10px !important; }
  .header-right .cash-pill { max-width: 112px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .content { padding: 16px !important; overflow: visible !important; }
  .page-title, .ops-page-head h1 { font-size: 1.35rem !important; }
  .ops-page-head, .hero, .detail-head { align-items: flex-start !important; }
  .ops-page-head { flex-direction: column !important; gap: 12px !important; }
  .ops-actions, .actions { width: 100%; flex-wrap: wrap !important; }

  .table-responsive, .table-wrap {
    width: 100% !important; overflow-x: auto !important; overflow-y: hidden;
    -webkit-overflow-scrolling: touch; border-radius: 7px;
  }
  .table-responsive .table, .table-wrap .table { min-width: 680px; }
  .table th, .table td { padding: 10px 11px !important; font-size: .8rem !important; }

  .modal-backdrop, .modal-bg { padding: 12px !important; }
  .modal { width: min(96vw, 680px) !important; max-height: 92dvh !important; border-radius: 10px !important; }
  .modal-body { max-width: 100%; }
  .modal-footer, .modal-foot { flex-wrap: wrap !important; }

  /* POS: stack products and cart so nothing is cut off */
  .main-wrapper[style*="overflow: hidden"] { height: auto !important; overflow: visible !important; }
  .pos-container {
    display: grid !important; grid-template-columns: 1fr !important; height: auto !important;
    min-height: 0 !important; padding: 14px !important; gap: 14px !important;
  }
  .left-panel, .right-panel { flex: none !important; width: 100% !important; }
  .left-panel { min-height: 0 !important; }
  .product-grid { max-height: none !important; overflow: visible !important; }
  .right-panel { min-height: 520px; }
  .cart-items { max-height: 42vh; min-height: 180px; }
  .help-panel { display: none !important; }

  /* Clients/Citas pages had their own desktop-only body/sidebar rules */
  .workspace { grid-template-columns: 1fr !important; }
  .client-list { max-height: 360px !important; }
  .detail-grid, .modal-body { grid-template-columns: 1fr !important; }
  .field.full { grid-column: auto !important; }
  .tabs { overflow-x: auto !important; -webkit-overflow-scrolling: touch; }
  .tab { white-space: nowrap; }
}

/* Phones */
@media (max-width: 600px) {
  :root { --header-height: 56px; }
  .content { padding: 12px !important; }
  .header, .top, .top-header { padding: 8px 10px !important; }
  .header-right { gap: 8px !important; }
  .header-right .cash-pill { display: none !important; }
  .icon-btn { font-size: 1.05rem !important; }
  .card, .panel { padding: 14px !important; border-radius: 8px !important; }
  .panel { overflow: hidden !important; }

  .ops-metrics, .stats, .summary-cards, .summary { grid-template-columns: 1fr 1fr !important; gap: 9px !important; }
  .ops-metric, .stat, .sum { min-height: 82px !important; padding: 12px !important; }
  .ops-metric strong, .stat strong, .sum strong { font-size: 1.15rem !important; }
  .ops-metric small, .stat small, .sum small { font-size: .65rem !important; }
  .ops-status-grid { grid-template-columns: 1fr 1fr !important; }

  .ops-toolbar, .toolbar, .search-bar { flex-direction: column !important; align-items: stretch !important; width: 100%; }
  .ops-toolbar .form-control, .toolbar .form-control,
  #searchOrder, #catFilter, #searchFilter { width: 100% !important; max-width: none !important; }
  .ops-toolbar .btn, .toolbar .btn { justify-content: center; }

  .ops-page-head .btn, .hero > .btn, .hero .actions .btn { min-height: 42px; }
  .ops-actions .btn { flex: 1 1 145px; justify-content: center; }
  .btn { min-height: 40px; padding: 9px 12px !important; }

  .table-responsive .table, .table-wrap .table { min-width: 620px; }
  .notifications-panel { position: fixed !important; top: 62px !important; left: 10px !important; right: 10px !important; width: auto !important; max-height: calc(100dvh - 75px); }

  .ops-form-grid { grid-template-columns: 1fr !important; }
  .ops-form-grid .full { grid-column: auto !important; }
  .form-control { font-size: 16px; } /* avoids iOS zoom */

  .modal { width: 100% !important; max-width: none !important; }
  .modal-header, .modal-head, .modal-body, .modal-footer, .modal-foot { padding-left: 14px !important; padding-right: 14px !important; }
  .modal-footer .btn, .modal-foot .btn { flex: 1 1 130px; justify-content: center; }

  .product-grid { grid-template-columns: repeat(2, minmax(0,1fr)) !important; gap: 9px !important; }
  .prod-card { padding: 11px !important; }
  .prod-card h5 { font-size: .78rem !important; }
  .prod-card i { font-size: 1.45rem !important; }
  .cart-header { flex-wrap: wrap !important; }
  .cart-header select { flex: 1 1 100% !important; }
  .cart-header .btn { width: 100%; justify-content: center; }
  .cart-item { gap: 9px; align-items: flex-start !important; }
  .pay-methods { display: grid !important; grid-template-columns: repeat(3,1fr); gap: 7px !important; }
  .pay-btn { padding: 9px 5px !important; font-size: .76rem; }
  #efectivoPanel { display: grid !important; grid-template-columns: auto 1fr !important; }
  #efectivoPanel strong { text-align: right; }

  .hero { flex-direction: column !important; align-items: stretch !important; }
  .hero .actions { width: 100%; }
  .hero .actions .btn { flex: 1; }
  .workspace { min-height: 0 !important; }
  .detail-head { flex-direction: column !important; }
  .detail-grid { grid-template-columns: 1fr !important; }
  .client-list { max-height: 300px !important; }

  /* Forms embedded with inline 2-column grids */
  [style*="grid-template-columns:1fr 1fr"],
  [style*="grid-template-columns: 1fr 1fr"] { grid-template-columns: 1fr !important; }
  [style*="display:flex"][style*="gap:10px"] { flex-wrap: wrap; }
}

/* Very small phones */
@media (max-width: 390px) {
  .ops-metrics, .stats, .summary-cards, .summary, .ops-status-grid { grid-template-columns: 1fr !important; }
  .product-grid { grid-template-columns: 1fr 1fr !important; }
  .page-title, .ops-page-head h1 { font-size: 1.2rem !important; }
  .header b, .header h2 { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

@media (orientation: landscape) and (max-height: 520px) and (max-width: 900px) {
  .sidebar .logo-container, .sidebar .sidebar-header { padding: 6px 12px !important; }
  .sidebar .logo-container img, .sidebar .sidebar-header img { max-width: 72px !important; }
  .user-info { padding: 7px 12px !important; }
  .ops-nav .nav-item, .ops-nav a, .nav-item { padding-top: 8px !important; padding-bottom: 8px !important; min-height: 34px !important; }
  .nav-section { padding-top: 10px !important; }
}
