/* Base table plugin styles */

.editable-table {
  position: relative;
  width: 100%;
  margin: 20px 0;
  font-family: inherit;
}

/* Empty state */
.editable-table__empty {
  text-align: center;
}

.editable-table__table--placeholder {
  border: 2px dashed #ccc;
  background: rgba(0, 0, 0, 0.02);
}

.editable-table__cell--placeholder {
  height: 40px;
  width: 100px;
  border: 1px solid #e0e0e0;
}

.editable-table__instructions {
  margin-top: 15px;
  color: #666;
  font-size: 14px;
  font-style: italic;
}

/* Table structure */
.editable-table__table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--table-body-font-size, 14px);
  color: var(--table-body-text, inherit);
}

.editable-table__cell {
  padding: var(--table-cell-padding, 12px);
  text-align: left;
  vertical-align: top;
  background-color: var(--table-body-bg, #ffffff);
  transition: background-color 0.2s;
}

/* Alternating row colors */
.editable-table__table tr:nth-child(even) .editable-table__cell {
  background-color: var(--table-body-bg-alt, #f5f5f5);
}

/* Borders (when enabled) */
.editable-table--borders-enabled .editable-table__cell {
  border: var(--table-border-width, 1px) var(--table-border-style, solid) var(--table-border-color, #e0e0e0);
}

/* Header row */
.editable-table__cell--header-row {
  background-color: var(--table-header-bg, #000000) !important;
  color: var(--table-header-text, #ffffff);
  font-size: var(--table-header-font-size, 16px);
  font-weight: 600;
}

/* Header column */
.editable-table__cell--header-column {
  background-color: var(--table-header-bg, #000000) !important;
  color: var(--table-header-text, #ffffff);
  font-size: var(--table-header-font-size, 16px);
  font-weight: 600;
}

/* Header corner cell (hidden when both headers active) */
.editable-table__cell--header-corner {
  display: none !important;
}

/* Editing state */
.editable-table__cell--editing {
  outline: 2px solid #4A90E2;
  outline-offset: -2px;
  background-color: #f0f8ff !important;
}

.editable-table__cell--expanding {
  background-color: #f9f9f9;
  border: 1px solid #e0e0e0;
}

/* Error messages */
.editable-table__error {
  padding: 12px;
  margin: 10px 0;
  background-color: #fee;
  color: #c33;
  border: 1px solid #c33;
  border-radius: 4px;
  font-size: 14px;
}

/* Loading state */
.editable-table--loading {
  opacity: 0.6;
  pointer-events: none;
}

/* Focus styles */
.editable-table__table:focus {
  outline: 2px solid #4A90E2;
  outline-offset: 4px;
}

/* Floating toolbar styles */

.editable-table__toolbar {
  position: fixed;
  display: flex;
  gap: 4px;
  padding: 8px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  z-index: 1000;
}

.editable-table__toolbar-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  color: #333;
  transition: all 0.2s;
}

.editable-table__toolbar-button:hover:not(:disabled) {
  background: #f5f5f5;
  border-color: #ddd;
}

.editable-table__toolbar-button:active:not(:disabled) {
  background: #e8e8e8;
}

.editable-table__toolbar-button--active {
  background: #4A90E2;
  color: #fff;
  border-color: #4A90E2;
}

.editable-table__toolbar-button--active:hover {
  background: #357ABD;
  border-color: #357ABD;
}

.editable-table__toolbar-button--disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Header control buttons */
.editable-table__header-control {
  position: fixed;
  padding: 8px 12px;
  background: #4A90E2;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  white-space: nowrap;
  transition: all 0.2s;
  z-index: 1000;
}

.editable-table__header-control:hover {
  background: #357ABD;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25);
}

.editable-table__header-control:active {
  background: #2868A8;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

/* Mobile and responsive styles */

.editable-table__scroll-container {
  width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  position: relative;
}

/* Fade gradient indicator */
.editable-table__scroll-fade {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 40px;
  background: linear-gradient(to left, rgba(255, 255, 255, 0.9), transparent);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 10;
}

/* Mobile-specific adjustments */
@media (max-width: 768px) {
  .editable-table {
    margin: 15px 0;
  }

  .editable-table__toolbar {
    padding: 6px;
    gap: 3px;
    border-radius: 4px;
  }

  .editable-table__toolbar-button {
    width: 36px;
    height: 36px;
    font-size: 18px;
  }

  .editable-table__header-control {
    font-size: 12px;
    padding: 6px 10px;
  }

  .editable-table__cell {
    min-width: 100px;
    padding: var(--table-cell-padding, 10px);
  }

  .editable-table__instructions {
    font-size: 13px;
    padding: 0 10px;
  }
}

/* Touch-friendly hit areas */
@media (hover: none) and (pointer: coarse) {
  .editable-table__toolbar-button {
    min-width: 44px;
    min-height: 44px;
  }

  .editable-table__header-control {
    min-height: 44px;
    padding: 10px 14px;
  }

  .editable-table__cell {
    min-height: 44px;
  }
}

/* Tablet adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
  .editable-table {
    margin: 18px 0;
  }
}

/* Animation styles */

/* Grid expansion animation */
@keyframes expandGrid {
  from {
    opacity: 0.5;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.editable-table__table {
  animation: fadeIn 0.3s ease-out;
}

/* Fade in animation */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Expanding cell animation */
.editable-table__cell--expanding {
  animation: cellPulse 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes cellPulse {
  0% {
    background-color: #e8e8e8;
  }
  50% {
    background-color: #f5f5f5;
  }
  100% {
    background-color: #f9f9f9;
  }
}

/* Toolbar entrance */
.editable-table__toolbar {
  animation: toolbarSlideIn 0.2s ease-out;
}

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

/* Header control entrance */
.editable-table__header-control {
  animation: buttonPop 0.2s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes buttonPop {
  0% {
    opacity: 0;
    transform: scale(0.8);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Error message slide in */
.editable-table__error {
  animation: slideInDown 0.3s ease-out;
}

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

/* Smooth transitions */
.editable-table__cell {
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.editable-table__toolbar-button {
  transition: all 0.15s ease;
}

/* Loading pulse */
.editable-table--loading {
  animation: loadingPulse 1.5s ease-in-out infinite;
}

@keyframes loadingPulse {
  0%, 100% {
    opacity: 0.6;
  }
  50% {
    opacity: 0.8;
  }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

