/* ============================================
   K-TID Design System — "The Digital Monolith"
   Based on DESIGN.md (kbs_trust_grid)
   ============================================ */

:root {
  --primary: #003f87;
  --primary-container: #0056b3;
  --primary-fixed: #d7e2ff;
  --primary-fixed-dim: #acc7ff;
  --on-primary: #ffffff;
  --on-primary-container: #bbd0ff;

  --secondary: #4a6178;
  --secondary-container: #cae2fe;
  --secondary-fixed: #cee5ff;

  --tertiary: #004762;
  --tertiary-container: #006083;
  --tertiary-fixed: #c4e7ff;

  --surface: #f8f9fa;
  --surface-dim: #d9dadb;
  --surface-container-lowest: #ffffff;
  --surface-container-low: #f3f4f5;
  --surface-container: #edeeef;
  --surface-container-high: #e7e8e9;
  --surface-container-highest: #e1e3e4;

  --on-surface: #191c1d;
  --on-surface-variant: #424752;
  --outline: #727784;
  --outline-variant: #c2c6d4;

  --error: #ba1a1a;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--surface);
  color: var(--on-surface);
  font-family: 'Inter', 'Pretendard', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
body { min-height: max(884px, 100dvh); }

.font-headline { font-family: 'Manrope', system-ui, sans-serif; letter-spacing: -0.02em; }
.font-body { font-family: 'Inter', 'Pretendard', system-ui, sans-serif; }
.font-label { font-family: 'Inter', system-ui, sans-serif; }

/* Material Symbols */
.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  user-select: none;
}
.ms-fill { font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24; }

/* ---------- Signature Gradients & Glass ---------- */
.premium-gradient {
  background: linear-gradient(135deg, #003f87 0%, #0056b3 100%);
}
.trust-gradient {
  background: linear-gradient(135deg, #003f87 0%, #0056b3 60%, #006083 100%);
}
.glass-panel {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

/* ---------- App Shell ---------- */
.app-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  height: 64px;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  box-shadow: 0 1px 2px rgba(0, 63, 135, 0.04);
}
.app-main {
  max-width: 42rem;
  margin: 0 auto;
  padding: 96px 24px 112px;
}
.app-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  height: 80px;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex; justify-content: space-around; align-items: center;
  padding: 0 16px env(safe-area-inset-bottom);
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.06);
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 8px 20px;
  border-radius: 16px;
  color: #94a3b8;
  text-decoration: none;
  transition: transform 0.2s, background 0.3s, color 0.3s;
}
.nav-item:active { transform: scale(0.9); }
.nav-item:hover { color: var(--primary); }
.nav-item.active {
  background: #dbeafe;
  color: #1e3a8a;
}
.nav-item.active .material-symbols-outlined {
  font-variation-settings: 'FILL' 1, 'wght' 500;
}
.nav-item span.label {
  font-family: 'Manrope', system-ui, sans-serif;
  font-size: 10px;
  font-weight: 600;
  margin-top: 4px;
}

/* Brand logo */
.brand-logo {
  font-family: 'Manrope', system-ui, sans-serif;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #1e3a8a;
  text-decoration: none;
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface-container-lowest);
  border-radius: 24px;
  padding: 24px;
}
.card-low {
  background: var(--surface-container-low);
  border-radius: 24px;
  padding: 20px;
}
.card-elevated {
  background: var(--surface-container-lowest);
  border-radius: 24px;
  padding: 24px;
  box-shadow: 0 8px 32px rgba(25, 28, 29, 0.06);
}

/* Hero Monolith Card */
.monolith {
  position: relative;
  overflow: hidden;
  border-radius: 32px;
  padding: 32px;
  color: white;
  box-shadow: 0 20px 48px rgba(0, 63, 135, 0.22);
}
.monolith .blob-1 {
  position: absolute; right: -48px; top: -48px;
  width: 192px; height: 192px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  filter: blur(48px);
  pointer-events: none;
}
.monolith .blob-2 {
  position: absolute; left: -32px; bottom: -32px;
  width: 128px; height: 128px;
  background: rgba(0, 86, 179, 0.3);
  border-radius: 50%;
  filter: blur(32px);
  pointer-events: none;
}

/* ---------- Buttons ---------- */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 28px;
  background: linear-gradient(135deg, #003f87 0%, #0056b3 100%);
  color: white;
  font-family: 'Manrope', sans-serif;
  font-weight: 800;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: none; border-radius: 999px; cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 63, 135, 0.24);
  transition: transform 0.15s, opacity 0.2s;
  width: 100%;
}
.btn-primary:active { transform: scale(0.97); }
.btn-tertiary {
  background: transparent;
  color: var(--primary);
  font-weight: 700;
  font-size: 14px;
  border: none; cursor: pointer;
}

