/* ========================================
   K8s NetworkPolicy Auto-Generator
   Design: Dark Slate + Green Accent
   Font: Pretendard (KR) + JetBrains Mono (Code)
   ======================================== */

:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-surface: #334155;
  --bg-hover: #3b4a63;
  --text-primary: #f8fafc;
  --text-secondary: #a0aec0;
  --text-muted: #78859b;
  --accent: #22c55e;
  --accent-hover: #16a34a;
  --accent-warning: #f59e0b;
  --accent-error: #ef4444;
  --accent-info: #3b82f6;
  --border: #475569;
  --border-subtle: #334155;
  --radius: 4px;
  --radius-lg: 8px;
  --font-ui: 'Pretendard', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-code: 'JetBrains Mono', monospace;
  --transition: 200ms ease;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-ui);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ====== Buttons ====== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 400;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  min-height: 44px;
  min-width: 44px;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-hover); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled {
  background: var(--bg-surface);
  color: var(--text-muted);
  border-color: var(--border-subtle);
  cursor: not-allowed;
}

.btn-accent {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
  font-weight: 700;
}
.btn-accent:hover { background: var(--accent-hover); }
.btn-accent:disabled {
  background: var(--bg-surface);
  color: var(--text-muted);
  border-color: var(--border-subtle);
  cursor: not-allowed;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--bg-surface); color: var(--text-primary); }

.btn-sm { padding: 4px 10px; font-size: 13px; min-height: 44px; }
.btn-lg { padding: 12px 24px; font-size: 16px; }

/* ====== Header ====== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-subtle);
}
.header-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.logo-icon {
  font-size: 24px;
  line-height: 1;
}
.header-titles {
  display: flex;
  align-items: center;
  gap: 10px;
}
.header-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.header-badge {
  display: inline-block;
  padding: 2px 8px;
  background: var(--accent);
  color: #000;
  font-size: 11px;
  font-weight: 700;
  border-radius: var(--radius);
  letter-spacing: 0.03em;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ====== Hero ====== */
.hero {
  position: relative;
  overflow: hidden;
  height: 260px;
}
.hero-bg {
  position: absolute;
  inset: 0;
}
.hero-bg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.3;
}
.hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(15,23,42,0.92) 0%, rgba(30,41,59,0.85) 100%);
}
.hero-content {
  position: relative;
  max-width: 1440px;
  margin: 0 auto;
  padding: 48px 24px;
  text-align: center;
}
.hero-title {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 12px;
  animation: fadeUp 0.6s ease-out;
}
.hero-subtitle {
  font-size: 16px;
  color: var(--text-secondary);
  max-width: 640px;
  margin: 0 auto;
  animation: fadeUp 0.6s ease-out 0.15s both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ====== Features ====== */
.features {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
}
.features-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 40px 24px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}
.feature-card {
  padding: 20px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  transition: border-color var(--transition), transform var(--transition);
}
.feature-card:hover {
  border-color: var(--border);
  transform: translateY(-2px);
}
.feature-img {
  width: 100%;
  height: 120px;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
}
.feature-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.7;
  transition: opacity var(--transition);
}
.feature-card:hover .feature-img img { opacity: 0.9; }
.feature-card h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 8px;
}
.feature-card p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ====== Tool Workspace ====== */
.tool-workspace {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px;
}
.tool-grid {
  display: grid;
  grid-template-columns: 40% 60%;
  gap: 24px;
  min-height: 600px;
}

/* ====== Panels ====== */
.panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
}
.panel-header h2 {
  font-size: 16px;
  font-weight: 700;
}
.panel-actions {
  display: flex;
  gap: 6px;
}

/* ====== Input Panel ====== */
.input-panel {
  padding: 0;
}
.input-panel .drop-zone {
  margin: 16px 20px 0;
}
.input-panel .file-list {
  margin: 0 20px;
}
.input-panel .editor-wrap {
  margin: 12px 20px 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}
.input-panel .editor-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.input-panel .yaml-editor {
  flex: 1;
  min-height: 200px;
}
.input-panel #analyzeBtn {
  margin: 16px 20px;
}
.input-panel #progress {
  margin: 0 20px 16px;
}

