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

:root {
  --color-bg: #f5f6f8;
  --color-surface: #ffffff;
  --color-primary: #2563eb;
  --color-primary-light: #dbeafe;
  --color-primary-dark: #1d4ed8;
  --color-text: #1e293b;
  --color-text-muted: #64748b;
  --color-border: #e2e8f0;
  --color-success: #16a34a;
  --color-warning: #d97706;
  --color-danger: #dc2626;
  --color-info: #0891b2;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* === Header === */
header {
  background: var(--color-primary);
  color: white;
  padding: 1.5rem 2rem;
  text-align: center;
}

header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

header .subtitle {
  font-size: 0.875rem;
  opacity: 0.85;
  margin-top: 0.25rem;
}

/* === Main === */
main {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem;
}

/* === Drop Zone === */
.drop-zone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  padding: 4rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}

.drop-zone.drag-over {
  transform: scale(1.01);
}

.drop-icon {
  color: var(--color-text-muted);
  margin-bottom: 1rem;
}

.drop-zone:hover .drop-icon,
.drop-zone.drag-over .drop-icon {
  color: var(--color-primary);
}

.drop-text {
  font-size: 1.125rem;
  color: var(--color-text);
  margin-bottom: 0.25rem;
}

.drop-subtext {
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

.xml-hint {
  margin-top: 0.75rem;
  font-size: 0.8rem;
  opacity: 0.7;
}

.report-header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* === Loading === */
.loading {
  text-align: center;
  padding: 4rem 2rem;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1rem;
}

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

.hidden {
  display: none !important;
}

/* === Report === */
.report-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.report-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
}

.reset-btn {
  background: var(--color-surface);
  color: var(--color-primary);
  border: 1px solid var(--color-primary);
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.15s;
}

.reset-btn:hover {
  background: var(--color-primary);
  color: white;
}

/* === Tabs === */
.tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--color-border);
  margin-bottom: 1.5rem;
  overflow-x: auto;
}

.tab {
  background: none;
  border: none;
  padding: 0.75rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-muted);
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
}

.tab:hover {
  color: var(--color-text);
}

.tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

/* === Stat Cards === */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.stat-card .stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--color-primary);
  line-height: 1.2;
}

.stat-card .stat-label {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.25rem;
}

.stat-card .stat-detail {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-top: 0.5rem;
}

/* === Tables === */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}

.data-table th,
.data-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.875rem;
}

.data-table th {
  background: var(--color-bg);
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  position: sticky;
  top: 0;
}

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

.data-table tr:hover td {
  background: var(--color-primary-light);
}

/* === Section Headers === */
.section-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-border);
}

/* === File Tree === */
.file-tree {
  font-family: "SF Mono", "Fira Code", "Fira Mono", Menlo, monospace;
  font-size: 0.8rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem;
  max-height: 600px;
  overflow-y: auto;
  box-shadow: var(--shadow);
}