/* ---------- Trust Badge (Signature Component) ---------- */
.trust-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px;
  background: rgba(0, 96, 131, 0.08);
  border-radius: 999px;
}
.trust-badge .material-symbols-outlined {
  font-size: 14px;
  color: var(--tertiary);
  font-variation-settings: 'FILL' 1;
}
.trust-badge span {
  font-size: 10px;
  font-weight: 700;
  color: var(--tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ---------- Toggle Switch ---------- */
.toggle {
  width: 44px; height: 24px;
  background: var(--surface-container-highest);
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  border: none;
  padding: 2px;
  transition: background 0.2s;
}
.toggle::after {
  content: '';
  display: block;
  width: 20px; height: 20px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
  transition: transform 0.2s;
}
.toggle.on { background: var(--primary-container); }
.toggle.on::after { transform: translateX(20px); }

/* ---------- Row / List helpers (no dividers) ---------- */
.row-stack > * + * { margin-top: 12px; }
.row-stack-sm > * + * { margin-top: 8px; }
.row-stack-lg > * + * { margin-top: 16px; }

/* Press effects */
.press { transition: transform 0.15s, opacity 0.2s; }
.press:active { transform: scale(0.97); }
.press-card:active { transform: scale(0.99); opacity: 0.9; }

/* Typography scale */
.text-display-lg { font-size: 3.5rem; line-height: 1.05; }
.text-display-md { font-size: 2.5rem; line-height: 1.1; }
.text-headline-lg { font-size: 2rem; line-height: 1.15; }
.text-headline-md { font-size: 1.5rem; line-height: 1.2; }
.text-title-lg { font-size: 1.125rem; line-height: 1.3; }
.text-label-sm { font-size: 11px; letter-spacing: 0.04em; }

/* Utility tonal text */
.text-muted { color: var(--on-surface-variant); }
.text-primary { color: var(--primary); }
.text-tertiary { color: var(--tertiary); }

/* Ghost border (for inputs only) */
.ghost-border {
  border: 1px solid rgba(194, 198, 212, 0.2);
}
.ghost-border:focus-within {
  border-color: var(--primary);
  background: var(--surface-container-lowest);
}

@media (max-width: 480px) {
  .text-display-lg { font-size: 2.5rem; }
}

/* ============================================
   Polygon / Blockchain Components (v0.2.0)
   Polygon brand: #7B3FE4
   ============================================ */
:root {
  --polygon: #7B3FE4;
  --polygon-soft: rgba(123, 63, 228, 0.08);
}

/* Live status badge */
.chain-badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(8px);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: all 0.3s;
}
.chain-badge .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: chain-pulse 2s infinite;
}
.chain-badge.offline .dot {
  background: #94a3b8;
  animation: none;
  box-shadow: none;
}
@keyframes chain-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70%  { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Blockchain verify button (wallet cards) */
.btn-chain {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  background: var(--polygon-soft);
  color: var(--polygon);
  font-size: 11px;
  font-weight: 700;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s, background 0.2s;
  font-family: 'Manrope', sans-serif;
  letter-spacing: 0.02em;
}
.btn-chain:hover { background: rgba(123, 63, 228, 0.14); }
.btn-chain:active { transform: scale(0.96); }
.btn-chain .material-symbols-outlined { font-size: 14px; }

/* Polygon address chip (monospace) */
.addr-chip {
  font-family: 'Manrope', 'SF Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  color: var(--polygon);
  letter-spacing: -0.01em;
  text-decoration: none;
  border-bottom: 1px dashed rgba(123, 63, 228, 0.3);
}
.addr-chip:hover { border-bottom-style: solid; }

/* Skeleton loader */
.skeleton {
  background: linear-gradient(90deg,
    var(--surface-container-low) 0%,
    var(--surface-container-high) 50%,
    var(--surface-container-low) 100%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
  border-radius: 8px;
}
@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* On-chain timeline item */
.chain-tx {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px;
  background: var(--surface-container-lowest);
  border-radius: 16px;
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s, box-shadow 0.2s;
  border-left: 3px solid var(--polygon);
}
.chain-tx:hover { transform: translateX(2px); box-shadow: 0 2px 8px rgba(0,0,0,0.04); }
.chain-tx .tx-hash {
  font-family: 'Manrope', monospace;
  font-size: 12px;
  font-weight: 700;
  color: var(--on-surface);
  letter-spacing: -0.01em;
}
.chain-tx .tx-meta {
  font-size: 10px;
  color: var(--on-surface-variant);
  margin-top: 2px;
}

/* ============================================
   Issuer Dashboard (v0.3.0-step2)
   ============================================ */

/* 2단 레이아웃 */
.issuer-layout {
  display: grid;
  grid-template-columns: 40fr 60fr;
  gap: 20px;
  align-items: start;
}
@media (max-width: 768px) {
  .issuer-layout {
    grid-template-columns: 1fr;
  }
}

/* 기관 선택 드롭다운 */
.issuer-select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--surface-container-lowest) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%23424752' d='M6 8L0 0h12z'/></svg>") no-repeat right 14px center;
  border: 1px solid rgba(194, 198, 212, 0.3);
  border-radius: 12px;
  padding: 10px 36px 10px 14px;
  font-family: 'Inter', 'Pretendard', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--on-surface);
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s;
}
.issuer-select:focus { border-color: var(--primary); }

