/**
 * React Power Table - Main Styles
 * Root CSS file that imports all component-specific styles
 */

/* 
 * Base styling reset and core styling for the library
 * These styles provide the foundation for all components
 */
/* Import core styling components - this is managed through the styles.ts entry point:
 * - theme.css - Core variables and theming utilities
 * - table.css - Main table structure and layout
 * - toolbar.css - Table toolbar and action buttons
 * - pagination.css - Pagination controls
 * - actions.css - Row action buttons styling
 * - button.css - Button components
 * - dialog.css - Modal dialogs for CRUD operations
 * - form-components.css - Form elements for filtering and editing
 * - column-visibility.css - Column visibility toggle controls
 * - checkbox.css - Custom checkbox styling
 * - loading.css - Loading spinner components
 * - loading-state.css - Loading state overlays and animations
 */

.rpt-container *,
.rpt-container *::before,
.rpt-container *::after {
  box-sizing: border-box;
}

.rpt-container {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue',
    Arial, sans-serif;
  color: var(--rpt-text-color);
  line-height: 1.5;
  width: 100%;
  position: relative;
  background-color: var(--rpt-bg-color, #ffffff);
  border-radius: var(--rpt-border-radius); /* Added border-radius variable */
  min-width: 280px; /* Base minimum width for small devices */
  overflow-x: auto; /* Enable horizontal scrolling at container level */
  -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
  scrollbar-width: thin;
  scrollbar-color: var(--rpt-scrollbar-thumb-color) var(--rpt-scrollbar-bg);
  transition: var(--rpt-scrollbar-transition);
}

.rpt-container:hover {
  scrollbar-width: auto;
  scrollbar-color: var(--rpt-scrollbar-thumb-hover-color) var(--rpt-scrollbar-bg);
}

.rpt-container::-webkit-scrollbar {
  width: var(--rpt-scrollbar-width);
  height: var(--rpt-scrollbar-width);
  background-color: var(--rpt-scrollbar-bg);
  transition: var(--rpt-scrollbar-transition);
}

.rpt-container:hover::-webkit-scrollbar {
  width: var(--rpt-scrollbar-hover-width);
  height: var(--rpt-scrollbar-hover-width);
}

.rpt-container::-webkit-scrollbar-track {
  background: var(--rpt-scrollbar-bg);
  border-radius: 10px;
}

.rpt-container::-webkit-scrollbar-thumb {
  background: var(--rpt-scrollbar-thumb-color);
  border-radius: 10px;
  transition: var(--rpt-scrollbar-transition);
}

.rpt-container::-webkit-scrollbar-thumb:hover {
  background: var(--rpt-scrollbar-thumb-hover-color);
}

/* Responsive image */
.rpt-container img {
  max-width: 100%;
  height: auto;
}

/* Visually hidden but accessible content */
.rpt-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Assistive text for screen readers */
.rpt-visually-hidden {
  position: absolute;
  overflow: hidden;
  clip: rect(0 0 0 0);
  height: 1px;
  width: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
}

/* Common transitions */
.rpt-transition {
  transition-property: background-color, border-color, color, fill, stroke, opacity, box-shadow, transform;
  transition-duration: var(--rpt-transition-duration);
  transition-timing-function: ease-in-out;
}

/* Action buttons styling - updated for flexible layout */
.rpt-action-cell {
  text-align: center !important;
  width: auto !important;
  min-width: auto !important;
  padding: 4px 8px !important;
  vertical-align: middle !important;
}

.rpt-action-header-cell {
  text-align: center !important;
  width: auto !important;
  min-width: auto !important;
}

/* Action buttons container */
.rpt-action-buttons-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
}

