/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.btn-success {
  background: var(--success-bg);
  color: #065f46;
  border: 1.5px solid var(--success-border);
}
.btn-success:hover:not(:disabled) { background: #dcfce7; }

.btn-danger {
  background: var(--danger-bg);
  color: #991b1b;
  border: 1.5px solid var(--danger-border);
}
.btn-danger:hover:not(:disabled) { background: #fee2e2; }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 14px 28px; font-size: 15px; border-radius: var(--radius); width: 100%; }
.btn-block { width: 100%; }

/* ========== Cards ========== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 24px;
}
.card + .card { margin-top: 16px; }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 8px;
}
.card-title { font-size: 16px; font-weight: 700; }
.card-sub { font-size: 13px; color: var(--text-secondary); }

/* ========== Forms ========== */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: all 0.15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.08);
}
.form-group textarea {
  resize: vertical;
  min-height: 100px;
  line-height: 1.6;
}
.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--text-muted);
}

/* ========== Tags ========== */
.tag {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 4px;
}
.tag-blue { background: var(--primary-light); color: var(--primary-dark); }
.tag-green { background: var(--success-bg); color: #065f46; }
.tag-yellow { background: var(--warning-bg); color: #92400e; }
.tag-red { background: var(--danger-bg); color: #991b1b; }
.tag-gray { background: var(--bg); color: var(--text-secondary); }

/* ========== Lists ========== */
.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s;
}
.list-item:last-child { border-bottom: none; }
.list-item:hover { background: var(--surface-hover); margin: 0 -12px; padding-left: 12px; padding-right: 12px; border-radius: var(--radius-sm); }
.list-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.list-content { flex: 1; min-width: 0; }
.list-title { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-desc { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.list-meta { font-size: 12px; color: var(--text-muted); white-space: nowrap; }

/* ========== Stats ========== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
  text-align: center;
}
.stat-value { font-size: 32px; font-weight: 800; color: var(--primary); margin-bottom: 4px; }
.stat-label { font-size: 13px; color: var(--text-secondary); }

/* ========== Modal ========== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 440px;
  padding: 28px;
  box-shadow: var(--shadow-lg);
  margin: 20px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.modal-header h2 { font-size: 18px; font-weight: 700; }
.modal-close {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--bg);
  cursor: pointer;
  font-size: 16px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-close:hover { background: var(--border); color: var(--text); }

/* ========== Toast ========== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--text);
  color: #fff;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  transition: all 0.3s;
  z-index: 300;
  pointer-events: none;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ========== Loading ========== */
.loading {
  display: none;
  text-align: center;
  padding: 48px 20px;
}
.loading.active { display: block; }
.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

/* ========== Empty State ========== */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}
.empty-state .icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ========== Login Wall ========== */
.login-wall {
  text-align: center;
  padding: 80px 20px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 2px dashed var(--border);
  margin-top: 24px;
}
.login-wall h3 { font-size: 20px; margin-bottom: 8px; }
.login-wall p { color: var(--text-secondary); font-size: 14px; margin-bottom: 20px; }

/* ========== Progress Bar ========== */
.progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
}
.progress-bar-fill.green { background: var(--success); }
.progress-bar-fill.yellow { background: var(--warning); }
.progress-bar-fill.red { background: var(--danger); }

/* ========== Violation Cards ========== */
.violation-card {
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  border: 1.5px solid;
}
.violation-card.redline {
  background: var(--danger-bg);
  border-color: var(--danger-border);
}
.violation-card.yellowline {
  background: var(--warning-bg);
  border-color: var(--warning-border);
}
.violation-card.tip {
  background: var(--primary-light);
  border-color: #bfdbfe;
}
.violation-card .v-level {
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.violation-card.redline .v-level { color: #991b1b; }
.violation-card.yellowline .v-level { color: #92400e; }
.violation-card.tip .v-level { color: var(--primary-dark); }
.violation-card .v-quote {
  font-size: 13px;
  font-style: italic;
  color: var(--text-secondary);
  margin-bottom: 8px;
  padding: 8px;
  background: rgba(255,255,255,0.5);
  border-radius: var(--radius-sm);
}
.violation-card .v-suggestion {
  font-size: 13px;
  color: var(--text);
  line-height: 1.6;
}

/* ========== Scene Cards ========== */
.scene-card {
  padding: 20px;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  transition: all 0.15s;
}
.scene-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); }
.scene-card.active { border-color: var(--primary); background: var(--primary-light); }
.scene-card.completed { border-color: var(--success); }
.scene-card.locked { opacity: 0.5; cursor: not-allowed; }
.scene-card .sc-icon { font-size: 28px; margin-bottom: 8px; }
.scene-card .sc-name { font-size: 14px; font-weight: 700; }
.scene-card .sc-desc { font-size: 12px; color: var(--text-secondary); margin-top: 4px; line-height: 1.5; }
.scene-card .sc-status { margin-top: 8px; }

/* ========== Chat/Message Styles ========== */
.chat-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
  background: var(--bg);
  border-radius: var(--radius);
  min-height: 300px;
  max-height: 500px;
  overflow-y: auto;
}
.message {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.6;
}
.message.ai {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}
.message.user {
  align-self: flex-end;
  background: var(--primary);
  color: #fff;
}
.message-system {
  align-self: center;
  font-size: 12px;
  color: var(--text-muted);
  padding: 4px 12px;
  background: var(--bg);
  border-radius: 12px;
}

/* ========== Report Styles ========== */
.report-header {
  text-align: center;
  padding: 32px 24px;
  background: linear-gradient(135deg, var(--primary-light), #fff);
  border-radius: var(--radius-lg);
  border: 2px solid var(--primary);
  margin-bottom: 24px;
}
.report-header .report-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--primary-dark);
  margin-bottom: 8px;
}
.report-header .report-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
}
.report-section {
  margin-bottom: 24px;
}
.report-section h4 {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
}
.signature-box {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
}
.signature-box.signed {
  border-color: var(--success);
  background: var(--success-bg);
}

/* ========== Auth Tabs ========== */
.auth-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  background: var(--bg);
  padding: 4px;
  border-radius: var(--radius-sm);
}
.auth-tab {
  flex: 1;
  padding: 8px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.15s;
}
.auth-tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

/* ========== Role Badge ========== */
.role-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
}
.role-badge.leader {
  background: var(--primary-light);
  color: var(--primary-dark);
}
.role-badge.trainee {
  background: var(--bg);
  color: var(--text-secondary);
}