/* Drag & Drop Upload Zone */
.drop-zone {
  border: 2px dashed rgba(194, 198, 212, 0.5);
  border-radius: 16px;
  padding: 32px 20px;
  text-align: center;
  background: var(--surface-container-low);
  transition: all 0.2s;
  cursor: pointer;
}
.drop-zone:hover {
  border-color: var(--primary-fixed-dim);
  background: rgba(0, 63, 135, 0.03);
}
.drop-zone.dragover {
  border-color: var(--primary);
  background: var(--primary-fixed);
  transform: scale(1.01);
}
.drop-zone .material-symbols-outlined {
  font-size: 36px;
  color: var(--primary);
  margin-bottom: 8px;
}

/* Progress bar */
.progress-track {
  height: 8px;
  background: var(--surface-container-high);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary) 0%, var(--primary-container) 100%);
  border-radius: 999px;
  width: 0%;
  transition: width 0.3s ease-out;
}

/* Issue list table */
.issue-table { width: 100%; border-collapse: collapse; }
.issue-table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 10px;
  font-weight: 700;
  color: var(--on-surface-variant);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--surface-container-low);
}
.issue-table th:first-child { border-top-left-radius: 10px; border-bottom-left-radius: 10px; }
.issue-table th:last-child  { border-top-right-radius: 10px; border-bottom-right-radius: 10px; }
.issue-table td {
  padding: 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--on-surface);
}
.issue-table tr.row-idle    { background: transparent; }
.issue-table tr.row-processing {
  background: var(--primary-fixed);
  animation: row-pulse 1.2s ease-in-out infinite;
}
.issue-table tr.row-done {
  background: rgba(16, 185, 129, 0.05);
}
.issue-table tr.row-failed {
  background: rgba(186, 26, 26, 0.06);
}
.issue-table tr.row-error {
  background: rgba(186, 26, 26, 0.08);
}
@keyframes row-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.85; }
}

/* Status icon pill */
.status-pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.status-pill.idle       { background: var(--surface-container-high); color: var(--on-surface-variant); }
.status-pill.processing { background: rgba(0, 63, 135, 0.12); color: var(--primary); }
.status-pill.done       { background: rgba(16, 185, 129, 0.15); color: #065f46; }
.status-pill.failed     { background: rgba(186, 26, 26, 0.12); color: var(--error); }

/* Transaction hash display (cell) */
.tx-hash-cell {
  font-family: 'Manrope', monospace;
  font-size: 10px;
  color: var(--polygon);
  letter-spacing: -0.01em;
}

/* Issuer button variant (smaller) */
.btn-sm {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 18px;
  font-size: 12px;
  font-weight: 700;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  font-family: 'Manrope', sans-serif;
  letter-spacing: 0.02em;
  transition: transform 0.15s, opacity 0.2s;
}
.btn-sm:active { transform: scale(0.96); }
.btn-sm:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-sm.btn-sm-primary {
  background: linear-gradient(135deg, #003f87 0%, #0056b3 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(0, 63, 135, 0.22);
}
.btn-sm.btn-sm-ghost {
  background: var(--surface-container-high);
  color: var(--on-surface);
}
.btn-sm.btn-sm-outline {
  background: transparent;
  color: var(--primary);
  border: 1px solid rgba(0, 63, 135, 0.2);
}

/* Summary cards */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 16px;
}
.summary-cell {
  background: var(--surface-container-low);
  border-radius: 12px;
  padding: 12px;
  text-align: center;
}
.summary-cell .label {
  font-size: 10px;
  color: var(--on-surface-variant);
  font-weight: 600;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.summary-cell .value {
  font-family: 'Manrope', sans-serif;
  font-size: 20px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.02em;
}
@media (max-width: 480px) {
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
}

/* 6탭일 때 nav 레이블 축소 */
.app-nav.nav-6 .nav-item { padding: 8px 10px; }
.app-nav.nav-6 .nav-item span.label { font-size: 9px; }
@media (max-width: 380px) {
  .app-nav.nav-6 .nav-item { padding: 8px 6px; }
  .app-nav.nav-6 .nav-item .material-symbols-outlined { font-size: 22px; }
}
