/**
 * Declaration Table & Correction View Styles
 * 
 * Styles for spreadsheet-like table component
 * - Responsive layout
 * - Keyboard navigation indicators
 * - Error highlighting
 * - Bulk edit UI
 */

/* ============================================================================ */
/* TABLE WRAPPER & CONTAINER */
/* ============================================================================ */

.declaration-table-wrapper {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem;
  background: rgba(255, 253, 248, 0.8);
  border-radius: 16px;
  box-shadow: 0 16px 36px rgba(16, 24, 32, 0.12);
  border: 1px solid rgba(16, 24, 32, 0.08);
}

.table-container {
  overflow-x: auto;
  border: 1px solid rgba(16, 24, 32, 0.1);
  border-radius: 14px;
  background: white;
  box-shadow: 0 10px 24px rgba(16, 24, 32, 0.08);
}

/* ============================================================================ */
/* DECLARATION META & FILTERS */
/* ============================================================================ */

.declaration-meta {
  display: flex;
  gap: 2rem;
  padding: 0.75rem 1rem;
  background: rgba(255, 253, 248, 0.95);
  border: 1px solid rgba(16, 24, 32, 0.08);
  border-radius: 12px;
  font-size: 0.95rem;
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.meta-item strong {
  font-weight: 600;
  color: #2a3643;
}

.filter-section {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem;
  background: rgba(255, 253, 248, 0.95);
  border: 1px solid rgba(16, 24, 32, 0.08);
  border-radius: 12px;
}

.filter-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
}

.filter-toggle input[type="checkbox"] {
  cursor: pointer;
  width: 1.2rem;
  height: 1.2rem;
}

.invalid-count {
  color: #c6483c;
  font-weight: 500;
  margin-left: 0.25rem;
}

/* ============================================================================ */
/* TABLE STYLES */
/* ============================================================================ */

.declaration-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  background: white;
}

.declaration-table thead {
  background: #f2ebe0;
  border-bottom: 2px solid rgba(16, 24, 32, 0.08);
  font-weight: 600;
  color: #101820;
  position: sticky;
  top: 0;
  z-index: 10;
}

.declaration-table th {
  padding: 0.75rem;
  text-align: left;
  white-space: nowrap;
  border-right: 1px solid rgba(16, 24, 32, 0.08);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.75rem;
}

.declaration-table th:last-child {
  border-right: none;
}

.declaration-table tbody tr {
  border-bottom: 1px solid rgba(16, 24, 32, 0.08);
  transition: background-color 0.15s ease;
}

.declaration-table tbody tr:hover {
  background-color: rgba(16, 24, 32, 0.04);
}

/* Row states */
.table-row.row-valid {
  background-color: white;
}

.table-row.row-invalid {
  background-color: rgba(198, 72, 60, 0.08);
}

.table-row.row-invalid:hover {
  background-color: rgba(198, 72, 60, 0.14);
}

/* ============================================================================ */
/* TABLE CELLS */
/* ============================================================================ */

.declaration-table td {
  padding: 0.6rem 0.75rem;
  border-right: 1px solid rgba(16, 24, 32, 0.08);
  min-height: 44px;
  vertical-align: middle;
}

.declaration-table td:last-child {
  border-right: none;
}

