/* BSM ENTERPRISE, LTD · AI Packaging Review Design Tokens & Layout */
:root {
  --primary: #28745a;
  --primary-dark: #19523f;
  --primary-light: #eef3ee;
  --accent: #d99b3d;
  --accent-dark: #b87f28;
  --bg: #f6f4ee;
  --surface: #ffffff;
  --panel: #eef3ee;
  --ink: #17211b;
  --muted: #66736b;
  --line: #d8ded8;
  --success: #2e7d32;
  --warning: #ed6c02;
  --danger: #d32f2f;
  --shadow: 0 4px 12px rgba(23, 33, 27, 0.06);
  --radius: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Microsoft YaHei", sans-serif;
  background-color: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Site Header */
.site-header {
  height: 54px;
  background-color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.brand-wrap { display: flex; align-items: center; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark { width: 32px; height: 32px; }
.brand-text { display: flex; flex-direction: column; }
.company-tag { font-size: 10px; color: #a5d6a7; font-weight: 700; letter-spacing: 0.5px; }
.app-title { font-size: 14px; font-weight: 700; color: #ffffff; }

.header-nav { display: flex; align-items: center; gap: 12px; }
.nav-link {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px; font-size: 13px; font-weight: 500;
  color: #e0f2f1; text-decoration: none; border-radius: 6px;
  transition: background-color 0.2s, color 0.2s;
}
.nav-link:hover { background-color: rgba(255,255,255,0.12); color: #fff; }
.nav-link.active { background-color: #ffffff; color: var(--primary); font-weight: 700; }

/* Main App Layout */
.app-layout {
  display: flex;
  flex: 1;
  padding: 14px;
  gap: 14px;
  max-width: 1680px;
  margin: 0 auto;
  width: 100%;
}

/* History Sidebar */
.history-sidebar {
  width: 320px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  max-height: calc(100vh - 82px);
}

.sidebar-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--primary-light);
  border-top-left-radius: var(--radius);
  border-top-right-radius: var(--radius);
}
.sidebar-header .title-row { display: flex; align-items: center; gap: 8px; }
.sidebar-header h2 { font-size: 14px; font-weight: 700; color: var(--primary); }
.count-badge { font-size: 12px; font-weight: 600; background: var(--primary); color: #fff; padding: 2px 8px; border-radius: 12px; }

.search-box { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.search-box input {
  width: 100%; padding: 7px 10px; font-size: 12px;
  border: 1px solid var(--line); border-radius: 6px; outline: none;
}
.search-box input:focus { border-color: var(--primary); }

.history-list {
  list-style: none; overflow-y: auto; flex: 1; padding: 6px;
}
.empty-hint { text-align: center; color: var(--muted); font-size: 12px; padding: 20px 0; }

.history-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 6px; cursor: pointer;
  border-bottom: 1px dashed var(--line);
  transition: background 0.15s;
}
.history-item:hover { background: var(--panel); }
.history-item.active { background: #e0f2f1; border-color: var(--primary); }

.history-thumb { width: 44px; height: 44px; border-radius: 4px; object-fit: cover; border: 1px solid var(--line); }
.history-info { flex: 1; min-width: 0; }
.history-title { font-size: 12px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-meta { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); margin-top: 2px; }
.v-badge { font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 4px; }
.v-pass { background: #e8f5e9; color: var(--success); }
.v-warning { background: #fff3e0; color: var(--warning); }
.v-risk { background: #ffebee; color: var(--danger); }
.v-pending { background: #e3f2fd; color: #1976d2; }

/* Main Content Area */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

/* Banner Card */
.banner-card {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #ffffff;
  padding: 16px 20px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
}
.banner-info h1 { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.banner-info p { font-size: 12px; color: #e0f2f1; line-height: 1.4; }
.banner-badge .badge-tag {
  background: var(--accent); color: #fff; font-size: 11px; font-weight: 700;
  padding: 4px 10px; border-radius: 12px; white-space: nowrap;
}

/* Upload Card */
.review-upload-panel {
  display: flex; flex-direction: column; gap: 12px;
}
.upload-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px;
}
.upload-card {
  background: var(--surface);
  border: 2px dashed var(--primary);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  box-shadow: var(--shadow);
}
.reference-card { border-color: var(--accent); }
.upload-icon { font-size: 36px; line-height: 1; }
.file-summary {
  width: 100%; margin-top: 10px; font-size: 11px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.start-review {
  align-self: center; min-width: 260px; background: var(--accent); color: #fff;
  font-size: 14px; padding: 10px 20px;
}
.start-review:hover { background: var(--accent-dark); }
.start-review:disabled { opacity: .45; cursor: not-allowed; }
.upload-card:hover, .upload-card.drag-over {
  background: #f0f7f4;
  border-color: var(--accent);
}
.upload-icon { color: var(--primary); margin-bottom: 8px; }
.upload-text h3 { font-size: 15px; font-weight: 700; color: var(--ink); margin-bottom: 4px; }
.upload-text p { font-size: 12px; color: var(--muted); margin-bottom: 12px; }

/* Buttons */
.btn {
  font-family: inherit; font-size: 13px; font-weight: 600;
  border: none; border-radius: 6px; cursor: pointer;
  padding: 8px 16px; transition: background 0.2s, transform 0.1s;
}
.btn:active { transform: scale(0.98); }
.btn:focus-visible, .nav-link:focus-visible, input:focus-visible {
  outline: 3px solid rgba(217, 155, 61, .55); outline-offset: 2px;
}
.btn.primary-action { background: var(--primary); color: #fff; }
.btn.primary-action:hover { background: var(--primary-dark); }
.btn.secondary-action { background: var(--accent); color: #fff; }
.btn.secondary-action:hover { background: var(--accent-dark); }
.btn.soft-sm { background: var(--panel); color: var(--ink); border: 1px solid var(--line); font-size: 12px; padding: 4px 10px; }
.btn.soft-sm:hover { background: #d0e3d8; }

/* Queue Dashboard */
.queue-dashboard {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
  box-shadow: var(--shadow);
}
.queue-summary {
  display: flex; align-items: center; justify-content: space-around; margin-bottom: 10px;
}
.metric { display: flex; flex-direction: column; align-items: center; }
.metric .label { font-size: 11px; color: var(--muted); }
.metric .num { font-size: 18px; font-weight: 800; }
.text-warning { color: var(--warning); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }

.progress-bar-wrap { height: 6px; background: var(--panel); border-radius: 3px; overflow: hidden; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--accent), var(--primary)); transition: width 0.3s; }

/* Results Section */
.results-section {
  display: flex; flex-direction: column; gap: 10px;
}
.section-title-row {
  display: flex; align-items: center; justify-content: space-between;
}
.section-title-row h2 { font-size: 15px; font-weight: 700; color: var(--primary); }
.actions-group { display: flex; gap: 8px; }

.results-list { display: flex; flex-direction: column; gap: 12px; }
.empty-state {
  background: var(--surface); border: 1px dashed var(--line);
  border-radius: var(--radius); padding: 40px; text-align: center; color: var(--muted);
}
.empty-state svg { color: var(--muted); margin-bottom: 8px; }

/* Result Card */
.result-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.result-card.status-risk { border-left: 4px solid var(--danger); }
.result-card.status-warning { border-left: 4px solid var(--warning); }
.result-card.status-pass { border-left: 4px solid var(--success); }
.result-card.status-pending { border-left: 4px solid #1976d2; }

.card-top {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 16px; background: #fbfcfb; border-bottom: 1px solid var(--line);
}
.thumb-preview {
  width: 72px; height: 72px; border-radius: 6px; object-fit: cover;
  border: 1px solid var(--line); cursor: pointer; flex-shrink: 0;
}
.card-details { flex: 1; min-width: 0; }
.card-filename { font-size: 14px; font-weight: 700; color: var(--ink); margin-bottom: 4px; word-break: break-all; }
.card-badges { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.badge-item { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 4px; }
.bg-lang { background: #e0f7fa; color: #006064; }
.bg-reference { background: #fff6e6; color: #8a5a11; }

@media (max-width: 900px) {
  .upload-grid { grid-template-columns: 1fr; }
  .site-header { height: auto; padding: 10px 14px; align-items: flex-start; gap: 10px; }
  .header-nav { max-width: 55vw; overflow-x: auto; padding-bottom: 4px; }
  .app-layout { flex-direction: column; padding: 10px; }
  .history-sidebar { width: 100%; max-height: 240px; }
  .banner-card { align-items: flex-start; gap: 10px; }
  .start-review { width: 100%; min-width: 0; min-height: 44px; }
  .btn { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

.card-report-body {
  padding: 16px; font-size: 13px; line-height: 1.6; color: #2d3748;
}

/* Markdown Styling */
.card-report-body h1, .card-report-body h2, .card-report-body h3 {
  font-size: 14px; font-weight: 700; color: var(--primary); margin: 10px 0 6px 0;
  border-bottom: 1px solid #edf2f7; padding-bottom: 4px;
}
.card-report-body ul, .card-report-body ol { padding-left: 20px; margin-bottom: 8px; }
.card-report-body li { margin-bottom: 4px; }
.card-report-body strong { color: #1a202c; font-weight: 700; }
.card-report-body code { background: #f7fafc; padding: 2px 6px; border-radius: 4px; font-family: monospace; font-size: 12px; color: #c53030; }

.card-footer {
  padding: 8px 16px; background: var(--panel); border-top: 1px solid var(--line);
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
}

.hidden { display: none !important; }

.loading-overlay {
  position: fixed; inset: 0; z-index: 1200; display: grid; place-items: center;
  padding: 20px; background: rgba(12, 28, 24, 0.5); backdrop-filter: blur(2px);
}
.loading-card {
  min-width: min(360px, 92vw); padding: 24px; border-radius: 16px;
  background: var(--surface); box-shadow: 0 24px 70px rgba(0,0,0,.25); text-align: center;
}
.loading-spinner {
  width: 36px; height: 36px; margin: 0 auto 14px; border-radius: 50%;
  border: 4px solid #d9ebe5; border-top-color: var(--primary);
  animation: loading-spin .8s linear infinite;
}
.loading-card p { margin: 7px 0 0; color: var(--muted); }
@keyframes loading-spin { to { transform: rotate(360deg); } }

/* Modal */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.75); display: flex; align-items: center; justify-content: center;
  z-index: 999; padding: 20px;
}
.modal-content {
  position: relative; max-width: 90vw; max-height: 90vh; background: #fff; border-radius: 8px; overflow: hidden;
}
.modal-content img { max-width: 90vw; max-height: 90vh; display: block; }
.modal-close {
  position: absolute; top: 10px; right: 10px; background: rgba(0,0,0,0.6); color: #fff;
  border: none; width: 30px; height: 30px; border-radius: 50%; cursor: pointer; font-size: 16px;
}
