:root {
  --primary: #0d6efd;
  --success: #198754;
  --danger: #dc3545;
  --warning: #ffc107;
  --info: #0dcaf0;
  --purple: #6f42c1;
  --orange: #fd7e14;
  --background: #f8f9fa;
  --border: #dee2e6;
  --text: #212529;
  --card-background: #ffffff;
  --text-color: #1e293b;
  --border-radius: 8px;
  --shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, Cantarell, sans-serif;
}

body {
  background: var(--background);
  color: var(--text);
  line-height: 1.5;
}

.container {
  max-width: 1320px;
  margin: 2rem auto;
  padding: 0 1rem;
}

/* Header Card */
.header-card {
  background: white;
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.title i {
  font-size: 1.5rem;
  color: var(--primary);
}

.title h1 {
  color: var(--primary);
  font-size: 1.5rem;
  font-weight: 600;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 2rem;
}

.quantity-display {
  text-align: right;
}

.quantity-display span {
  color: #6c757d;
  font-size: 0.9rem;
}

.quantity-display h2 {
  color: var(--primary);
  font-size: 2rem;
  margin-top: 0.25rem;
}

/* Controls */
.controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  gap: 1rem;
}

.entries-select select {
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  outline: none;
}

.search-box {
  position: relative;
}

.search-box input {
  padding: 0.5rem 1rem 0.5rem 2.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  width: 250px;
}

.search-box i {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: #6c757d;
}

/* Table */
.table-container {
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  overflow: auto;
  margin-bottom: 1.5rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

th,
td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th {
  background: #f8f9fa;
  font-weight: 500;
  font-size: 0.875rem;
}

td {
  vertical-align: middle;
}

tbody tr:hover {
  background: #f8f9fa;
}

/* Status Badge */
.badge.success {
  background: #d1e7dd;
  color: #0f5132;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
}

/* Action Buttons */
.actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.icon-btn {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 4px;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s;
  font-size: 0.875rem;
}

.icon-btn:hover {
  opacity: 0.9;
}

.icon-btn.primary {
  background: var(--primary);
}
.icon-btn.success {
  background: var(--success);
}
.icon-btn.warning {
  background: var(--warning);
}
.icon-btn.danger {
  background: var(--danger);
}
.icon-btn.info {
  background: var(--info);
}
.icon-btn.purple {
  background: var(--purple);
}
.icon-btn.orange {
  background: var(--orange);
}

/* Export Buttons */
.export-buttons {
  display: flex;
  gap: 0.5rem;
}

.btn {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 4px;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: opacity 0.2s;
}

.btn:hover {
  opacity: 0.9;
}

.btn-primary {
  background: var(--primary);
}
.btn-success {
  background: var(--success);
}
.btn-danger {
  background: var(--danger);
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.page-buttons {
  display: flex;
  gap: 0.5rem;
}

.page-btn {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  background: white;
  border-radius: 4px;
  cursor: pointer;
}

.page-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.page-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Responsive Design */
@media (max-width: 1200px) {
  .header-card {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
  }

  .header-right {
    flex-direction: column;
    gap: 1rem;
  }
}

@media (max-width: 992px) {
  .controls {
    flex-direction: column;
    align-items: stretch;
  }

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

  .export-buttons {
    justify-content: center;
  }
}

@media (max-width: 768px) {
  .container {
    margin: 1rem auto;
  }

  .actions {
    justify-content: center;
  }

  .pagination {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
  }
}

@media (max-width: 576px) {
  .header-card {
    padding: 1rem;
  }

  .title h1 {
    font-size: 1.25rem;
  }

  .export-buttons {
    flex-direction: column;
    width: 100%;
  }

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

  .icon-btn {
    width: 40px;
    height: 40px;
  }
}

/* Table Scroll Handling */
@media (max-width: 1400px) {
  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table {
    min-width: 1200px;
  }
}

/* Print Styles */
@media print {
  .container {
    margin: 0;
    padding: 0;
  }

  .header-card,
  .controls,
  .actions,
  .pagination {
    display: none;
  }

  .table-container {
    box-shadow: none;
  }

  table {
    border: 1px solid #000;
  }

  th,
  td {
    border: 1px solid #000;
  }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
  :root {
    --background: #1a1a1a;
    --card-background: #2d2d2d;
    --text: #ffffff;
  }

  .stock-table th {
    background: #333;
  }

  .stock-table tbody tr:hover {
    background: #333;
  }

  .search-box input,
  .entries-select {
    background: var(--card-background);
    color: var(--text);
    border-color: #404040;
  }

  .page-btn {
    background: var(--card-background);
    color: var(--text);
    border-color: #404040;
  }

  .status-badge.success {
    background: #1a4731;
  }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
  :root {
    --primary: #0000ff;
    --success: #008000;
    --warning: #ff8c00;
    --danger: #ff0000;
  }

  .stock-table th,
  .stock-table td {
    border: 2px solid #000;
  }

  .btn,
  .action-btn {
    border: 2px solid #000;
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

/* Landscape Mode */
@media screen and (max-height: 500px) and (orientation: landscape) {
  .dashboard-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--card-background);
  }

  .table-container {
    height: calc(100vh - 200px);
    overflow-y: auto;
  }
}

/* Additional Responsive Table Handling */
.table-container {
  position: relative;
}

@media screen and (max-width: 1024px) {
  .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -1rem;
    padding: 0 1rem;
  }

  .stock-table {
    min-width: 900px;
  }

  /* Sticky first column */
  .stock-table th:first-child,
  .stock-table td:first-child {
    position: sticky;
    left: 0;
    background: var(--card-background);
    z-index: 10;
  }
}

/* Loading States */
.loading {
  opacity: 0.7;
  pointer-events: none;
}

/* Touch Device Optimizations */
@media (hover: none) {
  .btn:active,
  .action-btn:active {
    opacity: 0.7;
  }

  .stock-table tbody tr:active {
    background: #f0f0f0;
  }
}
