/* shadcn/ui inspired CSS - Dark/Light theme */
:root {
  --background: 0 0% 100%;
  --foreground: 240 10% 3.9%;
  --card: 0 0% 100%;
  --card-foreground: 240 10% 3.9%;
  --popover: 0 0% 100%;
  --popover-foreground: 240 10% 3.9%;
  --primary: 240 5.9% 10%;
  --primary-foreground: 0 0% 98%;
  --secondary: 240 4.8% 95.9%;
  --secondary-foreground: 240 5.9% 10%;
  --muted: 240 4.8% 95.9%;
  --muted-foreground: 240 3.8% 46.1%;
  --accent: 240 4.8% 95.9%;
  --accent-foreground: 240 5.9% 10%;
  --destructive: 0 84.2% 60.2%;
  --destructive-foreground: 0 0% 98%;
  --border: 240 5.9% 90%;
  --input: 240 5.9% 90%;
  --ring: 240 5.9% 10%;
  --radius: 0.5rem;
  --success: 142 76% 36%;
  --warning: 38 92% 50%;
  --info: 217 91% 60%;
  --sidebar-width: 260px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans KR", sans-serif;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  line-height: 1.6;
  font-size: 14px;
}

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

/* Layout */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width);
  background: hsl(var(--card));
  border-right: 1px solid hsl(var(--border));
  padding: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  z-index: 50;
}

.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid hsl(var(--border));
}

.sidebar-header h1 {
  font-size: 16px;
  font-weight: 700;
  color: hsl(var(--foreground));
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-header h1 svg { width: 20px; height: 20px; }

.sidebar-nav { padding: 12px 8px; }

.nav-section { margin-bottom: 16px; }
.nav-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: hsl(var(--muted-foreground));
  padding: 4px 12px;
  margin-bottom: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius);
  color: hsl(var(--muted-foreground));
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
}

.nav-item:hover {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
  text-decoration: none;
}

.nav-item.active {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-badge {
  margin-left: auto;
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 999px;
  font-weight: 600;
}
.nav-item.active .nav-badge {
  background: hsl(var(--primary-foreground) / 0.2);
  color: hsl(var(--primary-foreground));
}

.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
}

.page-header {
  padding: 24px 32px 16px;
  border-bottom: 1px solid hsl(var(--border));
  background: hsl(var(--card));
}

.page-header h2 {
  font-size: 22px;
  font-weight: 700;
  color: hsl(var(--foreground));
}

.page-header p {
  color: hsl(var(--muted-foreground));
  font-size: 13px;
  margin-top: 2px;
}

.page-body { padding: 24px 32px; }

/* Cards */
.card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  overflow: hidden;
}

.card-header { padding: 16px 20px 12px; }
.card-title { font-size: 15px; font-weight: 600; }
.card-description { font-size: 12px; color: hsl(var(--muted-foreground)); margin-top: 2px; }
.card-content { padding: 0 20px 16px; }
.card-footer {
  padding: 12px 20px;
  border-top: 1px solid hsl(var(--border));
  background: hsl(var(--muted) / 0.3);
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  padding: 20px;
}

.stat-card .stat-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  font-size: 18px;
}

.stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 4px;
}

.stat-card .stat-label {
  font-size: 12px;
  color: hsl(var(--muted-foreground));
  font-weight: 500;
}

.stat-icon.blue { background: hsl(217 91% 60% / 0.1); color: hsl(217 91% 60%); }
.stat-icon.green { background: hsl(142 76% 36% / 0.1); color: hsl(142 76% 36%); }
.stat-icon.orange { background: hsl(38 92% 50% / 0.1); color: hsl(38 92% 50%); }
.stat-icon.red { background: hsl(0 84% 60% / 0.1); color: hsl(0 84% 60%); }
.stat-icon.purple { background: hsl(262 83% 58% / 0.1); color: hsl(262 83% 58%); }

/* Table */
.table-wrapper { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  text-align: left;
  padding: 10px 12px;
  font-weight: 600;
  font-size: 12px;
  color: hsl(var(--muted-foreground));
  border-bottom: 1px solid hsl(var(--border));
  background: hsl(var(--muted) / 0.3);
  white-space: nowrap;
}

tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid hsl(var(--border));
  vertical-align: middle;
}