/* Improved action buttons */
.rpt-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  margin: 0;
  border-radius: 4px;
  border: 1px solid var(--rpt-border-color, #e2e8f0);
  background-color: var(--rpt-bg-subtle, #f8fafc);
  color: var(--rpt-text-secondary, #64748b);
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.rpt-action-btn:hover {
  background-color: var(--rpt-bg-hover, #f1f5f9);
  border-color: var(--rpt-border-hover, #cbd5e1);
  color: var(--rpt-text-primary, #475569);
}

.rpt-action-btn--view {
  color: var(--rpt-primary, #2563eb);
  border-color: var(--rpt-primary-subtle, #bfdbfe);
}

.rpt-action-btn--edit {
  color: var(--rpt-warning, #ca8a04);
  border-color: var(--rpt-warning-subtle, #fef9c3);
}

.rpt-action-btn--delete {
  color: var(--rpt-destructive, #dc2626);
  border-color: var(--rpt-destructive-subtle, #fee2e2);
}

.rpt-action-btn--primary {
  color: var(--rpt-primary, #2563eb);
  border-color: var(--rpt-primary-subtle, #bfdbfe);
}

.rpt-action-btn--view:hover {
  background-color: var(--rpt-primary-bg-subtle, #dbeafe);
}

.rpt-action-btn--edit:hover {
  background-color: var(--rpt-warning-bg-subtle, #fef9c3);
}

.rpt-action-btn--delete:hover {
  background-color: var(--rpt-destructive-bg-subtle, #fee2e2);
}

.rpt-action-btn--primary:hover {
  background-color: var(--rpt-primary-bg-subtle, #dbeafe);
}

.rpt-action-btn .rpt-action-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
}

.rpt-action-btn svg {
  width: 16px;
  height: 16px;
}

.rpt-action-label {
  margin-left: 4px;
}

/* Skeleton loading styles */
.rpt-skeleton {
  background: linear-gradient(90deg, 
    rgba(190, 190, 190, 0.2) 25%, 
    rgba(129, 129, 129, 0.24) 37%, 
    rgba(190, 190, 190, 0.2) 63%
  );
  background-size: 400% 100%;
  animation: rpt-skeleton-loading 1.4s ease-in-out infinite;
  border-radius: 4px;
}

.rpt-skeleton-text {
  height: 16px;
  width: 80%;
}

.rpt-skeleton-checkbox {
  height: 16px;
  width: 16px;
  border-radius: 2px;
}

.rpt-skeleton-actions {
  height: 32px;
  width: 100%;
  border-radius: 6px;
}

@keyframes rpt-skeleton-loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Dark mode skeleton */
.dark .rpt-skeleton,
[data-theme="dark"] .rpt-skeleton {
  background: linear-gradient(90deg, 
    rgba(64, 64, 64, 0.2) 25%, 
    rgba(96, 96, 96, 0.24) 37%, 
    rgba(64, 64, 64, 0.2) 63%
  );
  background-size: 400% 100%;
}

/* Light and dark mode auto detection */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    /* Dark mode variables defined in theme.css */
  }
}

/* Improved responsive classes */
@media (max-width: 640px) {
  .rpt-container {
    border-radius: calc(var(--rpt-border-radius) / 2); /* Smaller radius on mobile */
  }
  
  /* Optimize buttons for touch */
  .rpt-btn, .rpt-action-btn {
    min-height: 36px; /* Ensure touch target size meets standards */
  }
  
  /* Ensure tables don't overflow */
  .rpt-table-wrapper {
    margin-right: -1px;
    margin-left: -1px;
  }
  
  /* Ensure font size is readable on mobile */
  .rpt-text-xs {
    font-size: 0.75rem !important;
  }
}

/* Enhanced mobile landscape mode */
@media (max-width: 896px) and (orientation: landscape) {
  .rpt-container {
    max-height: 85vh;
  }
  
  /* Optimize dialogs for landscape */
  .rpt-dialog {
    max-height: 85vh;
    width: 90vw;
  }
}

/* Print styles - simplified for better printing */
@media print {
  .rpt-container {
    background-color: white !important;
    color: black !important;
    border: none !important;
    box-shadow: none !important;
    overflow: visible !important;
  }
  
  /* Ensure scrollbars don't print */
  .rpt-container::-webkit-scrollbar,
  .rpt-table-wrapper::-webkit-scrollbar,
  .rpt-dialog-content::-webkit-scrollbar {
    display: none !important;
  }
  
  /* Fix table layout for printing */
  .rpt-table {
    table-layout: auto !important;
    width: 100% !important;
  }
  
  /* Ensure borders print properly */
  .rpt-head-cell, .rpt-cell {
    border: 1px solid #000 !important;
  }
}