/* cignyl-sftp 20260824 */
/* ------------------------------ */
/* v2 Data Grid (AG Grid)        */
/* ------------------------------ */

.v2-theme .v2-data-grid {
  position: relative;
  width: var(--v2-data-grid-width, 100%);
}

.v2-theme .v2-data-grid__grid-wrap {
  width: 100%;
  height: var(--v2-data-grid-height, 400px);
  min-height: 140px;
}

/* ---- Fill-height mode (height: 100%) ---- */

.v2-theme .v2-data-grid--fill-height {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.v2-theme .v2-data-grid--fill-height > .v2-data-grid__grid-wrap {
  height: auto;
  flex: 1 1 0%;
  min-height: 140px;
}

.v2-theme .v2-data-grid--fill-height > .v2-data-grid__pagination {
  flex-shrink: 0;
}

/* ---- Disabled state ---- */

.v2-theme .v2-data-grid--disabled-true {
  opacity: 0.6;
  pointer-events: none;
}

/* ---- Error / message overlay ---- */

.v2-theme .v2-data-grid__overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  border: 1px dashed hsl(var(--border));
  background: hsl(var(--card) / 0.75);
  color: hsl(var(--card-foreground));
  padding: var(--v2-space-md);
  z-index: 2;
}

.v2-theme .v2-data-grid__overlay-inner {
  max-width: 28rem;
  text-align: center;
}

.v2-theme .v2-data-grid__overlay-text {
  font-size: 0.95rem;
  line-height: 1.4;
  color: hsl(var(--muted-foreground));
}

/* ---- AG Grid theme variable mapping (light) ---- */

.v2-theme .v2-data-grid .ag-theme-quartz,
.v2-theme .v2-data-grid .ag-theme-quartz-dark {
  --ag-background-color: hsl(var(--background));
  --ag-foreground-color: hsl(var(--foreground));
  --ag-header-background-color: hsl(var(--muted));
  --ag-header-foreground-color: hsl(var(--muted-foreground));
  --ag-border-color: hsl(var(--border));
  --ag-row-hover-color: hsl(var(--accent));
  --ag-selected-row-background-color: hsl(var(--accent));
  --ag-range-selection-background-color: hsl(var(--accent));
  --ag-font-family: inherit;
  --ag-font-size: 14px;
  --ag-row-border-color: hsl(var(--border));
  --ag-header-column-separator-color: hsl(var(--border));
  --ag-header-column-resize-handle-color: hsl(var(--border));
  --ag-input-focus-border-color: hsl(var(--ring));
  --ag-checkbox-checked-color: hsl(var(--primary));
  --ag-checkbox-unchecked-color: hsl(var(--muted-foreground));
  --ag-card-shadow: 0 1px 4px 0 hsl(var(--foreground) / 0.1);
}

/* ---- Override layout.css input[type=text] for AG Grid inputs ---- */
/* layout.css sets padding-left: 3px on all input[type=text]; restore a sane
   default so AG Grid text inputs are not cramped. */
.v2-theme .v2-data-grid input.ag-input-field-input,
.v2-theme .v2-data-grid input.ag-text-field-input {
  padding-left: 6px;
}

/* Filter-menu popup inputs need extra left padding for the search-icon overlay. */
.v2-theme .v2-data-grid .ag-filter input.ag-input-field-input,
.v2-theme .v2-data-grid .ag-filter input.ag-text-field-input {
  padding-left: 24px;
}

/* Floating date filters also render a leading icon; keep placeholder clear of it. */
.v2-theme .v2-data-grid .ag-floating-filter .ag-date-filter input.ag-input-field-input,
.v2-theme .v2-data-grid .ag-floating-filter .ag-date-filter input.ag-text-field-input {
  padding-left: 24px;
}

/* ---- Server-side pagination bar ---- */

.v2-theme .v2-data-grid__pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border: 1px solid hsl(var(--border));
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  background: hsl(var(--muted));
  font-size: 13px;
  color: hsl(var(--muted-foreground));
  min-height: 40px;
}

.v2-theme .v2-data-grid__pagination-info {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.v2-theme .v2-data-grid__pagination-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.v2-theme .v2-data-grid__pagination-page-size {
  height: 28px;
  padding: 0 6px;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-size: 13px;
  cursor: pointer;
  margin-right: 8px;
}

.v2-theme .v2-data-grid__pagination-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease;
}

.v2-theme .v2-data-grid__pagination-btn:hover:not(:disabled) {
  background: hsl(var(--accent));
}

.v2-theme .v2-data-grid__pagination-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.v2-theme .v2-data-grid__pagination-page-text {
  padding: 0 8px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ---- Utility: hidden ---- */

.v2-theme .v2-data-grid .v2-is-hidden {
  display: none !important;
}
