* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  /* Smooth scrolling for better UX */
  scroll-behavior: smooth;
  /* Prevent text size adjustment on orientation change */
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: #f5f5f5;
  color: #333;
  /* Better touch scrolling on iOS */
  -webkit-overflow-scrolling: touch;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

header {
  background: white;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  margin-bottom: 20px;
}

h1 {
  margin-bottom: 15px;
  color: #2c3e50;
}

nav {
  display: flex;
  gap: 10px;
}

.nav-btn {
  padding: 10px 20px;
  border: none;
  background: #ecf0f1;
  border-radius: 5px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.3s;
}

.nav-btn:hover {
  background: #bdc3c7;
}

.nav-btn.active {
  background: #3498db;
  color: white;
}

.view {
  display: none;
  background: white;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.view.active {
  display: block;
}

.controls {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

input[type="text"],
input[type="number"],
select {
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 5px;
  font-size: 14px;
  flex: 1;
  min-width: 200px;
}

select {
  cursor: pointer;
  background: white;
}

button {
  padding: 10px 20px;
  border: none;
  background: #3498db;
  color: white;
  border-radius: 5px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.3s;
  /* Minimum touch target size for accessibility */
  min-height: 44px;
  /* Prevent text selection on double-tap */
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

button:hover {
  background: #2980b9;
}

button.btn-secondary {
  background: #95a5a6;
}

button.btn-secondary:hover {
  background: #7f8c8d;
}

button.btn-danger {
  background: #e74c3c;
}

button.btn-danger:hover {
  background: #c0392b;
}

button.btn-primary {
  background: #27ae60;
}

button.btn-primary:hover {
  background: #229954;
}

.table-container {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

thead {
  background: #34495e;
  color: white;
  position: sticky;
  top: 0;
}

th {
  padding: 12px;
  text-align: left;
  font-weight: 600;
}

th.sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
}

th.sortable:hover {
  text-decoration: underline;
}

.sort-icon {
  display: inline-block;
  width: 12px;
  font-size: 10px;
  color: #95a5a6;
  margin-left: 5px;
}

.sort-icon.active {
  color: #fff;
  font-weight: bold;
}

td {
  padding: 10px 12px;
  border-bottom: 1px solid #ecf0f1;
}

tbody tr:hover {
  background: #f8f9fa;
}

.product-image {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 4px;
  cursor: pointer;
  transition: transform 0.2s;
}

.product-image:hover {
  transform: scale(1.1);
}

.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  overflow: auto;
}

.modal.active {
  display: block;
}

.modal-content {
  background: white;
  margin: 50px auto;
  padding: 30px;
  border-radius: 8px;
  max-width: 800px;
  position: relative;
}

.image-modal-content {
  max-width: 90%;
  max-height: 90%;
  padding: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
}

#zoomed-image {
  max-width: 100%;
  max-height: 80vh;
  border-radius: 8px;
}

.close {
  position: absolute;
  right: 15px;
  top: 15px;
  font-size: 28px;
  font-weight: bold;
  color: #aaa;
  cursor: pointer;
  z-index: 1001;
}

.close:hover {
  color: #000;
}

.product-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.detail-section {
  background: #f8f9fa;
  padding: 15px;
  border-radius: 5px;
}

.detail-section h3 {
  margin-bottom: 10px;
  color: #2c3e50;
  font-size: 16px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  border-bottom: 1px solid #ddd;
}

.detail-row:last-child {
  border-bottom: none;
}

.detail-label {
  font-weight: 600;
  color: #7f8c8d;
}

/* Transaction Table Styles */
.transaction-section {
  background: #ffffff;
  padding: 20px;
  border-radius: 8px;
  border: 1px solid #dee2e6;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.transaction-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  font-size: 14px;
}

.transaction-table thead {
  background: #f8f9fa;
  border-bottom: 2px solid #dee2e6;
}

.transaction-table th {
  padding: 12px 10px;
  text-align: left;
  font-weight: 600;
  color: #495057;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.transaction-table tbody tr {
  transition: background 0.2s;
}

.transaction-table tbody tr:hover {
  background: #f8f9fa;
}

.transaction-table .badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.transaction-table .badge-success {
  background: #d4edda;
  color: #155724;
}

.transaction-table .badge-warning {
  background: #fff3cd;
  color: #856404;
}

.transaction-table .badge-secondary {
  background: #e2e3e5;
  color: #383d41;
}


.shelves-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 15px;
}

.shelf-card {
  background: #ecf0f1;
  padding: 20px;
  border-radius: 8px;
  text-align: center;
  position: relative;
}

.shelf-card h3 {
  margin-bottom: 10px;
  color: #2c3e50;
}