.file-tree-item {
  padding: 0.2rem 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.file-tree-item .file-icon {
  width: 14px;
  text-align: center;
  flex-shrink: 0;
}

.file-tree-item .file-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-tree-item .file-size {
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.file-tree-item.type-xml .file-icon { color: #2563eb; }
.file-tree-item.type-image .file-icon { color: #16a34a; }
.file-tree-item.type-audio .file-icon { color: #d97706; }
.file-tree-item.type-video .file-icon { color: #9333ea; }
.file-tree-item.type-other .file-icon { color: #64748b; }

.file-tree-item.clickable {
  cursor: pointer;
}

.file-tree-item.clickable:hover {
  background: var(--color-primary-light);
  border-radius: 3px;
}

.folder-toggle {
  cursor: pointer;
  user-select: none;
}

.folder-contents {
  padding-left: 1.25rem;
}

.folder-contents.collapsed {
  display: none;
}

/* === Color Swatches === */
.color-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.color-swatch {
  width: 60px;
  height: 60px;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  position: relative;
  cursor: default;
  box-shadow: var(--shadow);
}

.color-swatch .color-label {
  position: absolute;
  bottom: -1.5rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.65rem;
  color: var(--color-text-muted);
  white-space: nowrap;
}

/* === XML Viewer === */
.xml-viewer-select {
  width: 100%;
  padding: 0.5rem;
  margin-bottom: 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.875rem;
}

.xml-content {
  font-family: "SF Mono", "Fira Code", "Fira Mono", Menlo, monospace;
  font-size: 0.8rem;
  background: #1e293b;
  color: #e2e8f0;
  padding: 1rem;
  border-radius: var(--radius);
  overflow: auto;
  max-height: 600px;
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.5;
}

.xml-content .xml-tag { color: #7dd3fc; }
.xml-content .xml-attr { color: #fbbf24; }
.xml-content .xml-value { color: #86efac; }
.xml-content .xml-comment { color: #64748b; }

/* === Badges === */
.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #e0f2fe; color: #075985; }

/* === Detail List === */
.detail-list {
  list-style: none;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}

.detail-list li {
  display: flex;
  justify-content: space-between;
  padding: 0.625rem 1rem;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.875rem;
}

.detail-list li:last-child {
  border-bottom: none;
}

.detail-list .label {
  color: var(--color-text-muted);
}

.detail-list .value {
  font-weight: 500;
}

/* === Empty State === */
.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--color-text-muted);
}

/* === Findings === */
.findings-summary {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.findings-summary-item {
  flex: 1;
  text-align: center;
  padding: 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 600;
}

.findings-summary-item .findings-count {
  display: block;
  font-size: 2rem;
  line-height: 1.2;
}

.findings-pass { background: #dcfce7; color: #166534; }
.findings-fail { background: #fee2e2; color: #991b1b; }
.findings-error { background: #fef3c7; color: #92400e; }
.findings-skip { background: var(--color-bg); color: var(--color-text-muted); }

.finding-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
  overflow: hidden;
}

.finding-card.finding-pass { border-left: 4px solid var(--color-success); }
.finding-card.finding-fail { border-left: 4px solid var(--color-danger); }
.finding-card.finding-error { border-left: 4px solid var(--color-warning); }
.finding-card.finding-skip { border-left: 4px solid var(--color-text-muted); }

.finding-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
}

.finding-status {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 0.25rem 0.625rem;
  border-radius: 4px;
  flex-shrink: 0;
}

.finding-pass .finding-status { background: #dcfce7; color: #166534; }
.finding-fail .finding-status { background: #fee2e2; color: #991b1b; }
.finding-error .finding-status { background: #fef3c7; color: #92400e; }
.finding-skip .finding-status { background: #f1f5f9; color: #64748b; }

.finding-title {
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.finding-id {
  font-family: "SF Mono", "Fira Code", Menlo, monospace;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  font-weight: 500;
}

.finding-body {
  padding: 1rem;
}

.finding-desc {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 0.75rem;
}

.finding-notes {
  font-size: 0.85rem;
  color: var(--color-text);
  background: var(--color-bg);
  padding: 0.625rem 0.875rem;
  border-radius: 6px;
  margin-bottom: 0.75rem;
  border: 1px solid var(--color-border);
}

.finding-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  font-size: 0.8rem;
  margin-bottom: 0.75rem;
}

.finding-stat {
  color: var(--color-text-muted);
}

.finding-stat strong {
  color: var(--color-text);
  font-weight: 600;
}

.finding-violation {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 6px;
  padding: 0.75rem 1rem;
  margin-top: 0.5rem;
}

.finding-violation-detail {
  font-size: 0.85rem;
  font-weight: 500;
  color: #991b1b;
  margin-bottom: 0.5rem;
}

.finding-violation-items {
  list-style: none;
  padding: 0;
  margin: 0;
}

.finding-violation-items li {
  font-size: 0.8rem;
  padding: 0.25rem 0;
  color: #7f1d1d;
  border-bottom: 1px solid #fecaca;
  font-family: "SF Mono", "Fira Code", Menlo, monospace;
  word-break: break-all;
}

.finding-violation-items li:last-child {
  border-bottom: none;
}

/* === Footer === */
footer {
  text-align: center;
  padding: 1rem 2rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

/* === Print === */
@media print {
  header { background: white; color: black; }
  .tab-bar, .reset-btn, .drop-zone, footer { display: none; }
  .panel { display: block !important; page-break-inside: avoid; }
  .data-table { box-shadow: none; border: 1px solid #ccc; }
}
