/* ============================================================
   Compliance Test Platform — Global Styles
   ============================================================ */

:root {
  --bg: #f6f9fc;
  --card: #ffffff;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --muted: #6b7280;
  --border: #e5e7eb;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --success: #22c55e;
  --warning: #f59e0b;
  --nav-bg: #0f172a;
  --nav-text: #e2e8f0;
  --sidebar-bg: #f8fafc;
  --sidebar-border: #e5e7eb;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  font-size: 14px;
  color: #111827;
  background: var(--bg);
  line-height: 1.5;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 12px 0; font-weight: 600; }

/* ---- Navigation Bar ---- */
.nav-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: 56px;
  background: var(--nav-bg);
  color: var(--nav-text);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 32px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.nav-bar .nav-title {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.nav-bar .nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-bar .nav-link {
  color: var(--nav-text);
  font-size: 14px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
}

.nav-bar .nav-link:hover,
.nav-bar .nav-link.active {
  background: rgba(255,255,255,0.12);
  color: #fff;
  text-decoration: none;
}

/* ---- Page Wrapper ---- */
.page-wrapper {
  padding-top: 56px; /* account for fixed nav */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---- Layout: Sidebar + Main ---- */
.layout {
  display: flex;
  flex: 1;
  min-height: calc(100vh - 56px);
}

/* ---- Sidebar ---- */
.sidebar {
  width: 240px;
  min-width: 240px;
  max-width: 240px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 16px 0;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px 12px 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.sidebar-header h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0;
}

.sidebar-item {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  cursor: pointer;
  border-radius: 6px;
  margin: 1px 8px;
  font-size: 14px;
  color: #374151;
  transition: background 0.12s;
  gap: 8px;
  user-select: none;
}

.sidebar-item:hover {
  background: #eff6ff;
  color: var(--accent);
}

.sidebar-item.active {
  background: #dbeafe;
  color: var(--accent);
  font-weight: 600;
}

.sidebar-item .item-count {
  margin-left: auto;
  font-size: 11px;
  background: #e5e7eb;
  color: var(--muted);
  padding: 1px 7px;
  border-radius: 99px;
  font-weight: 500;
}

.sidebar-item .item-remove {
  margin-left: auto;
  background: transparent;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  font-size: 14px;
  padding: 0 2px;
  line-height: 1;
  border-radius: 3px;
  display: none;
}

.sidebar-item:hover .item-remove {
  display: inline;
}

.sidebar-item .item-remove:hover {
  color: var(--danger);
  background: #fee2e2;
}

/* Group name input inline */
.new-group-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  margin: 0 8px;
}

.new-group-input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 13px;
  outline: none;
}

.new-group-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(37,99,235,0.15);
}

/* ---- Main Content Area ---- */
.main-content {
  flex: 1;
  overflow: auto;
  padding: 24px;
  min-width: 0;
}

/* ---- Toolbar ---- */
.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.toolbar-right {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  border: none;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s, opacity 0.15s;
  white-space: nowrap;
  line-height: 1.4;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 3px rgba(37,99,235,0.25);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: 0 2px 6px rgba(37,99,235,0.3);
}

.btn-secondary {
  background: #fff;
  color: #374151;
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: #f9fafb;
  border-color: #d1d5db;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger-hover);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 5px;
}

.btn-icon {
  padding: 6px 8px;
  border-radius: 6px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}

.btn-icon:hover {
  background: #f3f4f6;
  color: #374151;
}