tbody tr:hover { background: hsl(var(--muted) / 0.4); }
tbody tr:last-child td { border-bottom: none; }

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-active { background: hsl(142 76% 36% / 0.1); color: hsl(142 76% 36%); }
.badge-closed { background: hsl(var(--muted)); color: hsl(var(--muted-foreground)); }
.badge-unread { background: hsl(0 84% 60% / 0.1); color: hsl(0 84% 60%); }
.badge-pass { background: hsl(217 91% 60% / 0.1); color: hsl(217 91% 60%); }
.badge-final { background: hsl(262 83% 58% / 0.1); color: hsl(262 83% 58%); }
.badge-pending { background: hsl(38 92% 50% / 0.1); color: hsl(38 92% 50%); }
.badge-running { background: hsl(217 91% 60% / 0.1); color: hsl(217 91% 60%); animation: pulse 2s infinite; }
.badge-completed { background: hsl(142 76% 36% / 0.1); color: hsl(142 76% 36%); }
.badge-failed { background: hsl(0 84% 60% / 0.1); color: hsl(0 84% 60%); }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn:hover { text-decoration: none; }

.btn-primary {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}
.btn-primary:hover { opacity: 0.9; }

.btn-secondary {
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
  border-color: hsl(var(--border));
}
.btn-secondary:hover { background: hsl(var(--accent)); }

.btn-destructive {
  background: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
}

.btn-outline {
  background: transparent;
  color: hsl(var(--foreground));
  border-color: hsl(var(--border));
}
.btn-outline:hover { background: hsl(var(--accent)); }

.btn-ghost { background: transparent; color: hsl(var(--foreground)); }
.btn-ghost:hover { background: hsl(var(--accent)); }

.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 10px 20px; font-size: 15px; }
.btn-icon { padding: 8px; }

.btn[disabled], .btn.loading {
  opacity: 0.5;
  pointer-events: none;
}

/* Input/Select */
.input, .select {
  padding: 8px 12px;
  border: 1px solid hsl(var(--input));
  border-radius: var(--radius);
  font-size: 13px;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  outline: none;
  transition: border-color 0.15s;
}

.input:focus, .select:focus {
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 2px hsl(var(--ring) / 0.1);
}

/* Tabs */
.tabs { display: flex; gap: 0; border-bottom: 1px solid hsl(var(--border)); margin-bottom: 20px; }

.tab-item {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
  cursor: pointer;
}

.tab-item:hover { color: hsl(var(--foreground)); text-decoration: none; }
.tab-item.active {
  color: hsl(var(--foreground));
  border-bottom-color: hsl(var(--primary));
}

/* Avatar */
.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  object-fit: cover;
  background: hsl(var(--muted));
  flex-shrink: 0;
}

.avatar-lg { width: 80px; height: 80px; }

/* Flex/Grid helpers */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mr-2 { margin-right: 8px; }
.p-4 { padding: 16px; }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.text-muted { color: hsl(var(--muted-foreground)); }
.text-right { text-align: right; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full { width: 100%; }

/* Grid */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

/* Profile */
.profile-header {
  display: flex;
  gap: 24px;
  padding: 24px;
}

.profile-info h3 { font-size: 20px; font-weight: 700; }
.profile-info .meta { color: hsl(var(--muted-foreground)); font-size: 13px; margin-top: 4px; }

.info-grid {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 8px 16px;
  font-size: 13px;
}

.info-grid dt { color: hsl(var(--muted-foreground)); font-weight: 500; }
.info-grid dd { color: hsl(var(--foreground)); }

/* Resume */
.resume-frame {
  width: 100%;
  min-height: 600px;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: white;
  padding: 24px;
}

/* Filter bar */
.filter-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: hsl(var(--muted-foreground));
}

.empty-state svg { width: 48px; height: 48px; margin-bottom: 12px; opacity: 0.3; }
.empty-state p { font-size: 14px; }

/* Alert styles */
.alert {
  padding: 1rem;
  border-radius: var(--radius);
  border: 1px solid;
  margin-bottom: 1rem;
}

.alert-warning {
  background: hsl(var(--warning) / 0.1);
  border-color: hsl(var(--warning) / 0.4);
  color: hsl(38 92% 30%);
}