.shelf-card button {
  margin-top: 10px;
  padding: 5px 15px;
  font-size: 12px;
}

.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.badge-success {
  background: #d4edda;
  color: #155724;
}

.badge-warning {
  background: #fff3cd;
  color: #856404;
}

.badge-danger {
  background: #f8d7da;
  color: #721c24;
}

.locations-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.location-tag {
  background: #3498db;
  color: white;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.location-tag-remove {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.75);
  padding: 0;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  transition: color 0.15s;
}

.location-tag-remove:hover {
  color: white;
}

.search-results {
  margin-bottom: 20px;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 5px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: all 0.2s;
}

.search-result-item:hover {
  background: #f8f9fa;
  border-color: #3498db;
}

.search-result-item img {
  width: 50px;
  height: 50px;
  object-fit: cover;
  border-radius: 4px;
}

.search-result-info {
  flex: 1;
}

.search-result-info h4 {
  margin-bottom: 5px;
}

.search-result-info p {
  color: #7f8c8d;
  font-size: 12px;
}

.print-queue {
  border: 2px dashed #ddd;
  border-radius: 8px;
  padding: 20px;
  min-height: 200px;
  margin-bottom: 20px;
}

.print-queue-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px;
  background: #f8f9fa;
  border-radius: 5px;
  margin-bottom: 10px;
}

.print-queue-item-info {
  display: flex;
  align-items: center;
  gap: 15px;
  flex: 1;
}

.print-queue-item img {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 4px;
}

.print-queue-item-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.print-queue-item-controls input {
  width: 60px;
  min-width: 60px;
}

.empty-message {
  text-align: center;
  color: #95a5a6;
  padding: 40px;
}

.loading {
  text-align: center;
  padding: 40px;
  color: #95a5a6;
}

.location-editor {
  margin-top: 20px;
}

.location-editor input {
  margin-bottom: 10px;
}

.location-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 10px;
}

.location-tag-edit {
  background: #3498db;
  color: white;
  padding: 5px 10px;
  border-radius: 12px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.location-tag-edit button {
  background: none;
  border: none;
  color: white;
  padding: 0;
  font-size: 16px;
  cursor: pointer;
}

.pagination-info {
  text-align: center;
  padding: 15px;
  color: #7f8c8d;
  font-size: 14px;
  background: #f8f9fa;
  border-radius: 5px;
  margin: 10px 0;
}

.pagination-controls {
  display: flex;
  justify-content: center;
  padding: 20px 0;
  margin-top: 10px;
}

.pagination-buttons {
  display: flex;
  gap: 5px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
}

.pagination-buttons button {
  min-width: 40px;
  padding: 8px 12px;
  border: 1px solid #ddd;
  background: white;
  color: #333;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.pagination-buttons button:hover:not(:disabled) {
  background: #3498db;
  color: white;
  border-color: #3498db;
}

.pagination-buttons button.active {
  background: #3498db;
  color: white;
  border-color: #3498db;
  font-weight: bold;
}

.pagination-buttons button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: #ecf0f1;
}

.pagination-ellipsis {
  padding: 8px 5px;
  color: #95a5a6;
}

/* Sales Analytics Styles */
.chart-view-btn {
  padding: 8px 16px;
  border: 1px solid #ddd;
  background: white;
  color: #555;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
  white-space: nowrap;
}

.chart-view-btn:hover {
  background: #f8f9fa;
  border-color: #3498db;
}

.chart-view-btn.active {
  background: #3498db;
  color: white;
  border-color: #3498db;
}

.insight-card {
  background: white;
  border-left: 4px solid #3498db;
  padding: 15px;
  margin-bottom: 12px;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.insight-card.insight-success {
  border-left-color: #2ecc71;
  background: #f0fdf4;
}

.insight-card.insight-warning {
  border-left-color: #f39c12;
  background: #fffbeb;
}

.insight-card.insight-danger {
  border-left-color: #e74c3c;
  background: #fef2f2;
}

.insight-card.insight-info {
  border-left-color: #3498db;
  background: #f0f9ff;
}

.insight-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  color: #2c3e50;
  font-size: 15px;
}

.insight-icon {
  font-size: 20px;
}

.insight-message {
  color: #555;
  font-size: 14px;
  line-height: 1.5;
  margin: 0;
}

