/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: var(--fs-sm);
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  min-height: 38px;
  transition: all 150ms ease;
}

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

.btn-primary {
  background-color: var(--accent);
  color: var(--on-accent);
}
.btn-primary:hover:not(:disabled) {
  background-color: var(--accent-hover);
  color: var(--on-accent);
}

.btn-secondary {
  background-color: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) {
  background-color: var(--border);
}

.btn-danger {
  background-color: var(--danger);
  color: #FFFFFF;
}
.btn-danger:hover:not(:disabled) {
  background-color: #991B1B;
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: transparent;
}
.btn-ghost:hover:not(:disabled) {
  background-color: var(--surface-2);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-md);
}

/* Cards */
.card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

/* Inputs & Form */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-label {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text);
}

.form-control {
  width: 100%;
  padding: 8px 12px;
  font-size: 16px; /* Chống zoom trên iOS */
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background-color: var(--surface);
  color: var(--text);
  min-height: 40px;
  transition: border-color 150ms ease;
}

.form-control:focus {
  border-color: var(--accent);
}

/* Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: var(--border);
  transition: 200ms;
  border-radius: var(--radius-full);
}

.slider::before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 200ms;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--accent);
}

input:checked + .slider::before {
  transform: translateX(20px);
}

/* Tables */
.table-container {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background-color: var(--surface);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table th, .data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-sm);
}

.data-table th {
  background-color: var(--surface-2);
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: var(--fs-xs);
  letter-spacing: 0.05em;
}

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

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

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: var(--fs-xs);
  font-weight: 600;
}

.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger  { background: var(--danger-soft);  color: var(--danger); }
.badge-accent  { background: var(--accent-soft);  color: var(--accent); }

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

.stat-card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
}

.stat-label {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  margin-bottom: 4px;
}

.stat-value {
  font-size: var(--fs-2xl);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

/* Modal */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop.active {
  display: flex;
}

.modal-dialog {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 560px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.modal-body {
  padding: 20px;
  overflow-y: auto;
  max-height: calc(85dvh - 120px);
}

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: var(--fs-sm);
  min-width: 280px;
  animation: toastIn 150ms ease-out;
}

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

/* Terminal Console Window Styles (Tool_SZL Style) */
.terminal-window {
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
}

.terminal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: #161b22;
  border-bottom: 1px solid #30363d;
}

.terminal-dots {
  display: flex;
  align-items: center;
  gap: 8px;
}

.terminal-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  display: inline-block;
}

.terminal-dot.red { background: #ff5f56; box-shadow: 0 0 6px rgba(255, 95, 86, 0.4); }
.terminal-dot.yellow { background: #ffbd2e; box-shadow: 0 0 6px rgba(255, 189, 46, 0.4); }
.terminal-dot.green { background: #27c93f; box-shadow: 0 0 6px rgba(39, 201, 63, 0.4); }

.terminal-body {
  background: #090d13;
  padding: 18px 20px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.65;
  color: #c9d1d9;
  min-height: 480px;
  max-height: 620px;
  overflow-y: auto;
}

.terminal-line {
  margin-bottom: 4px;
  word-break: break-all;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.terminal-line .term-time {
  color: #6e7681;
  user-select: none;
  flex-shrink: 0;
}

.terminal-line .term-tag {
  font-weight: 700;
  padding: 0 4px;
  border-radius: 3px;
  font-size: 11px;
  flex-shrink: 0;
}

.terminal-line.info .term-tag { color: #58a6ff; background: rgba(56, 139, 253, 0.15); }
.terminal-line.success .term-tag { color: #3fb950; background: rgba(63, 185, 80, 0.15); }
.terminal-line.warning .term-tag { color: #d29922; background: rgba(210, 153, 34, 0.15); }
.terminal-line.error .term-tag { color: #f85149; background: rgba(248, 81, 73, 0.15); }
.terminal-line.action .term-tag { color: #bc8cff; background: rgba(188, 140, 255, 0.15); }

.terminal-line .term-bot {
  color: #79c0ff;
  font-weight: 600;
  flex-shrink: 0;
}

.terminal-line .term-grp {
  color: #a5d6ff;
  background: rgba(165, 214, 255, 0.1);
  padding: 0 4px;
  border-radius: 3px;
  flex-shrink: 0;
}

.terminal-line .term-msg {
  color: #e6edf3;
  flex: 1;
}

.terminal-line.error .term-msg {
  color: #ff7b72;
}

.terminal-line.warning .term-msg {
  color: #e3b341;
}