.alert-warning strong {
  display: block;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.badge-warning {
  background: hsl(var(--warning) / 0.15);
  color: hsl(38 92% 35%);
  border: 1px solid hsl(var(--warning) / 0.3);
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .main-content { margin-left: 0; }

  /* Page chrome */
  .page-body { padding: 16px; }
  .page-header { padding: 16px 16px 12px; }
  .page-header h2 { font-size: 18px; }
  .page-header p { font-size: 12px; }

  /* Cards */
  .card-header { padding: 14px 16px 10px; }
  .card-content { padding: 0 16px 14px; }
  .card-footer { padding: 10px 16px; }

  /* Stats: compact 2-col, icon-left with value/label stacked on right */
  .stats-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 8px; margin-bottom: 16px; }
  .stat-card {
    padding: 10px 12px;
    display: grid;
    grid-template-columns: 32px 1fr;
    grid-template-rows: auto auto;
    column-gap: 10px;
    align-items: center;
  }
  .stat-card .stat-icon {
    grid-row: 1 / 3;
    width: 32px; height: 32px;
    margin: 0;
    font-size: 14px;
  }
  .stat-card .stat-value { grid-column: 2; grid-row: 1; font-size: 18px; }
  .stat-card .stat-label { grid-column: 2; grid-row: 2; font-size: 11px; }

  /* Generic grids collapse to 1 col */
  .grid-2, .grid-3 { grid-template-columns: 1fr !important; }

  /* Profile / detail pages */
  .profile-header { flex-direction: column; gap: 16px; padding: 16px; align-items: flex-start; }
  .info-grid { grid-template-columns: 88px 1fr; gap: 6px 12px; }
  .avatar-lg { width: 64px; height: 64px; }
  .resume-frame { padding: 14px; min-height: 480px; }

  /* Tabs scroll horizontally instead of wrapping */
  .tabs { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab-item { flex-shrink: 0; }

  /* Filter bar: kill inline fixed widths, let inputs grow */
  .filter-bar { gap: 6px; }
  .filter-bar > .input,
  .filter-bar > .select,
  .filter-bar input.input,
  .filter-bar select.select { flex: 1 1 calc(50% - 3px); width: auto !important; min-width: 0; }
  .filter-bar > .btn { flex: 1 1 auto; }

  /* Inputs: 16px to prevent iOS focus zoom + bigger touch */
  .input, .select, input.input, select.select, textarea { font-size: 16px; padding: 10px 12px; }

  /* Buttons: larger touch targets */
  .btn { padding: 10px 14px; font-size: 14px; min-height: 40px; }
  .btn-sm { padding: 6px 10px; font-size: 13px; min-height: 32px; }
  .btn-lg { padding: 12px 18px; font-size: 16px; }
  .btn-icon { padding: 10px; min-height: 40px; }

  /* Tables → card-style list on mobile */
  .table-wrapper { overflow-x: visible; -webkit-overflow-scrolling: touch; }
  .table-wrapper table,
  .table-wrapper tbody,
  .table-wrapper tr { display: block; width: 100%; }
  .table-wrapper thead { display: none; }
  .table-wrapper tbody tr {
    padding: 12px;
    border-bottom: 1px solid hsl(var(--border));
  }
  .table-wrapper tbody tr:last-child { border-bottom: none; }
  .table-wrapper tbody tr:hover { background: transparent; }
  .table-wrapper tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 4px 0;
    border-bottom: none;
    text-align: left;
    white-space: normal;
  }
  /* Use data-col / data-label as inline labels */
  .table-wrapper tbody td[data-col]::before,
  .table-wrapper tbody td[data-label]::before {
    content: attr(data-col) attr(data-label);
    font-weight: 600;
    color: hsl(var(--muted-foreground));
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex-shrink: 0;
  }
  /* Hide labels for non-data cells (avatar/checkbox/action) */
  .table-wrapper tbody td[data-col="avatar"]::before,
  .table-wrapper tbody td[data-col="check"]::before,
  .table-wrapper tbody td[data-col="action"]::before { content: none; }
  /* truncate becomes pointless when block; let it wrap */
  .table-wrapper tbody td.truncate {
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
    max-width: none !important;
  }
  /* Align action buttons to the right within their row */
  .table-wrapper tbody td[data-col="action"] { justify-content: flex-end; }

  /* Page-header right-aligned actions wrap below title */
  .page-header > .flex.justify-between { flex-wrap: wrap; gap: 8px; }
  /* Action / bulk bars wrap on small screens */
  .bulk-bar { flex-wrap: wrap; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr !important; }
  .page-header h2 { font-size: 16px; }
  .info-grid { grid-template-columns: 1fr; gap: 2px 0; }
  .info-grid dt { font-size: 11px; margin-top: 8px; }
  .filter-bar > .input,
  .filter-bar > .select { flex-basis: 100%; }
}
