/* ============================================
   PRIMOS Mobile Responsive Styles
   Mobile-first responsive design for all pages
   ============================================ */

/* ============================================
   MOBILE NAVIGATION - SLIDE-IN DRAWER
   ============================================ */

/* Hamburger Menu Button */
.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: white;
  padding: 8px;
  cursor: pointer;
  z-index: 1001;
}

.mobile-menu-btn .hamburger {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 24px;
}

.mobile-menu-btn .hamburger span {
  display: block;
  height: 2px;
  background: white;
  border-radius: 2px;
  transition: all 0.3s ease;
}

.mobile-menu-btn.active .hamburger span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.mobile-menu-btn.active .hamburger span:nth-child(2) {
  opacity: 0;
}

.mobile-menu-btn.active .hamburger span:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
}

/* Mobile Nav Overlay */
.mobile-nav-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.mobile-nav-overlay.active {
  display: block;
  opacity: 1;
}

/* Mobile Nav Drawer */
.mobile-nav-drawer {
  position: fixed;
  top: 0;
  left: -280px;
  width: 280px;
  height: 100%;
  background: var(--color-header-bg);
  z-index: 1000;
  transition: left 0.3s ease;
  overflow-y: auto;
  box-shadow: 2px 0 20px rgba(0, 0, 0, 0.3);
}

.mobile-nav-drawer.active {
  left: 0;
}