/* ====== Drop Zone ====== */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  outline: none;
}
.drop-zone:hover,
.drop-zone:focus-visible {
  border-color: var(--accent);
  background: rgba(34,197,94,0.05);
}
.drop-zone.dragover {
  border-color: var(--accent);
  background: rgba(34,197,94,0.1);
}
.drop-zone svg {
  color: var(--text-muted);
  margin-bottom: 8px;
}
.drop-text {
  font-size: 14px;
  color: var(--text-secondary);
}
.drop-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ====== File List ====== */
.file-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.file-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--text-secondary);
}
.file-tag-remove {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1;
  background: none;
  border: none;
  padding: 0 2px;
}
.file-tag-remove:hover { color: var(--accent-error); }

/* ====== YAML Editor ====== */
.yaml-editor {
  width: 100%;
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 12px;
  font-family: var(--font-code);
  font-size: 13px;
  line-height: 1.6;
  resize: vertical;
  tab-size: 2;
  outline: none;
  transition: border-color var(--transition);
}
.yaml-editor:focus { border-color: var(--accent); }
.yaml-editor::placeholder { color: var(--text-muted); }

.yaml-status {
  font-size: 12px;
  margin-top: 4px;
  min-height: 18px;
}
.yaml-status.valid { color: var(--accent); }
.yaml-status.invalid { color: var(--accent-error); }
.yaml-status.info { color: var(--text-muted); }

/* ====== Progress ====== */
.progress-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
}
.progress-bar .progress-fill {
  flex: 1;
  height: 4px;
  background: var(--bg-surface);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}
.progress-bar .progress-fill::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 2px;
  animation: progressFill 2s ease-out forwards;
}
.progress-text {
  font-size: 12px;
  color: var(--text-secondary);
  min-width: 120px;
}

@keyframes progressFill {
  0% { width: 0; }
  30% { width: 40%; }
  60% { width: 70%; }
  100% { width: 100%; }
}

/* ====== Tabs ====== */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 20px;
}
.tab {
  padding: 12px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 14px;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
  min-height: 44px;
}
.tab:hover { color: var(--text-secondary); }
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ====== Tab Content ====== */
.tab-content {
  display: none;
  flex: 1;
  padding: 20px;
  overflow: auto;
}
.tab-content.active { display: flex; flex-direction: column; }

/* ====== States ====== */
.empty-state, .loading-state, .error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  text-align: center;
  color: var(--text-muted);
  padding: 40px 20px;
}
.empty-state svg, .error-state svg { margin-bottom: 16px; }
.empty-state p { font-size: 14px; }

.loading-state .spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--bg-surface);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-state svg { color: var(--accent-error); }
.error-msg { color: var(--accent-error); font-size: 14px; }

.partial-state {
  padding: 12px 16px;
  background: rgba(245,158,11,0.1);
  border: 1px solid rgba(245,158,11,0.3);
  border-radius: var(--radius);
  margin-bottom: 12px;
}
.partial-notice {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--accent-warning);
  font-size: 13px;
}

.hidden { display: none !important; }

/* ====== Screen Reader Only ====== */
.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;
}

/* ====== Format Bar ====== */
.format-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}
.format-toggles {
  display: flex;
  gap: 12px;
  border: none;
  padding: 0;
  margin: 0;
}
.toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
}
.toggle-label input[type="radio"] {
  accent-color: var(--accent);
}
.format-actions {
  display: flex;
  gap: 6px;
}

/* ====== Code Output ====== */
.code-output {
  flex: 1;
  background: var(--bg-primary);
  color: var(--accent);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 16px;
  font-family: var(--font-code);
  font-size: 13px;
  line-height: 1.7;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 300px;
}

/* ====== ISMS-P Table ====== */
.ismsp-table-wrap {
  flex: 1;
  overflow: auto;
}
.ismsp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.ismsp-table th, .ismsp-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}
.ismsp-table th {
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.ismsp-table td {
  color: var(--text-primary);
}
.ismsp-status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 700;
}
.ismsp-status.covered {
  background: rgba(34,197,94,0.15);
  color: var(--accent);
}
.ismsp-status.partial {
  background: rgba(245,158,11,0.15);
  color: var(--accent-warning);
}
.ismsp-status.missing {
  background: rgba(239,68,68,0.15);
  color: var(--accent-error);
}
.ismsp-detail {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  display: none;
}
.ismsp-row-expanded .ismsp-detail {
  display: block;
}
.ismsp-row {
  cursor: pointer;
  transition: background var(--transition);
}
.ismsp-row:hover { background: rgba(255,255,255,0.03); }