/* ---- Form Controls ---- */
input[type="text"],
input[type="search"],
input[type="number"],
select,
textarea {
  font-family: var(--font);
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 7px 10px;
  background: #fff;
  color: #111827;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input[type="text"]:focus,
input[type="search"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

select {
  cursor: pointer;
}

/* ---- Cards ---- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 20px;
  box-shadow: 0 1px 3px rgba(16,24,40,0.04);
}

/* ---- Tables ---- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.data-table thead {
  background: #f8fafc;
}

.data-table th {
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #f0f2f5;
  vertical-align: middle;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover {
  background: #f9fafb;
}

.data-table .col-check {
  width: 36px;
  text-align: center;
}

/* ---- Level Badges ---- */
.level-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.level-badge.LEVEL_1 {
  background: #dbeafe;
  color: #1e40af;
}

.level-badge.LEVEL_2 {
  background: #f3f4f6;
  color: #374151;
  border: 1px solid #e5e7eb;
}

.level-badge.REJECT {
  background: #fee2e2;
  color: #991b1b;
}

.level-badge.MANUAL_REVIEW {
  background: #fef3c7;
  color: #92400e;
}

.level-badge.unknown {
  background: #f3f4f6;
  color: #9ca3af;
}

/* ---- Status Badges ---- */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.status-badge.pending {
  background: #f3f4f6;
  color: #6b7280;
}

.status-badge.running {
  background: #dbeafe;
  color: #1e40af;
}

.status-badge.running::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse-dot 1.2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

.status-badge.completed {
  background: #dcfce7;
  color: #15803d;
}

.status-badge.failed {
  background: #fee2e2;
  color: #991b1b;
}

/* ---- Tag Chips ---- */
.tags-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  min-width: 100px;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  border-radius: 99px;
  padding: 1px 8px 1px 8px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

.tag-chip .tag-remove {
  background: transparent;
  border: none;
  cursor: pointer;
  color: #60a5fa;
  padding: 0;
  margin-left: 2px;
  font-size: 12px;
  line-height: 1;
  border-radius: 50%;
  width: 14px;
  height: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tag-chip .tag-remove:hover {
  background: #bfdbfe;
  color: #1d4ed8;
}

.tag-add-btn {
  background: transparent;
  border: 1px dashed #93c5fd;
  color: #60a5fa;
  border-radius: 99px;
  padding: 1px 7px;
  font-size: 11px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.12s;
}

.tag-add-btn:hover {
  background: #eff6ff;
  border-color: var(--accent);
  color: var(--accent);
}

.tag-input-inline {
  border: 1px solid var(--accent);
  border-radius: 99px;
  padding: 1px 8px;
  font-size: 11px;
  outline: none;
  width: 80px;
}

/* ---- Floating Action Bar ---- */
.floating-bar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 12px;
  background: #0f172a;
  color: #fff;
  border-radius: 12px;
  padding: 12px 20px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3), 0 2px 8px rgba(0,0,0,0.2);
  min-width: 560px;
  flex-wrap: wrap;
  animation: slideUp 0.2s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.floating-bar .selected-count {
  font-size: 13px;
  font-weight: 600;
  color: #93c5fd;
  white-space: nowrap;
}

.floating-bar input[type="text"] {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  flex: 1;
  min-width: 160px;
}

.floating-bar input[type="text"]::placeholder {
  color: rgba(255,255,255,0.4);
}

.floating-bar input[type="text"]:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 2px rgba(96,165,250,0.2);
}

.floating-bar .concurrency-label {
  font-size: 12px;
  color: #94a3b8;
  white-space: nowrap;
}

.floating-bar input[type="range"] {
  width: 80px;
  accent-color: var(--accent);
}

.floating-bar .concurrency-val {
  font-size: 13px;
  font-weight: 600;
  color: #e2e8f0;
  min-width: 16px;
}

/* ---- CSV Dropzone ---- */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 32px;
  text-align: center;
  cursor: pointer;
  background: linear-gradient(180deg, rgba(37,99,235,0.02), transparent);
  transition: border-color 0.15s, background 0.15s;
  margin-bottom: 16px;
}

.dropzone.dragover {
  border-color: var(--accent);
  background: rgba(37,99,235,0.05);
}

.dropzone p {
  margin: 4px 0;
  color: var(--muted);
  font-size: 13px;
}

.dropzone .drop-icon {
  font-size: 28px;
  margin-bottom: 8px;
}

/* ---- Progress Bar ---- */
.progress-bar-container {
  width: 100%;
  background: #e5e7eb;
  border-radius: 99px;
  height: 8px;
  overflow: hidden;
  margin: 8px 0;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #60a5fa);
  border-radius: 99px;
  transition: width 0.4s ease;
  min-width: 4px;
}