.mobile-nav-header {
  padding: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mobile-nav-header img {
  height: 32px;
  filter: brightness(0) invert(1);
}

.mobile-nav-close {
  background: none;
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  padding: 8px;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.mobile-nav-close:hover {
  opacity: 1;
}

/* Mobile Nav Menu Items */
.mobile-nav-menu {
  padding: 16px 0;
}

.mobile-nav-section {
  padding: 8px 0;
}

.mobile-nav-section-title {
  padding: 12px 20px 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.5);
}

.mobile-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
  transition: all 0.2s ease;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.mobile-nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.mobile-nav-item.active {
  background: var(--color-primary);
  color: white;
}

.mobile-nav-item .nav-icon {
  font-size: 18px;
  width: 24px;
  text-align: center;
}

/* Mobile User Section */
.mobile-nav-user {
  padding: 16px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  margin-top: auto;
}

.mobile-nav-user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.mobile-nav-user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.mobile-nav-user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mobile-nav-user-name {
  color: white;
  font-weight: 500;
  font-size: 14px;
}

.mobile-nav-user-email {
  color: rgba(255, 255, 255, 0.6);
  font-size: 12px;
}

.mobile-nav-logout {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 8px;
  color: white;
  font-size: 13px;
  cursor: pointer;
  width: 100%;
  transition: background 0.2s;
}

.mobile-nav-logout:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ============================================
   RESPONSIVE BREAKPOINTS
   ============================================ */

/* Tablet and below (768px) */
@media (max-width: 768px) {
  /* Show mobile menu button, hide desktop nav */
  .mobile-menu-btn {
    display: flex;
  }

  .nav-tabs {
    display: none !important;
  }

  /* Header adjustments */
  .header {
    padding: 12px 16px;
    gap: 12px;
  }

  .header-left {
    gap: 12px;
  }

  .header-logo {
    width: 100px;
  }

  /* Hide global search on mobile */
  .global-search {
    display: none;
  }

  /* Hide Ask PRIMOS button on mobile */
  .ask-primos-btn {
    display: none;
  }

  /* User info simplified */
  .user-info {
    display: none;
  }

  /* Container padding */
  .container {
    padding: 16px;
  }

  /* Page title bar */
  .page-title-bar h1 {
    font-size: 22px;
  }

  /* ============================================
     DASHBOARD MOBILE STYLES
     ============================================ */

  /* Claude search container */
  .claude-search-container {
    padding: 16px;
  }

  .claude-search-suggestions {
    flex-wrap: wrap;
    gap: 8px;
  }

  .claude-search-suggestions button {
    font-size: 12px;
    padding: 6px 10px;
  }

  /* Production summary card */
  .production-summary-card {
    padding: 16px;
  }

  .production-status-counts {
    gap: 8px;
  }

  .production-count-item {
    min-width: 70px;
    padding: 8px;
  }

  .production-count-item .count {
    font-size: 20px;
  }

  .production-facility-summary {
    flex-direction: column;
    gap: 8px;
  }

  /* Quick links grid */
  .quick-links {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .quick-link {
    padding: 16px 12px;
  }

  /* Analytics grid */
  .analytics-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .analytics-card {
    padding: 16px;
  }

  /* Section headers */
  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  /* ============================================
     HEALTH METRICS BAR - MOBILE
     ============================================ */

  .health-metrics-bar {
    flex-wrap: wrap;
    gap: 8px;
  }

  .health-metric-card {
    flex: 1 1 calc(50% - 4px);
    min-width: 140px;
    padding: 12px;
  }

  .health-metric-card.health-all {
    flex: 1 1 100%;
  }

  .health-metric-count {
    font-size: 18px;
  }

  .health-metric-card.health-all .health-metric-count {
    font-size: 24px;
  }

  /* ============================================
     PRODUCTION CONTROLS BAR - MOBILE
     ============================================ */

  .production-controls-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 12px;
  }

  .production-controls-left {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .updated-time-display {
    justify-content: center;
    font-size: 12px;
  }

  .location-filter-group {
    justify-content: center;
  }

  .production-controls-right {
    justify-content: center;
  }

  .refresh-btn {
    width: 100%;
    justify-content: center;
  }

  /* ============================================
     ORDERS TABLE - MOBILE (PD#, Customer, Status only)
     ============================================ */

  .production-grid {
    border-radius: 8px;
  }

  .production-table {
    table-layout: auto;
  }

  /* Hide non-essential columns on mobile */
  .production-table .col-location,
  .production-table th:nth-child(4),
  .production-table td:nth-child(4),
  .production-table .col-days,
  .production-table th:nth-child(5),
  .production-table td:nth-child(5),
  .production-table .col-due,
  .production-table th:nth-child(6),
  .production-table td:nth-child(6) {
    display: none;
  }

  /* Keep Health, PD#, Customer, Status visible */
  .production-table thead th {
    padding: 10px 8px;
    font-size: 10px;
  }

  .production-table tbody td {
    padding: 12px 8px;
    font-size: 13px;
  }

  .production-table .col-health {
    width: 40px;
    min-width: 40px;
  }

  .production-table .col-pd {
    width: 80px;
    min-width: 70px;
  }

  .production-table .col-customer {
    min-width: 100px;
  }

  .production-table .col-status {
    min-width: 80px;
  }

  .health-swatch {
    width: 20px;
    height: 20px;
  }

  .customer-name {
    max-width: 120px;
    font-size: 13px;
  }

  .status-summary {
    font-size: 11px;
  }

  .status-summary .ai-icon {
    display: none;
  }

  /* ============================================
     ALL ORDERS TABLE - MOBILE
     ============================================ */

  #tab-orders .production-controls-bar {
    flex-direction: column;
    gap: 12px;
  }

  /* All Orders table - hide extra columns (show only PD#, SO#, Customer on mobile) */
  #orders-body tr td:nth-child(4),
  #orders-body tr td:nth-child(5),
  #orders-body tr td:nth-child(6),
  #orders-body tr td:nth-child(7),
  #orders-body tr td:nth-child(8),
  #orders-body tr td:nth-child(9),
  #orders-body tr td:nth-child(10),
  #orders-body tr td:nth-child(11) {
    display: none;
  }

  #tab-orders table thead th:nth-child(4),
  #tab-orders table thead th:nth-child(5),
  #tab-orders table thead th:nth-child(6),
  #tab-orders table thead th:nth-child(7),
  #tab-orders table thead th:nth-child(8),
  #tab-orders table thead th:nth-child(9),
  #tab-orders table thead th:nth-child(10),
  #tab-orders table thead th:nth-child(11) {
    display: none;
  }

  /* Pagination mobile styles */
  .orders-pagination {
    flex-direction: column;
    gap: 12px;
    text-align: center;
  }

  .orders-pagination-buttons {
    width: 100%;
    justify-content: center;
  }

  .orders-search-wrapper {
    width: 100%;
  }

  .orders-search-input {
    width: 100%;
  }

  .orders-filter-select {
    width: 100%;
    min-width: unset;
  }

  /* ============================================
     ENGINEERING QUEUE - MOBILE (PD#, Customer, Status)
     ============================================ */

  .eng-metrics-bar {
    flex-wrap: wrap;
    gap: 8px;
  }

  .eng-metric-card {
    flex: 1 1 calc(50% - 4px);
    min-width: 120px;
    padding: 10px 12px;
  }

  .eng-metric-card.eng-all {
    flex: 1 1 100%;
  }

  .eng-metric-count {
    font-size: 16px;
  }

  .eng-metric-card.eng-all .eng-metric-count {
    font-size: 22px;
  }

  /* Engineering timer bar mobile */
  .eng-timer-bar {
    flex-wrap: wrap;
    padding: 12px 16px;
    gap: 12px;
  }

  .eng-timer-bar .timer-elapsed {
    font-size: 20px;
  }

  /* Engineering sub-tabs */
  .eng-sub-tabs {
    gap: 4px;
    padding: 4px;
  }

  .eng-tab-btn {
    padding: 8px 12px;
    font-size: 12px;
    flex: 1;
    text-align: center;
    justify-content: center;
  }

  .eng-tab-btn .count-badge {
    margin-left: 4px;
    min-width: 18px;
    height: 18px;
    font-size: 10px;
  }

  /* Engineering Queue table - show PD#, Customer, Status only */
  .eng-queue-table .col-health,
  .eng-queue-table th:nth-child(1),
  .eng-queue-table td:nth-child(1) {
    display: table-cell;
    width: 32px;
    min-width: 32px;
    padding: 8px 4px 8px 8px;
  }

  .eng-queue-table .col-pd,
  .eng-queue-table th:nth-child(2),
  .eng-queue-table td:nth-child(2) {
    display: table-cell;
  }

  .eng-queue-table .col-customer,
  .eng-queue-table th:nth-child(4),
  .eng-queue-table td:nth-child(4) {
    display: table-cell;
  }

  .eng-queue-table .col-status,
  .eng-queue-table th:nth-child(8),
  .eng-queue-table td:nth-child(8) {
    display: table-cell;
  }

  /* Hide other columns */
  .eng-queue-table th:nth-child(3),
  .eng-queue-table td:nth-child(3),
  .eng-queue-table th:nth-child(5),
  .eng-queue-table td:nth-child(5),
  .eng-queue-table th:nth-child(6),
  .eng-queue-table td:nth-child(6),
  .eng-queue-table th:nth-child(7),
  .eng-queue-table td:nth-child(7),
  .eng-queue-table th:nth-child(9),
  .eng-queue-table td:nth-child(9),
  .eng-queue-table th:nth-child(10),
  .eng-queue-table td:nth-child(10),
  .eng-queue-table th:nth-child(11),
  .eng-queue-table td:nth-child(11) {
    display: none;
  }

  .eng-queue-table th,
  .eng-queue-table td {
    padding: 10px 8px;
    font-size: 12px;
  }

  .eng-queue-table .pd-number {
    font-size: 13px;
  }

  .eng-queue-table .customer-name {
    max-width: 100px;
    font-size: 12px;
  }

  .eng-status-badge {
    font-size: 9px;
    padding: 2px 6px;
  }

  /* ============================================
     MODALS - MOBILE
     ============================================ */

  .modal-content {
    margin: 10px;
    max-height: calc(100vh - 20px);
    width: calc(100% - 20px) !important;
    max-width: none !important;
  }

  .order-modal-redesign {
    width: calc(100% - 20px) !important;
  }

  .order-header-top {
    flex-direction: column;
    gap: 16px;
    padding: 16px 40px 16px 16px;
  }

  .order-header-pd-number {
    font-size: 24px;
  }

  .order-header-customer {
    font-size: 20px;
  }

  .order-header-meta {
    font-size: 13px;
    gap: 12px;
  }

  .order-header-right {
    text-align: left;
  }

  .order-modal-body {
    padding: 16px;
  }

  .order-info-bar {
    flex-direction: column;
    gap: 8px;
  }

  .order-info-chip {
    width: 100%;
  }

  .line-item-card-body {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  /* Engineering modal mobile */
  .eng-detail-modal-redesign {
    width: calc(100% - 20px) !important;
  }

  .eng-modal-header {
    padding: 20px 16px;
  }

  .eng-modal-header-top {
    flex-direction: column;
    gap: 12px;
  }

  .eng-modal-title {
    font-size: 20px;
  }

  .eng-modal-body {
    padding: 16px;
  }

  .eng-info-grid {
    grid-template-columns: 1fr;
  }

  .eng-work-actions {
    flex-direction: column;
  }

  .eng-work-btn {
    width: 100%;
  }

  /* ============================================
     HIDE NON-ESSENTIAL PAGES FROM MOBILE
     ============================================ */

  /* These are hidden via JS - pages only accessible on desktop */

}

