/* ===========================
   ESG Kanban Dashboard Styles
   =========================== */

:root {
  /* Color System - Dark Mode */
  --bg-primary: #0f1117;
  --bg-secondary: #161823;
  --bg-card: #1c1e2e;
  --bg-card-hover: #232540;
  --bg-surface: #252840;
  --bg-modal: #1a1d30;

  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-active: rgba(255, 255, 255, 0.12);

  --text-primary: #e8eaed;
  --text-secondary: #9aa0b8;
  --text-muted: #5c6380;

  /* Accent Colors */
  --accent-blue: #4a9eff;
  --accent-green: #3dd68c;
  --accent-orange: #f0a855;
  --accent-red: #f06565;
  --accent-purple: #a78bfa;
  --accent-cyan: #22d3ee;

  /* Category Colors */
  --env-color: #3dd68c;
  --env-bg: rgba(61, 214, 140, 0.1);
  --soc-color: #4a9eff;
  --soc-bg: rgba(74, 158, 255, 0.1);
  --gov-color: #f0a855;
  --gov-bg: rgba(240, 168, 85, 0.1);

  /* Status Colors */
  --new-color: #a78bfa;
  --new-bg: rgba(167, 139, 250, 0.12);
  --mod-color: #22d3ee;
  --mod-bg: rgba(34, 211, 238, 0.12);

  /* Score Colors */
  --score-pass: #3dd68c;
  --score-fail: #f06565;

  /* Spacing */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  /* Typography */
  --font-sans: 'Inter', 'Noto Sans TC', -apple-system, BlinkMacSystemFont, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* === Header === */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.header-left { display: flex; align-items: center; gap: 16px; }
.header-right { display: flex; align-items: center; gap: 20px; }

.logo { display: flex; align-items: center; gap: 14px; }

.logo-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  border-radius: var(--radius-md);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  color: white;
}

.logo-text h1 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.3px;
}

.subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.stats {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: var(--text-secondary);
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.stat-count {
  font-weight: 600;
  color: var(--text-primary);
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-export {
  background: rgba(74, 158, 255, 0.12);
  color: var(--accent-blue);
}

.btn-export:hover {
  background: rgba(74, 158, 255, 0.22);
}

.btn-view {
  background: transparent;
  color: var(--text-muted);
  padding: 6px 12px;
}

.btn-view.active {
  background: var(--bg-surface);
  color: var(--text-primary);
}

.btn-view:hover:not(.active) {
  color: var(--text-secondary);
}

.btn-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}

.btn-close:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
}

/* === Toolbar === */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
  gap: 16px;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.view-toggle {
  display: flex;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.filter-group {
  display: flex;
  gap: 8px;
}

.filter-select {
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-family: var(--font-sans);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s;
}

.filter-select:hover { border-color: var(--border-active); }
.filter-select:focus { outline: none; border-color: var(--accent-blue); }

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  transition: border-color 0.15s;
}

.search-box:focus-within { border-color: var(--accent-blue); }

.search-box svg { color: var(--text-muted); flex-shrink: 0; }

.search-box input {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  width: 200px;
  outline: none;
}

.search-box input::placeholder { color: var(--text-muted); }

/* === Kanban === */
.kanban-container {
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 20px 24px;
}

.kanban-board {
  display: flex;
  gap: 16px;
  height: 100%;
  min-width: min-content;
}

.kanban-column {
  flex: 0 0 320px;
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
}

.kanban-column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.kanban-column-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
}

.column-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.kanban-column-count {
  background: var(--bg-surface);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
}

.kanban-column-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.kanban-column-body::-webkit-scrollbar {
  width: 4px;
}

.kanban-column-body::-webkit-scrollbar-track {
  background: transparent;
}

.kanban-column-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
}

/* === Card === */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-active);
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 8px;
}

.card-id {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.card-id.env { color: var(--env-color); }
.card-id.soc { color: var(--soc-color); }
.card-id.gov { color: var(--gov-color); }

.card-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  letter-spacing: 0.3px;
}

.card-badge.new {
  background: var(--new-bg);
  color: var(--new-color);
}

.card-badge.modified {
  background: var(--mod-bg);
  color: var(--mod-color);
}

.card-title {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 10px;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
}

.card-type {
  background: var(--bg-surface);
  color: var(--text-muted);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
}