/* Cell content display */
.cell-content {
  display: inline-block;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Editable cell styling */
[data-editable="true"] {
  position: relative;
  cursor: cell;
  background: white;
}

[data-editable="true"]:focus-within {
  background: rgba(201, 111, 59, 0.15);
  outline: 2px solid #c96f3b;
  outline-offset: -1px;
}

/* Inputs in cells */
[data-editable="true"] input,
[data-editable="true"] select,
[data-editable="true"] textarea {
  width: 100%;
  padding: 0.35rem;
  border: 1px solid #c96f3b;
  border-radius: 0.5rem;
  font-size: 0.9rem;
  font-family: inherit;
  background: #fffaf3;
}

[data-editable="true"] input:focus,
[data-editable="true"] select:focus {
  outline: none;
  border-color: #c96f3b;
  box-shadow: 0 0 0 0.2rem rgba(201, 111, 59, 0.25);
}

/* Specific columns */
.col-selector {
  text-align: center;
  padding: 0.5rem;
}

.col-line-no {
  text-align: right;
  font-family: 'Courier New', monospace;
  color: rgba(16, 24, 32, 0.55);
}

.col-qty,
.col-value,
.col-net-mass {
  text-align: right;
  font-family: 'Courier New', monospace;
}

.col-flow {
  text-align: center;
  font-weight: 500;
}

.col-error {
  text-align: center;
  padding: 0.5rem;
}

/* ============================================================================ */
/* ERROR INDICATOR & ERROR ROW */
/* ============================================================================ */

.error-indicator {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.25rem;
  transition: transform 0.15s;
}

.error-indicator:hover {
  transform: scale(1.2);
}

.error-indicator.valid {
  color: #1f7a5b;
}

.error-indicator.has-errors {
  color: #dc3545;
}

/* Error row (expandable) */
.error-row {
  display: none;
  border-top: 2px solid #dc3545 !important;
  background: #fff5f5 !important;
}

.error-row.show {
  display: table-row;
}

.error-row td {
  padding: 1rem;
  border: none;
}

/* ============================================================================ */
/* ERROR PANEL */
/* ============================================================================ */

.error-panel {
  border: 1px solid rgba(198, 72, 60, 0.3);
  border-radius: 0.75rem;
  background: #fffaf3;
  padding: 1rem;
}

.error-panel-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(198, 72, 60, 0.15);
  flex-wrap: wrap;
}

.error-panel-icon {
  font-size: 1.2rem;
  color: #c6483c;
}

.error-panel-header strong {
  color: #c6483c;
  font-size: 0.95rem;
}

.error-panel-hint {
  color: rgba(16, 24, 32, 0.55);
  font-size: 0.8rem;
  margin-left: auto;
}