/* Small mobile (480px and below) */
@media (max-width: 480px) {
  .header {
    padding: 10px 12px;
  }

  .header-logo {
    width: 80px;
  }

  .container {
    padding: 12px;
  }

  .page-title-bar h1 {
    font-size: 18px;
  }

  /* Health metrics even more compact */
  .health-metric-card {
    padding: 10px;
  }

  .health-metric-count {
    font-size: 16px;
  }

  .health-metric-card.health-all .health-metric-count {
    font-size: 20px;
  }

  /* Quick links single column */
  .quick-links {
    grid-template-columns: 1fr;
  }

  /* Analytics single column */
  .analytics-grid {
    grid-template-columns: 1fr;
  }

  /* Table even more compact */
  .production-table thead th {
    padding: 8px 6px;
    font-size: 9px;
  }

  .production-table tbody td {
    padding: 10px 6px;
    font-size: 12px;
  }

  .customer-name {
    max-width: 80px;
  }

  /* Engineering table compact */
  .eng-queue-table th,
  .eng-queue-table td {
    padding: 8px 6px;
    font-size: 11px;
  }

  .eng-queue-table .customer-name {
    max-width: 70px;
  }

  /* Sub-tabs scrollable */
  .eng-sub-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  .eng-tab-btn {
    flex-shrink: 0;
  }
}

/* ============================================
   TOUCH-FRIENDLY ENHANCEMENTS
   ============================================ */

@media (max-width: 768px) {
  /* Larger touch targets */
  .btn,
  button {
    min-height: var(--touch-target-min);
  }

  /* Table rows touch-friendly */
  .production-table tbody tr,
  .eng-queue-table tbody tr {
    min-height: 48px;
  }

  /* Filter pills larger */
  .location-filter-pill {
    padding: 10px 16px;
    min-height: 44px;
  }

  /* Prevent text selection on interactive elements */
  .mobile-nav-item,
  .mobile-menu-btn,
  .location-filter-pill,
  .health-metric-card,
  .eng-metric-card {
    -webkit-tap-highlight-color: transparent;
    user-select: none;
  }
}

/* ============================================
   PREVENT BODY SCROLL WHEN DRAWER OPEN
   ============================================ */

body.mobile-nav-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
}
