@import './tokens.css';

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
  margin: 0;
  background: var(--ks-color-canvas);
  color: var(--ks-color-text);
  font-family: Inter, Pretendard, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: var(--ks-font-body, 12px);
  line-height: var(--ks-line-body, 16px);
}

/* KBX v60 Global Typography Token Scale Standard (표준 폰트 크기 계층 규격) */
h1, .ks-title {
  font-size: var(--ks-font-page, 16px) !important;
  line-height: var(--ks-line-page, 22px) !important;
  font-weight: 700 !important;
}

h2, .ks-section-title {
  font-size: var(--ks-font-section, 14px) !important;
  line-height: var(--ks-line-section, 18px) !important;
  font-weight: 700 !important;
}

h3, h4, dt, legend {
  font-size: var(--ks-font-section, 14px) !important;
  line-height: var(--ks-line-section, 18px) !important;
  font-weight: 600 !important;
}

p, span, li, td, input, select, button, label, .ks-font-body {
  font-size: var(--ks-font-body, 12px);
  line-height: var(--ks-line-body, 16px);
}

th, .ag-header-cell-text {
  font-size: var(--ks-font-grid, 12px) !important;
  line-height: var(--ks-line-grid, 16px) !important;
  font-weight: 700 !important;
}

caption, .hint, .note, .ks-caption, small, .help-text, .ks-font-caption {
  font-size: var(--ks-font-caption, 11px) !important;
  line-height: var(--ks-line-caption, 14px) !important;
}

button, input, select, textarea { font: inherit; }
a { color: var(--ks-color-action); }
:focus-visible { outline: var(--ks-focus-ring-width) solid color-mix(in srgb, var(--ks-color-focus) 55%, transparent); outline-offset: var(--ks-focus-ring-offset); }
.ks-financial-number { font-variant-numeric: tabular-nums; font-family: 'JetBrains Mono', Consolas, monospace; }
.ks-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.ks-card { 
  background: var(--ks-color-surface-raised); 
  border: 1px solid var(--ks-color-border); 
  border-radius: var(--ks-radius-lg); 
  box-shadow: var(--ks-shadow-md); 
  transition: var(--ks-transition-smooth);
}
.ks-card:hover {
  box-shadow: var(--ks-shadow-lg);
  border-color: var(--ks-color-border-strong);
}
.ks-glass-card {
  background: var(--ks-glass-bg);
  backdrop-filter: var(--ks-glass-backdrop);
  -webkit-backdrop-filter: var(--ks-glass-backdrop);
  border: 1px solid var(--ks-glass-border);
  border-radius: var(--ks-radius-lg);
  box-shadow: var(--ks-shadow-md);
}
.ks-stack { display: grid; gap: var(--ks-space-4); flex: 1; min-height: 0; height: 100%; }
.ks-inline { display: flex; align-items: center; gap: var(--ks-space-2); flex-wrap: wrap; }
.ks-muted { color: var(--ks-color-text-muted); }
.ks-danger-text { color: var(--ks-color-danger); }