.progress-label {
  font-size: 12px;
  color: var(--muted);
  text-align: right;
  margin-top: 4px;
}

/* ---- Stats Cards Row ---- */
.stats-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.stat-card {
  flex: 1;
  min-width: 110px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  box-shadow: 0 1px 3px rgba(16,24,40,0.04);
}

.stat-card .stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.stat-card .stat-value {
  font-size: 22px;
  font-weight: 700;
  color: #111827;
  line-height: 1.1;
}

.stat-card .stat-pct {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

/* ---- Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-box {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  width: min(760px, 92vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  animation: slideDown 0.18s ease;
}

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

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
  padding: 0 4px;
  border-radius: 4px;
}

.modal-close:hover {
  color: #111827;
  background: #f3f4f6;
}

.modal-body {
  padding: 16px 20px;
  overflow: auto;
  flex: 1;
}

.modal-body pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--mono);
  font-size: 12px;
  background: #0f1724;
  color: #e6eef8;
  border-radius: 8px;
  padding: 14px 16px;
  max-height: 56vh;
  overflow: auto;
}

/* ---- Toast Notifications ---- */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #1e293b;
  color: #f1f5f9;
  border-radius: 8px;
  padding: 11px 16px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  pointer-events: auto;
  animation: toastIn 0.2s ease;
  min-width: 240px;
  max-width: 360px;
}

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

.toast.success .toast-icon { color: #4ade80; }
.toast.error .toast-icon   { color: #f87171; }
.toast.info .toast-icon    { color: #60a5fa; }

.toast.fade-out {
  animation: toastOut 0.3s ease forwards;
}

@keyframes toastOut {
  to { opacity: 0; transform: translateY(8px); }
}

/* ---- Filter Tabs ---- */
.filter-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-tab {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  border: none;
  background: transparent;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.12s, border-color 0.12s;
  border-radius: 4px 4px 0 0;
}

.filter-tab:hover {
  color: #374151;
}

.filter-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* ---- Pagination ---- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
  font-size: 13px;
  color: var(--muted);
}

.pagination .page-info {
  white-space: nowrap;
}

/* ---- Correct/Incorrect indicators ---- */
.correct-yes { color: var(--success); font-weight: 700; font-size: 15px; }
.correct-no  { color: var(--danger);  font-weight: 700; font-size: 15px; }
.correct-na  { color: #d1d5db; font-size: 13px; }

/* ---- Skill editor ---- */
.skill-textarea {
  width: 100%;
  height: 580px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.55;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  resize: vertical;
  color: #1e293b;
  background: #fafbfc;
}

.skill-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
  background: #fff;
}

.skill-textarea[readonly] {
  background: #f1f5f9;
  color: var(--muted);
  cursor: default;
}

/* ---- Version History Table ---- */
.version-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--mono);
}

/* ---- Import Result Summary ---- */
.import-result {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 13px;
  color: #166534;
  margin-top: 8px;
}

.import-result.has-errors {
  background: #fff7ed;
  border-color: #fed7aa;
  color: #9a3412;
}

/* ---- Misc Utilities ---- */
.text-muted   { color: var(--muted); }
.text-sm      { font-size: 12px; }
.text-center  { text-align: center; }
.mt-8         { margin-top: 8px; }
.mt-12        { margin-top: 12px; }
.mt-16        { margin-top: 16px; }
.mb-8         { margin-bottom: 8px; }
.mb-12        { margin-bottom: 12px; }
.mb-16        { margin-bottom: 16px; }
.flex         { display: flex; }
.flex-1       { flex: 1; }
.items-center { align-items: center; }
.gap-8        { gap: 8px; }
.gap-12       { gap: 12px; }

.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--muted);
}

.empty-state .empty-icon {
  font-size: 36px;
  margin-bottom: 12px;
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .sidebar {
    width: 200px;
    min-width: 200px;
  }
  .floating-bar {
    min-width: calc(100vw - 32px);
    left: 16px;
    right: 16px;
    transform: none;
  }
}

@media (max-width: 640px) {
  .layout {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    max-width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 8px 0;
  }
  .main-content {
    padding: 16px;
  }
  .stats-row {
    gap: 8px;
  }
}
