/* ============================================
   MACHINES LIST - COMPLETE STYLES WITH DROPDOWN FIXES
   ============================================ */

/* ============================================
   CRITICAL RESPONSIVE FIXES
   ============================================ */

.grid.min-w-max {
  min-width: 0 !important;
  width: 100%;
}

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

.flex.flex-auto.flex-col {
  min-width: 0;
}

/* ============================================
   DROPDOWN (MAT-SELECT) FIXES - CRITICAL
   ============================================ */

/* Base mat-select styling */
.mat-mdc-form-field mat-select {
  width: 100%;
  display: block;
}

/* Dropdown trigger */
::ng-deep .mat-mdc-select-trigger {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 40px;
}

/* Selected value display */
::ng-deep .mat-mdc-select-value {
  width: 100%;
  max-width: 100%;
}

::ng-deep .mat-mdc-select-value-text {
  display: block;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Dropdown arrow */
::ng-deep .mat-mdc-select-arrow-wrapper {
  height: 24px;
  display: flex;
  align-items: center;
  padding-left: 8px;
}

::ng-deep .mat-mdc-select-arrow {
  transition: transform 0.2s ease;
  color: rgba(0, 0, 0, 0.54);
}

.dark ::ng-deep .mat-mdc-select-arrow {
  color: rgba(255, 255, 255, 0.54);
}

::ng-deep .mat-mdc-select.mat-mdc-select-panel-open .mat-mdc-select-arrow {
  transform: rotate(180deg);
}

/* Dropdown panel */
::ng-deep .mat-mdc-select-panel {
  min-width: 100% !important;
  max-width: 400px;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  margin-top: 8px;
}

.dark ::ng-deep .mat-mdc-select-panel {
  background-color: #2d3748;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

/* Dropdown options */
::ng-deep .mat-mdc-option {
  padding: 12px 16px;
  min-height: 48px;
  line-height: 1.5;
  transition: background-color 0.15s ease;
}

::ng-deep .mat-mdc-option:hover {
  background-color: rgba(0, 0, 0, 0.04);
}

.dark ::ng-deep .mat-mdc-option:hover {
  background-color: rgba(255, 255, 255, 0.08);
}

::ng-deep .mat-mdc-option.mat-mdc-option-active,
::ng-deep .mat-mdc-option.mdc-list-item--selected {
  background-color: rgba(25, 118, 210, 0.12);
  font-weight: 500;
}

.dark ::ng-deep .mat-mdc-option.mat-mdc-option-active,
.dark ::ng-deep .mat-mdc-option.mdc-list-item--selected {
  background-color: rgba(96, 165, 250, 0.2);
}

/* Placeholder styling */
::ng-deep .mat-mdc-select-placeholder {
  color: rgba(0, 0, 0, 0.42);
}

.dark ::ng-deep .mat-mdc-select-placeholder {
  color: rgba(255, 255, 255, 0.42);
}

/* ============================================
   FORM FIELD LAYOUT
   ============================================ */

/* Form container */
.flex.flex-col.p-8.sm\:flex-row {
  padding: 32px;
}

.flex.flex-auto.flex-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  width: 100%;
}

/* Form field base styling */
.mat-mdc-form-field {
  width: 100%;
  display: block;
}

/* Two-column layout on desktop */
.mat-mdc-form-field.w-full.sm\:w-1\/2 {
  width: 100%;
  margin-bottom: 16px;
}

@media (min-width: 640px) {
  .mat-mdc-form-field.w-full.sm\:w-1\/2 {
    width: calc(50% - 8px);
  }
  
  .mat-mdc-form-field.w-full.sm\:w-1\/2.pr-2 {
    margin-right: 16px;
  }
  
  .mat-mdc-form-field.w-full.sm\:w-1\/2.pl-2 {
    margin-left: 0;
  }
}

/* Form field internals */
::ng-deep .mat-mdc-form-field-infix {
  display: flex;
  align-items: center;
  min-height: 56px;
  padding-top: 16px;
  padding-bottom: 16px;
}

::ng-deep .mat-mdc-text-field-wrapper {
  padding: 0;
  padding-bottom: 0;
}

::ng-deep .mat-mdc-form-field-flex {
  align-items: center;
}

::ng-deep .mat-mdc-form-field-subscript-wrapper {
  margin-top: 6px;
}

::ng-deep .mat-mdc-form-field-appearance-outline .mat-mdc-form-field-outline {
  border-radius: 8px;
}

/* ============================================
   INVENTORY GRID - BASE LAYOUT
   ============================================ */

.inventory-grid {
  display: grid;
  align-items: center;
  width: 100%;
  padding: 16px 24px;
  gap: 16px;
}

.inventory-grid > div {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Desktop - All 11 columns */
@media (min-width: 1400px) {
  .inventory-grid {
    grid-template-columns: 
      60px 140px 180px 140px 180px 180px 150px 150px 150px 150px 200px;
  }
}

/* Large Laptop */
@media (min-width: 1024px) and (max-width: 1399px) {
  .inventory-grid {
    grid-template-columns: 
      50px 120px 150px 110px 140px 140px 130px 130px 120px 130px 170px;
    padding: 12px 20px;
  }
}

/* Tablet Landscape */
@media (min-width: 768px) and (max-width: 1023px) {
  .inventory-grid {
    grid-template-columns: 
      50px 120px 150px minmax(120px, 1fr) 130px 120px 160px;
    padding: 12px 16px;
  }
  
  .inventory-grid > div:nth-child(4),
  .inventory-grid > div:nth-child(8),
  .inventory-grid > div:nth-child(9),
  .inventory-grid > div:nth-child(10) {
    display: none !important;
  }
}

/* Tablet Portrait */
@media (min-width: 576px) and (max-width: 767px) {
  .inventory-grid {
    grid-template-columns: 45px minmax(100px, 1fr) 140px 180px;
    padding: 12px 16px;
  }
  
  .inventory-grid > div:nth-child(4),
  .inventory-grid > div:nth-child(5),
  .inventory-grid > div:nth-child(6),
  .inventory-grid > div:nth-child(7),
  .inventory-grid > div:nth-child(8),
  .inventory-grid > div:nth-child(9),
  .inventory-grid > div:nth-child(10) {
    display: none !important;
  }
  
  .inventory-grid .flex.gap-2 {
    flex-direction: row;
    gap: 8px;
  }
  
  .inventory-grid button {
    padding: 6px 12px;
    font-size: 13px;
    min-height: 36px;
  }
}

/* Mobile */
@media (max-width: 575px) {
  .inventory-grid {
    grid-template-columns: 40px minmax(80px, 1fr) 130px;
    padding: 12px 12px;
    gap: 12px;
    font-size: 13px;
  }
  
  .inventory-grid > div:nth-child(3),
  .inventory-grid > div:nth-child(4),
  .inventory-grid > div:nth-child(5),
  .inventory-grid > div:nth-child(6),
  .inventory-grid > div:nth-child(7),
  .inventory-grid > div:nth-child(8),
  .inventory-grid > div:nth-child(9),
  .inventory-grid > div:nth-child(10) {
    display: none !important;
  }
  
  .inventory-grid .flex.gap-2 {
    flex-direction: column;
    gap: 8px;
    width: 100%;
  }
  
  .inventory-grid button {
    width: 100%;
    font-size: 12px;
    padding: 8px 6px;
    min-height: 40px;
    min-width: auto !important;
  }
}

/* ============================================
   HEADER ROW STYLING
   ============================================ */

.inventory-grid.text-secondary {
  background: #f9fafb;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 14px;
  border-bottom: 2px solid #e5e7eb;
  position: sticky;
  top: 0;
  z-index: 10;
}

.dark .inventory-grid.text-secondary {
  background: rgba(0, 0, 0, 0.05);
  border-bottom-color: rgba(255, 255, 255, 0.1);
}

/* ============================================
   DATA ROW STYLING
   ============================================ */

.inventory-grid:not(.text-secondary) {
  transition: background-color 0.2s ease;
  border-bottom: 1px solid #e5e7eb;
}

.inventory-grid:not(.text-secondary):hover {
  background-color: #f8f9fa;
}

.dark .inventory-grid:not(.text-secondary) {
  border-bottom-color: rgba(255, 255, 255, 0.05);
}

.dark .inventory-grid:not(.text-secondary):hover {
  background-color: rgba(255, 255, 255, 0.05);
}

.inventory-grid > div:last-child {
  white-space: normal;
}

/* ============================================
   CREATED BY COLUMN
   ============================================ */

.inventory-grid > div:nth-child(10) {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inventory-grid > div:nth-child(10) mat-icon {
  color: #6b7280;
  font-size: 18px;
  width: 18px;
  height: 18px;
}

.inventory-grid > div:nth-child(10) span {
  font-size: 14px;
  color: #374151;
}

.dark .inventory-grid > div:nth-child(10) mat-icon {
  color: #9ca3af;
}

.dark .inventory-grid > div:nth-child(10) span {
  color: #d1d5db;
}

/* ============================================
   HEADER SECTION
   ============================================ */

.relative.flex.flex-0.flex-col.border-b {
  padding: 24px 32px;
}

@media (max-width: 767px) {
  .relative.flex.flex-0.flex-col.border-b {
    padding: 20px 16px;
  }
  
  .text-4xl.font-extrabold.tracking-tight {
    font-size: 1.875rem;
    line-height: 2.25rem;
  }
  
  .mt-6.flex.shrink-0.items-center {
    flex-direction: column;
    align-items: stretch !important;
    width: 100%;
    margin-top: 16px !important;
    gap: 12px;
  }
  
  mat-form-field.fuse-mat-dense.fuse-mat-rounded.min-w-64 {
    min-width: 0 !important;
    width: 100%;
  }
  
  .mt-6.flex.shrink-0.items-center > button.ml-4 {
    margin-left: 0 !important;
    width: 100%;
    min-height: 48px;
  }
}

/* ============================================
   FORM FOOTER BUTTONS
   ============================================ */

.flex.w-full.items-center.justify-between.border-t {
  padding: 20px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  border-top: 1px solid #e5e7eb;
}

.flex.w-full.items-center.justify-between.border-t > button.-ml-4 {
  margin-left: 0 !important;
  min-height: 44px;
  padding: 0 24px;
  transition: all 0.2s ease;
}

.flex.w-full.items-center.justify-between.border-t > button.-ml-4:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(220, 38, 38, 0.3);
}

.flex.w-full.items-center.justify-between.border-t > .flex.items-center {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.flex.w-full.items-center.justify-between.border-t button[color="primary"] {
  min-height: 44px;
  padding: 0 32px;
  transition: all 0.2s ease;
}

.flex.w-full.items-center.justify-between.border-t button[color="primary"]:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(25, 118, 210, 0.3);
}

@media (max-width: 767px) {
  .flex.w-full.items-center.justify-between.border-t {
    flex-direction: column;
    align-items: stretch !important;
    padding: 20px 24px;
    gap: 16px;
  }
  
  .flex.w-full.items-center.justify-between.border-t > button.-ml-4 {
    width: 100%;
    order: 2;
    min-height: 48px;
  }
  
  .flex.w-full.items-center.justify-between.border-t > div:empty {
    display: none;
  }
  
  .flex.w-full.items-center.justify-between.border-t > .flex.items-center {
    width: 100%;
    order: 1;
    flex-direction: column;
    gap: 12px;
  }
  
  .flex.w-full.items-center.justify-between.border-t .mr-4.flex.items-center {
    margin-right: 0 !important;
    width: 100%;
    justify-content: center;
  }
  
  .flex.w-full.items-center.justify-between.border-t button[color="primary"] {
    width: 100%;
    min-height: 48px;
    font-size: 15px;
  }
  
  .mat-mdc-form-field.w-full.sm\:w-1\/2 {
    width: 100% !important;
    padding: 0 !important;
    margin: 0 0 16px 0 !important;
  }
  
  .mat-mdc-form-field.w-full.sm\:w-1\/2.pr-2,
  .mat-mdc-form-field.w-full.sm\:w-1\/2.pl-2 {
    padding: 0 !important;
    margin: 0 0 16px 0 !important;
  }
  
  ::ng-deep .mat-mdc-select-panel {
    max-width: calc(100vw - 32px);
  }
}

/* ============================================
   FLASH MESSAGES
   ============================================ */

.mr-4.flex.items-center {
  transition: opacity 0.3s ease;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
}

.mr-4.flex.items-center mat-icon {
  margin-right: 8px;
}

.mr-4.flex.items-center:has(mat-icon.text-green-500) {
  background-color: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.mr-4.flex.items-center:has(mat-icon.text-red-500) {
  background-color: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.dark .mr-4.flex.items-center:has(mat-icon.text-green-500) {
  background-color: rgba(72, 187, 120, 0.2);
  color: #68d391;
  border-color: rgba(72, 187, 120, 0.3);
}

.dark .mr-4.flex.items-center:has(mat-icon.text-red-500) {
  background-color: rgba(245, 101, 101, 0.2);
  color: #fc8181;
  border-color: rgba(245, 101, 101, 0.3);
}

/* ============================================
   PASSWORD FIELD
   ============================================ */

.flex.items-center.gap-1 {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 100px;
}

.flex.items-center.gap-1 span {
  font-family: 'Courier New', monospace;
  font-size: 14px;
}

.flex.items-center.gap-1 button {
  padding: 6px;
  min-width: auto;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.flex.items-center.gap-1 button:hover {
  background-color: rgba(0, 0, 0, 0.04);
}

.dark .flex.items-center.gap-1 button:hover {
  background-color: rgba(255, 255, 255, 0.08);
}

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

.inventory-grid .flex.gap-2 button {
  transition: all 0.2s ease;
  border-radius: 6px;
}

.inventory-grid .flex.gap-2 button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* ============================================
   PAGINATOR
   ============================================ */

mat-paginator {
  border-top: 1px solid #e5e7eb;
  border-radius: 8px;
}

@media (max-width: 767px) {
  mat-paginator {
    font-size: 13px;
  }
  
  .mat-mdc-paginator-container {
    padding: 12px !important;
    flex-wrap: wrap;
    gap: 12px;
  }
}

/* ============================================
   EXPANDED FORM
   ============================================ */

.overflow-hidden.shadow-lg {
  margin: 0;
  border-radius: 8px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

@media (max-width: 575px) {
  .flex.flex-col.p-8.sm\:flex-row {
    padding: 20px;
  }
  
  ::ng-deep .mat-mdc-form-field-infix {
    min-height: 52px;
  }
  
  ::ng-deep .mat-mdc-option {
    padding: 10px 12px;
    min-height: 44px;
    font-size: 14px;
  }
}

/* ============================================
   EMPTY STATE
   ============================================ */

.border-t.p-8.text-center {
  padding: 60px 32px;
  text-align: center;
  color: #6c757d;
}

/* ============================================
   DARK MODE
   ============================================ */

.dark .flex.border-b,
.dark .border-b,
.dark .border-t {
  border-color: rgba(255, 255, 255, 0.1);
}

.dark .overflow-hidden.shadow-lg {
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

/* ============================================
   FOCUS STATES
   ============================================ */

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
  border-radius: 6px;
}

::ng-deep .mat-mdc-select:focus {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

/* ============================================
   CLIENT VIEW NOTICE
   ============================================ */

p.mt-2.text-sm.text-gray-600 {
  padding: 8px 16px;
  background-color: #fef3c7;
  border-left: 4px solid #f59e0b;
  border-radius: 4px;
  margin-top: 12px;
}

.dark p.mt-2.text-sm.text-gray-600 {
  background-color: rgba(251, 191, 36, 0.1);
  border-left-color: #fbbf24;
  color: #fcd34d;
}