/* Mobile Responsive Styles */
@media (max-width: 768px) {
  .container {
    padding: 10px;
  }
  
  header {
    padding: 15px;
  }
  
  h1 {
    font-size: 20px;
  }
  
  /* Stack navigation vertically on mobile */
  nav {
    flex-direction: column;
    gap: 8px;
  }
  
  .nav-btn {
    width: 100%;
    padding: 12px;
    font-size: 16px;
  }
  
  .view {
    padding: 15px;
  }
  
  /* Make controls full width and stack */
  .controls {
    flex-direction: column;
    gap: 10px;
  }
  
  .controls label {
    margin-left: 0 !important;
  }
  
  input[type="text"],
  input[type="number"] {
    min-width: 100%;
    width: 100%;
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 12px;
  }
  
  select {
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 12px;
    min-width: auto;
    width: auto;
    flex: 1;
  }
  
  button {
    width: 100%;
    padding: 12px;
    font-size: 16px;
  }
  
  /* Table responsive - enable horizontal scrolling */
  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -15px;
    padding: 0 15px;
  }
  
  table {
    font-size: 12px;
    min-width: 900px; /* Ensures table doesn't collapse too much */
  }
  
  th, td {
    padding: 8px 6px;
  }
  
  .product-image {
    width: 50px;
    height: 50px;
  }
  
  /* Touch-friendly badges */
  .badge {
    padding: 6px 10px;
    font-size: 12px;
  }
  
  .location-tag {
    padding: 4px 8px;
    font-size: 11px;
  }
  
  /* Modal adjustments for mobile */
  .modal-content {
    margin: 20px auto;
    padding: 20px;
    max-width: 95%;
    max-height: 85vh;
    overflow-y: auto;
  }
  
  .image-modal-content {
    margin: 10px;
    padding: 10px;
  }
  
  #zoomed-image {
    max-height: 70vh;
  }
  
  .close {
    font-size: 36px;
    right: 10px;
    top: 10px;
    background: rgba(255,255,255,0.9);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
  }
  
  /* Product detail grid - single column on mobile */
  .product-detail-grid {
    grid-template-columns: 1fr;
    gap: 15px;
  }
  
  .detail-section {
    padding: 12px;
  }
  
  .detail-section h3 {
    font-size: 14px;
  }
  
  .detail-row {
    flex-direction: column;
    gap: 5px;
    padding: 8px 0;
  }
  
  .detail-label {
    font-size: 12px;
  }
  
  /* Location editor touch-friendly */
  .location-editor {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  
  .location-editor input {
    width: 100%;
  }
  
  .location-editor button {
    width: 100%;
  }
  
  /* Sales analytics on mobile */
  .chart-view-btn {
    padding: 8px 12px;
    font-size: 12px;
    flex: 1;
    min-width: 100px;
  }
  
  #sales-chart-container {
    height: 250px !important;
    margin: 15px 0;
  }
  
  .insight-card {
    padding: 12px;
    margin-bottom: 10px;
  }
  
  .insight-header {
    font-size: 14px;
  }
  
  .insight-icon {
    font-size: 18px;
  }
  
  .insight-message {
    font-size: 13px;
  }
  
  /* Shelves grid - 2 columns on mobile */
  .shelves-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  
  .shelf-card {
    padding: 15px;
  }
  
  .shelf-card h3 {
    font-size: 14px;
  }
  
  /* Pagination touch-friendly */
  .pagination-buttons {
    flex-wrap: wrap;
    justify-content: center;
  }
  
  .pagination-buttons button {
    min-width: 44px; /* iOS touch target size */
    min-height: 44px;
    padding: 10px;
  }
  
  #pagination-info p {
    font-size: 13px;
    text-align: center;
  }
  
  /* Print queue on mobile */
  .queue-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  
  .queue-item {
    padding: 12px;
  }
}

/* Extra small phones */
@media (max-width: 480px) {
  h1 {
    font-size: 18px;
  }
  
  .shelves-grid {
    grid-template-columns: 1fr;
  }
  
  table {
    font-size: 11px;
  }
  
  th, td {
    padding: 6px 4px;
  }
  
  .product-image {
    width: 40px;
    height: 40px;
  }
  
  .pagination-buttons button {
    min-width: 38px;
    font-size: 13px;
    padding: 8px;
  }
}

/* User Info Styles */
.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 15px;
  background: #f8f9fa;
  border-radius: 5px;
}

.user-name {
  font-size: 14px;
  color: #495057;
  font-weight: 500;
}

.logout-btn {
  padding: 6px 12px;
  background: #dc3545;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.3s;
}

.logout-btn:hover {
  background: #c82333;
}

/* Print Label Dialog */
.preset-btn {
  padding: 10px 20px;
  border: 2px solid #007bff;
  background: white;
  color: #007bff;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s;
}

.preset-btn:hover {
  background: #007bff;
  color: white;
}

.preset-btn:active {
  transform: scale(0.95);
}

.btn-primary {
  background: #007bff;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.3s;
}

.btn-primary:hover {
  background: #0056b3;
}

.btn-secondary {
  background: #6c757d;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.3s;
}

.btn-secondary:hover {
  background: #545b62;
}