.error-item-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.error-field-badge {
  display: inline-block;
  background: #c6483c;
  color: #fff;
  padding: 0.1rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.error-item .error-message {
  color: #333;
  font-weight: 500;
  font-size: 0.9rem;
}

.error-guidance-icon {
  font-size: 0.85rem;
}

.error-panel-empty {
  text-align: center;
  padding: 2rem;
  color: rgba(16, 24, 32, 0.6);
}

.error-header {
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(16, 24, 32, 0.12);
}

.error-header h5 {
  margin: 0;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.error-details {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.error-section {
  border-left: 4px solid #c6483c;
  padding-left: 1rem;
}

.error-field-name {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.error-field-name strong {
  font-size: 0.95rem;
  color: #101820;
}

.error-items {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.error-item {
  background: #fffdf8;
  border: 1px solid rgba(16, 24, 32, 0.08);
  border-radius: 0.375rem;
  padding: 0.75rem;
  font-size: 0.9rem;
}

.error-message p {
  margin: 0;
  color: #c6483c;
  font-weight: 500;
}

.error-guidance {
  margin-top: 0.5rem;
  color: rgba(16, 24, 32, 0.75);
  font-size: 0.85rem;
  line-height: 1.5;
}

.error-guidance p {
  margin: 0;
}

.error-rule {
  margin-top: 0.5rem;
  color: rgba(16, 24, 32, 0.55);
  font-size: 0.8rem;
  font-style: italic;
}

.fix-btn {
  margin-top: 0.5rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.85rem;
}

.error-actions {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(16, 24, 32, 0.12);
  display: flex;
  justify-content: flex-end;
}

/* ============================================================================ */
/* BULK EDIT PANEL */
/* ============================================================================ */

.bulk-action-section {
  padding: 0.75rem 1rem;
  background: rgba(15, 91, 91, 0.1);
  border: 1px solid rgba(15, 91, 91, 0.25);
  border-radius: 0.75rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.selected-count {
  font-weight: 500;
  color: #0f5b5b;
}

.bulk-edit-panel {
  padding: 1rem 0;
}

.selected-info {
  padding: 0.75rem;
  background: rgba(15, 91, 91, 0.12);
  border-radius: 0.75rem;
  margin-bottom: 1rem;
}

.selected-info p {
  margin: 0;
  color: #0f5b5b;
}

.bulk-preview {
  padding: 1rem;
  background: #fffaf3;
  border: 1px solid rgba(16, 24, 32, 0.12);
  border-radius: 0.75rem;
  margin-top: 1rem;
}

.bulk-preview h6 {
  margin: 0 0 0.5rem 0;
  font-size: 0.9rem;
}

.bulk-preview ul {
  margin: 0;
  padding-left: 1.5rem;
  font-size: 0.9rem;
}

.bulk-preview li {
  margin: 0.25rem 0;
  color: rgba(16, 24, 32, 0.75);
}

/* ============================================================================ */
/* PAGINATION */
/* ============================================================================ */

.pagination-section {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1rem;
  background: #fffdf8;
  border: 1px solid rgba(16, 24, 32, 0.12);
  border-radius: 0.75rem;
}

.pagination-info {
  font-size: 0.9rem;
  color: rgba(16, 24, 32, 0.6);
  min-width: 150px;
  text-align: center;
}

/* ============================================================================ */
/* SCROLLBAR STYLING */
/* ============================================================================ */

.table-container::-webkit-scrollbar {
  height: 8px;
}

.table-container::-webkit-scrollbar-track {
  background: #efe6d9;
}

.table-container::-webkit-scrollbar-thumb {
  background: rgba(16, 24, 32, 0.45);
  border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb:hover {
  background: rgba(16, 24, 32, 0.6);
}

/* ============================================================================ */
/* RESPONSIVE DESIGN */
/* ============================================================================ */

/* Tablet (768px and up) */
@media (max-width: 768px) {
  .declaration-table {
    font-size: 0.85rem;
  }

  .declaration-table th,
  .declaration-table td {
    padding: 0.5rem;
  }

  .declaration-meta {
    flex-direction: column;
    gap: 0.5rem;
  }

  .filter-section {
    flex-direction: column;
    align-items: flex-start;
  }

  .pagination-section {
    flex-direction: column;
    gap: 0.5rem;
  }
}

/* Mobile (320px and up) */
@media (max-width: 320px) {
  .declaration-table {
    font-size: 0.8rem;
  }

  .declaration-table th,
  .declaration-table td {
    padding: 0.3rem;
  }

  .error-item {
    padding: 0.5rem;
  }

  .bulk-action-section {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ============================================================================ */
/* UTILITIES */
/* ============================================================================ */

.badge {
  display: inline-block;
  padding: 0.375rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: 0.375rem;
}

.badge-success {
  background: rgba(31, 122, 91, 0.18);
  color: #1f7a5b;
}

.badge-danger {
  background: rgba(198, 72, 60, 0.18);
  color: #c6483c;
}

.badge-warning {
  background: rgba(184, 132, 0, 0.18);
  color: #b88400;
}

.badge-info {
  background: rgba(27, 122, 166, 0.18);
  color: #1b7aa6;
}

/* ============================================================================ */
/* FOCUS & ACCESSIBILITY */
/* ============================================================================ */

/* Keyboard navigation indicators */
.declaration-table td:focus-within {
  box-shadow: inset 0 0 0 3px rgba(201, 111, 59, 0.45);
}

/* High contrast mode support */
@media (prefers-contrast: more) {
  .table-row.row-invalid {
    background-color: #ffcccc;
  }

  .table-row.row-invalid:hover {
    background-color: #ffaaaa;
  }

  [data-editable="true"]:focus-within {
    outline-width: 3px;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .declaration-table tbody tr,
  .error-indicator {
    transition: none;
  }
}