/* ====== Score Dashboard ====== */
.score-dashboard {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  flex: 1;
}
.score-gauge-wrap {
  position: relative;
  width: 200px;
  height: 200px;
}
.score-gauge {
  width: 100%;
  height: 100%;
}
.gauge-bg {
  stroke: var(--bg-surface);
}
.gauge-fill {
  stroke: var(--accent);
  transition: stroke-dasharray 1s ease-out, stroke var(--transition);
  stroke-linecap: round;
}
.gauge-fill.grade-a { stroke: var(--accent); }
.gauge-fill.grade-b { stroke: #3b82f6; }
.gauge-fill.grade-c { stroke: var(--accent-warning); }
.gauge-fill.grade-d { stroke: #f97316; }
.gauge-fill.grade-f { stroke: var(--accent-error); }

.gauge-score {
  fill: var(--text-primary);
  font-family: var(--font-code);
  font-size: 42px;
  font-weight: 700;
}
.gauge-grade {
  fill: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: 16px;
  font-weight: 700;
}

.score-breakdown {
  width: 100%;
  max-width: 480px;
}
.score-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 14px;
}
.score-item-label { color: var(--text-secondary); }
.score-item-value { font-family: var(--font-code); font-weight: 700; }
.score-item-value.pass { color: var(--accent); }
.score-item-value.fail { color: var(--accent-error); }

.score-recommendations {
  width: 100%;
  max-width: 480px;
}
.score-recommendations h4 {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-secondary);
}
.rec-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(245,158,11,0.08);
  border: 1px solid rgba(245,158,11,0.2);
  border-radius: var(--radius);
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}
.rec-item svg {
  flex-shrink: 0;
  color: var(--accent-warning);
  margin-top: 2px;
}

/* ====== CTA Section ====== */
.cta-section {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-subtle);
  padding: 64px 24px;
  text-align: center;
}
.cta-inner {
  max-width: 640px;
  margin: 0 auto;
}
.cta-inner h2 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 12px;
  letter-spacing: -0.02em;
}
.cta-inner p {
  color: var(--text-secondary);
  margin-bottom: 24px;
  line-height: 1.6;
}
.cta-btn {
  font-size: 16px;
  padding: 14px 32px;
}

/* ====== Footer ====== */
.footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-subtle);
}
.footer-inner {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-muted);
}
.footer-links {
  display: flex;
  gap: 16px;
}
.footer-links a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition);
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 4px;
}
.footer-links a:hover { color: var(--accent); }

/* ====== Toast ====== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text-primary);
  z-index: 200;
  animation: toastIn 0.3s ease-out;
  box-shadow: 0 4px 24px rgba(0,0,0,0.4);
}
.toast.toast-success { border-left: 3px solid var(--accent); }
.toast.toast-error { border-left: 3px solid var(--accent-error); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ====== Responsive ====== */
@media (max-width: 1023px) {
  .tool-grid {
    grid-template-columns: 50% 50%;
  }
  .hero-title { font-size: 28px; }
  .hero { height: 220px; }
  .features-inner { grid-template-columns: repeat(2, 1fr); gap: 16px; }
}
@media (max-width: 767px) {
  .tool-grid {
    grid-template-columns: 1fr;
    min-height: auto;
  }
  .hero { height: 200px; }
  .hero-title { font-size: 24px; }
  .hero-subtitle { font-size: 14px; }
  .features-inner {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .header-inner { padding: 10px 16px; }
  .header-title { font-size: 15px; }
  .header-badge { display: none; }
  .tool-workspace { padding: 16px; }
  .cta-section { padding: 48px 16px; }
  .cta-inner h2 { font-size: 22px; }
  .drop-zone { padding: 16px; }
  .format-bar { flex-direction: column; align-items: flex-start; }
  .footer-inner { flex-direction: column; gap: 8px; text-align: center; }
}

/* ====== Print ====== */
@media print {
  .header, .hero, .features, .cta-section, .footer,
  .input-panel, .format-bar, .tabs { display: none; }
  body { background: #fff; color: #000; }
  .tool-workspace { padding: 0; }
  .tool-grid { display: block; }
  .output-panel { border: none; }
  .tab-content:not(.hidden) { display: block !important; }
  .code-output {
    background: #f8f8f8;
    color: #000;
    border: 1px solid #ddd;
    font-size: 11px;
  }
  .ismsp-table th, .ismsp-table td {
    border-bottom: 1px solid #ddd;
    color: #000;
  }
  .ismsp-table th { background: #f0f0f0; }
  .score-gauge-wrap { break-inside: avoid; }
}