/* Standard Flex & Grid Layout Classes (높이 전파 표준) */
.ks-flex-column-1 { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.ks-flex-row-1 { display: flex; flex-direction: row; flex: 1; min-height: 0; }
.ks-overflow-auto { overflow-y: auto; }
.ks-overflow-x-auto { overflow-x: auto; }
.ks-overflow-hidden { overflow: hidden; }

/* Global Ultra-Dense Form Control & Button Density Standardization (전역 통일 규격) */
input[type="text"], input[type="number"], input[type="date"], select, textarea, .p-inputtext, .p-select, .p-dropdown, .ks-text-field__input, .ks-select__trigger, .ks-multi-select__trigger {
  height: var(--ks-control-height) !important;
  font-size: var(--ks-font-body) !important;
  padding: 0 var(--ks-space-2) !important;
  border-radius: var(--ks-radius-sm) !important;
  border-color: var(--ks-color-border) !important;
  box-sizing: border-box;
}

/* Automatic Global Inline Rule for Filter Container Slots */
.ks-page__filters .ks-text-field,
.ks-page__filters .ks-select,
.ks-page__filters .ks-date-field {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: var(--ks-space-2, 6px) !important;
}

.ks-page__filters:empty,
.ks-page__command-bar:empty,
.ks-page__summary:empty {
  display: none !important;
  min-height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  border: none !important;
}


.ks-page__filters .ks-text-field__label,
.ks-page__filters .ks-select__label,
.ks-page__filters .ks-date-field__label,
.ks-text-field--inline .ks-text-field__label,
.ks-select--inline .ks-select__label,
.ks-date-field--inline .ks-date-field__label {
  width: var(--ks-field-label-width, 72px) !important;
  min-width: var(--ks-field-label-width, 72px) !important;
  max-width: var(--ks-field-label-width, 72px) !important;
  text-align: left !important;
  white-space: nowrap !important;
  flex-shrink: 0 !important;
  margin-bottom: 0 !important;
  font-size: var(--ks-font-body) !important;
}

.ks-page__filters .ks-text-field__container,
.ks-page__filters .ks-select__container,
.ks-page__filters .ks-date-field__container,
.ks-text-field--inline .ks-text-field__container,
.ks-select--inline .ks-select__container,
.ks-date-field--inline .ks-date-field__container {
  flex: 1 1 auto !important;
  min-width: 0 !important;
  max-width: 100% !important;
  width: 100% !important;
}


.ks-set-sm, .ks-filter-sm {
  width: var(--ks-set-width-sm, 200px) !important;
  min-width: var(--ks-set-width-sm, 200px) !important;
  max-width: var(--ks-set-width-sm, 200px) !important;
  flex-shrink: 0 !important;
}

.ks-set-md, .ks-filter-md {
  width: var(--ks-set-width-md, 260px) !important;
  min-width: var(--ks-set-width-md, 260px) !important;
  max-width: var(--ks-set-width-md, 260px) !important;
  flex-shrink: 0 !important;
}

.ks-set-lg, .ks-filter-lg {
  width: var(--ks-set-width-lg, 340px) !important;
  min-width: var(--ks-set-width-lg, 340px) !important;
  max-width: var(--ks-set-width-lg, 340px) !important;
  flex-shrink: 0 !important;
}



select, .p-select, .p-dropdown, .ks-select, .status-select {
  width: var(--ks-control-width-select);
  max-width: 100%;
}

input[type="text"].search-input, .search-input {
  width: var(--ks-control-width-search);
  max-width: 100%;
}

input[type="date"] {
  width: var(--ks-control-width-date);
  max-width: 100%;
}

.filters, .ks-page__filters form, .ks-page__filters section {
  display: flex;
  align-items: center;
  gap: var(--ks-space-3);
  flex-wrap: nowrap;
}


button, .p-button, .ks-button {
  height: var(--ks-control-height) !important;
  font-size: var(--ks-font-body) !important;
  padding: 0 var(--ks-space-3) !important;
  border-radius: var(--ks-radius-sm) !important;
  box-sizing: border-box;
}

.p-button-sm, .ks-button--sm {
  height: 24px !important;
  font-size: var(--ks-font-caption) !important;
  padding: 0 var(--ks-space-2) !important;
}

.p-button-lg, .ks-button--lg {
  height: 32px !important;
  font-size: var(--ks-font-section) !important;
  padding: 0 var(--ks-space-4) !important;
}

/* Global Status Tags, Badges & Labels Standardization */
.ks-status-tag, .p-tag, .p-badge {
  font-size: var(--ks-font-caption) !important;
  height: 20px !important;
  padding: 0 var(--ks-space-2) !important;
  border-radius: var(--ks-radius-sm) !important;
  line-height: 18px !important;
}

/* Global Dialog & Modal Standardization */
.p-dialog-header, .ks-dialog__header {
  padding: var(--ks-space-3) var(--ks-space-4) !important;
  font-size: var(--ks-font-section) !important;
}

.p-dialog-content, .ks-dialog__content {
  padding: var(--ks-space-4) !important;
  font-size: var(--ks-font-body) !important;
}

.p-dialog-footer, .ks-dialog__footer {
  padding: var(--ks-space-3) var(--ks-space-4) !important;
}

/* Global Footer Exclusion: Single-Screen Principle */
/* All footers hidden (both page-level and global) to maximize content area */
/* Structure preserved for backward compatibility; CSS hiding only */
.ks-page__footer,
.ks-shell__footer,
footer[class*="ks-"] {
  display: none !important; /* Maximize viewport for content; all controls → header/command-bar/summary */
}
