/* css/10-responsive.css — Dashboard finesse and ALL mobile/tablet/touch rules (must load last). Load order matters: files are cut from one stylesheet, in cascade order. */
/* ─── DASHBOARD FINESSE & GRID STRICTNESS ─── */
.dash-grid-fix { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 24px; align-items: start; margin-bottom: 24px; }
@media(max-width: 1000px) { .dash-grid-fix { grid-template-columns: 1fr; } }

.panel-header-finesse { padding: 16px 20px; display: flex; justify-content: space-between; align-items: center; background: #fff; border-bottom: 1px solid var(--border); border-radius: 12px 12px 0 0; }
.panel-title-finesse { display: flex; align-items: center; gap: 8px; font-size: 11px; font-weight: 700; color: #1A1A1A; text-transform: uppercase; letter-spacing: 0.05em; }
.panel-link-red { color: #C0282D; font-size: 11px; font-weight: 600; cursor: pointer; border: none; background: transparent; padding: 0; display: inline-flex; align-items: center; gap: 4px; transition: opacity 0.15s; }
.panel-link-red:hover { opacity: 0.7; }

.stat-card-finesse { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.02); transition: box-shadow 0.2s, transform 0.2s; cursor: pointer; }
.stat-card-finesse:hover { box-shadow: 0 8px 24px rgba(0,0,0,0.06); transform: translateY(-2px); border-color: var(--border-mid); }
.stat-icon-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; }
.stat-circle-arrow { width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; color: var(--text-muted); }

.finesse-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 6px; font-size: 10px; font-weight: 600; }
.finesse-pill-green { background: #F0FDF4; color: #16A34A; border: 1px solid #BBF7D0; }
.finesse-pill-red { background: #FEF2F2; color: #C0282D; border: 1px solid #FECACA; }

.remind-btn { background: #fff; border: 1px solid var(--border-mid); border-radius: 6px; padding: 5px 10px; font-size: 11px; font-weight: 500; color: var(--text-muted); display: inline-flex; align-items: center; gap: 6px; cursor: pointer; transition: all 0.15s; }
.remind-btn:hover { border-color: var(--text); color: var(--text); box-shadow: 0 2px 4px rgba(0,0,0,0.05); }

.qa-btn-finesse { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; font-size: 12px; font-weight: 500; color: #1A1A1A; display: flex; align-items: center; gap: 12px; cursor: pointer; transition: all 0.15s; justify-content: flex-start; }
.qa-btn-finesse:hover { border-color: var(--border-mid); background: #FAFAF9; box-shadow: 0 2px 4px rgba(0,0,0,0.02); }

/* ═══════════════════════════════════════════════════════════════
   MOBILE & TABLET
   Priority order matches the actual goal — monitoring tasks from a
   phone with no laptop nearby — not a pixel-perfect pass over every
   screen in the app. Sidebar, header, Dashboard, My Actions, task
   modals, and Products & Projects are the surfaces that matter for
   that; everything else gets the general safety-net rules at the
   bottom (tap targets, table scrolling, modal sizing) rather than a
   bespoke layout each.
   ═══════════════════════════════════════════════════════════════ */

#sidebar-backdrop { display:none; position:fixed; inset:0; background:rgba(0,0,0,0.45); z-index:1099; }
#sidebar-backdrop.show { display:block; }

@media (max-width: 900px) {
  #screen-app { overflow: visible; }

  /* Sidebar becomes an off-canvas drawer instead of a permanent column */
  #sidebar {
    position: fixed; top: 0; left: 0; z-index: 1100;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 6px 0 28px rgba(0,0,0,0.3);
  }
  #sidebar.mobile-open { transform: translateX(0); }

  #main-area { width: 100%; min-width: 0; }

  /* Header: search bar shrinks and shares a row with the bell/avatar
     instead of being squeezed to near-nothing */
  #main-header { padding: 10px 14px; gap: 8px; flex-wrap: wrap; }
  .header-left { flex: 1; min-width: 0; }
  .global-search-wrap { max-width: none; }
  .global-search-input { font-size: 13px; } /* 16px+ would be nicer for iOS zoom-avoidance, but keep visual density */
  #user-name, #user-email { display: none; } /* avatar alone is enough on a phone-width header */
  .gsr-panel { width: calc(100vw - 28px); left: -40px; }

  /* Page content: full-bleed padding instead of desktop's generous gutters */
  .view-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .view-title { font-size: 20px; }
  #main-content, .main-content { padding: 14px !important; }

  /* Stat card / grid layouts collapse to one column everywhere they
     appear — dashboard stats, product cards, task cards, workload bars */
  .dashboard-row-2col, .dash-grid-fix, .task-group-grid,
  [style*="grid-template-columns:1fr 1fr"], [style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
  [style*="grid-template-columns:repeat(4"], [style*="grid-template-columns:repeat(3"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Products & Projects / task action rows — buttons wrap onto their
     own line cleanly rather than overflowing sideways */
  .pcf-actions { flex-wrap: wrap; }
  .pcf-actions .btn-primary-sm, .pcf-actions .btn-secondary-sm { flex: 1 1 auto; }

  /* Pending approvals / task detail grids inside modals */
  #pending-approvals-list [style*="grid-template-columns"] { grid-template-columns: 1fr !important; }

  /* Filter bars — full width, wrap freely */
  .task-filter-bar, #task-filter-bar-mobile { flex-direction: column; align-items: stretch; }
  .task-filter-bar > * { width: 100%; }

  .pdt-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

@media (max-width: 600px) {
  /* Modals: near-fullscreen instead of a fixed-width box that can
     overflow or leave awkward margins on a phone */
  #create-product-modal, .modal-overlay {
    padding: 0 !important;
    align-items: flex-end !important; /* slides up from the bottom, easier one-handed reach */
  }
  #create-product-modal > div, .modal-overlay > div {
    max-width: 100% !important; width: 100% !important;
    border-radius: 16px 16px 0 0 !important;
    max-height: 92vh; overflow-y: auto;
  }

  .view-title { font-size: 18px; }
  .panel-header { flex-wrap: wrap; gap: 6px; }

  /* Task cards inside a group grid: full width, no minmax floor to fight */
  .task-group-grid { grid-template-columns: 1fr !important; }

  /* Weekly review / edit-task forms: single column always */
  .form-row, .form-actions { width: 100%; }
}

/* Tables that were only ever designed for a wide desktop viewport (Task
   Tracker's table view, Circuit Box's data tables) — wrap in horizontal
   scroll rather than break the whole page layout or truncate silently */
@media (max-width: 900px) {
  table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap; }
  table thead, table tbody, table tr { display: table; width: 100%; table-layout: fixed; }
}

/* Touch targets — buttons and inputs sized for a mouse pointer are
   frequently too small to hit reliably with a thumb */
@media (pointer: coarse) {
  .btn-primary, .btn-secondary, .btn-outline, .btn-primary-sm, .btn-secondary-sm,
  .btn-danger-sm, .btn-danger-xs, .nav-item, .pdt-tab, input, select, textarea {
    min-height: 38px;
  }
  .btn-danger-xs, .task-drag-handle { min-height: 30px; } /* small icon-only controls stay compact */
}
