/* Desktop Table Styles */
.responsive-table-desktop {
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  box-sizing: border-box;
}

.responsive-table {
  width: 100%;
  border-collapse: collapse;
  background-color: var(--bg-primary);
  border-radius: var(--border-radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  table-layout: fixed;
  word-wrap: break-word;
}

.responsive-table thead {
  background-color: var(--bg-secondary);
}

.responsive-table.sticky-header thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

.responsive-table th {
  padding: var(--spacing-md);
  text-align: left;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 2px solid var(--border-color);
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.responsive-table td {
  padding: var(--spacing-md);
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
  word-break: break-word;
}

.responsive-table tbody tr:hover {
  background-color: var(--bg-secondary);
  transition: background-color var(--transition-fast);
}

.responsive-table tbody tr:last-child td {
  border-bottom: none;
}

/* Mobile Card Styles */
.responsive-table-mobile {
  display: none;
}

.mobile-card {
  background-color: var(--bg-primary);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--spacing-md);
  overflow: hidden;
  transition: box-shadow var(--transition-fast);
}

.mobile-card:hover {
  box-shadow: var(--shadow-md);
}

.mobile-card-header {
  padding: var(--spacing-md);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--spacing-sm);
}

.mobile-card-header:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: -2px;
}

.mobile-card-summary {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
}

.mobile-expand-button {
  background: none;
  border: none;
  color: var(--primary-color);
  font-size: 1.25rem;
  padding: var(--spacing-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background-color var(--transition-fast);
}

.mobile-expand-button:hover {
  background-color: var(--bg-secondary);
}

.mobile-card-details {
  padding: 0 var(--spacing-md) var(--spacing-md);
  border-top: 1px solid var(--border-color);
  margin-top: var(--spacing-sm);
  padding-top: var(--spacing-md);
  animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.mobile-row-field {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-xs) 0;
  gap: var(--spacing-sm);
}

.mobile-field-label {
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.875rem;
  flex-shrink: 0;
}

.mobile-field-value {
  color: var(--text-primary);
  text-align: right;
  flex: 1;
}

/* Empty State */
.responsive-table-empty {
  text-align: center;
  padding: var(--spacing-xl);
  color: var(--text-secondary);
  background-color: var(--bg-primary);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
}

/* Responsive Breakpoint */
@media (max-width: 768px) {
  .responsive-table-desktop {
    display: none;
  }

  .responsive-table-mobile {
    display: block;
  }
}

/* Ultra-small devices (<=400px) harden overflow prevention */
@media (max-width: 400px) {
  .responsive-table-desktop,
  .responsive-table,
  .responsive-table * {
    max-width: 100%;
    box-sizing: border-box;
    min-width: 0;
  }
}

/* Tablet adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
  .responsive-table th,
  .responsive-table td {
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: 0.875rem;
  }
}

/* Custom scrollbar for desktop table */
.responsive-table-desktop::-webkit-scrollbar {
  height: 8px;
}

.responsive-table-desktop::-webkit-scrollbar-track {
  background: var(--bg-secondary);
  border-radius: 4px;
}

.responsive-table-desktop::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

.responsive-table-desktop::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}