.card-score {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

.card-score.pass { color: var(--score-pass); }
.card-score.fail { color: var(--score-fail); }
.card-score.na { color: var(--text-muted); }

.card-dept {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.card-ai-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  color: var(--accent-purple);
  margin-top: 6px;
}

/* === Table View === */
.table-container {
  flex: 1;
  overflow: auto;
  padding: 20px 24px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table thead th {
  position: sticky;
  top: 0;
  background: var(--bg-secondary);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.data-table tbody tr {
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background 0.15s;
}

.data-table tbody tr:hover {
  background: var(--bg-card-hover);
}

.data-table td {
  padding: 12px 14px;
  vertical-align: top;
}

.data-table td:nth-child(4) {
  max-width: 400px;
  white-space: normal;
  line-height: 1.5;
}

/* === Modal === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: var(--bg-modal);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  width: 90%;
  max-width: 780px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: slideUp 0.25s ease;
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 24px 28px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-title-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.modal-badge {
  display: inline-flex;
  align-self: flex-start;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 10px;
  letter-spacing: 0.3px;
}

.modal-header h2 {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.5;
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px 28px;
}

.modal-section {
  margin-bottom: 24px;
}

.modal-section:last-child {
  margin-bottom: 0;
}

.modal-section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.modal-section-content {
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
}

.modal-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.info-card {
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  padding: 14px;
}

.info-card-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 500;
}

.info-card-value {
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 600;
}

/* AI Suggestion in Modal */
.ai-section {
  background: linear-gradient(135deg, rgba(167, 139, 250, 0.06), rgba(74, 158, 255, 0.04));
  border: 1px solid rgba(167, 139, 250, 0.15);
  border-radius: var(--radius-md);
  padding: 20px;
}

.ai-section .modal-section-title {
  color: var(--accent-purple);
}

.ai-item {
  margin-bottom: 16px;
}

.ai-item:last-child { margin-bottom: 0; }

.ai-item-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-purple);
  margin-bottom: 6px;
}

.ai-item-content {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.ai-item-content ul {
  padding-left: 18px;
  margin-top: 4px;
}

.ai-item-content li {
  margin-bottom: 4px;
}

.ai-placeholder {
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
  font-size: 13px;
}

/* Score badge in modal */
.score-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13px;
}

.score-badge.pass {
  background: rgba(61, 214, 140, 0.12);
  color: var(--score-pass);
}

.score-badge.fail {
  background: rgba(240, 101, 101, 0.12);
  color: var(--score-fail);
}

/* === Compliance Section === */
.compliance-badge-sm {
  font-size: 12px;
  margin-left: 4px;
  cursor: help;
}

.compliance-section {
  background: linear-gradient(135deg, rgba(74, 158, 255, 0.06), rgba(61, 214, 140, 0.04));
  border: 1px solid rgba(74, 158, 255, 0.15);
  border-radius: var(--radius-md);
  padding: 20px;
}

.compliance-section .modal-section-title {
  color: var(--accent-blue);
}

.compliance-header {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.compliance-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 14px;
}

.compliance-full {
  background: rgba(61, 214, 140, 0.15);
  color: var(--score-pass);
}

.compliance-partial {
  background: rgba(255, 193, 7, 0.15);
  color: #ffc107;
}

.compliance-fail {
  background: rgba(240, 101, 101, 0.15);
  color: var(--score-fail);
}

.compliance-na {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
}

.compliance-confidence,
.compliance-urls {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.compliance-gap {
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.compliance-list-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin: 14px 0 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.compliance-list {
  padding-left: 20px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-secondary);
}

.compliance-list.matched li {
  color: var(--score-pass);
}

.compliance-list.matched li::marker {
  color: var(--score-pass);
}

.compliance-list.missing li {
  color: var(--score-fail);
}

.compliance-list.missing li::marker {
  color: var(--score-fail);
}

.url-analysis-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.url-analysis-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: rgba(0, 0, 0, 0.15);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 12px;
}

.url-analysis-item.irrelevant {
  opacity: 0.6;
}

.url-icon {
  flex-shrink: 0;
  font-size: 14px;
  margin-top: 1px;
}

.url-info {
  flex: 1;
  min-width: 0;
}

.url-path {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent-blue);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.url-summary {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

.compliance-recommendation {
  margin-top: 14px;
  background: rgba(255, 193, 7, 0.08);
  border: 1px solid rgba(255, 193, 7, 0.15);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-secondary);
}

.compliance-recommendation strong {
  color: #ffc107;
}

/* === Draft Section ===  */
.draft-section {
  background: linear-gradient(135deg, rgba(61, 214, 140, 0.06), rgba(74, 158, 255, 0.04));
  border: 1px solid rgba(61, 214, 140, 0.15);
  border-radius: var(--radius-md);
  padding: 20px;
}

.draft-section .modal-section-title {
  color: var(--accent-green);
}

.draft-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.draft-input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.draft-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.draft-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

.draft-required {
  color: var(--accent-red);
}

.draft-input {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  transition: border-color 0.15s;
}

.draft-input:focus {
  outline: none;
  border-color: var(--accent-green);
}

.draft-input::placeholder {
  color: var(--text-muted);
}

.draft-textarea {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.6;
  resize: vertical;
  min-height: 100px;
  transition: border-color 0.15s;
}

.draft-textarea:focus {
  outline: none;
  border-color: var(--accent-green);
}

.draft-textarea::placeholder {
  color: var(--text-muted);
}

.draft-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 4px;
}

.draft-submit-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent-green), #2bb878);
  color: #fff;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 12px rgba(61, 214, 140, 0.25);
}

.draft-submit-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(61, 214, 140, 0.35);
}

.draft-submit-btn:active:not(:disabled) {
  transform: translateY(0);
}

.draft-submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.draft-status {
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
}

.draft-status-success {
  color: var(--accent-green);
}

.draft-status-error {
  color: var(--accent-red);
}

@media (max-width: 768px) {
  .draft-input-row {
    grid-template-columns: 1fr;
  }
}

/* === Hidden === */
.hidden { display: none !important; }

/* === Responsive === */
@media (max-width: 768px) {
  .header { flex-direction: column; gap: 12px; align-items: flex-start; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-left { flex-wrap: wrap; }
  .filter-group { flex-wrap: wrap; }
  .kanban-column { flex: 0 0 280px; }
}
