/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-weight: 500; font-size: 14px; transition: all var(--transition);
  white-space: nowrap; user-select: none;
}
.btn:hover { opacity: 0.9; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--primary-gradient); color: #fff; }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-lg { padding: 12px 24px; font-size: 16px; border-radius: var(--radius); }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; pointer-events: none; }

/* Badges */
.badge {
  display: inline-flex; align-items: center; padding: 2px 8px;
  border-radius: 100px; font-size: 12px; font-weight: 500;
}
.badge-success { background: var(--success-light); color: var(--success); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-info { background: var(--info-light); color: var(--info); }
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-muted { background: var(--border-light); color: var(--text-muted); }

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

/* Form Elements */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-bottom: 4px; }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-white); color: var(--text); transition: border-color var(--transition);
  outline: none; font-size: 14px;
}
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.form-textarea { resize: vertical; min-height: 80px; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 200ms ease;
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: var(--bg-card); border-radius: var(--radius-lg); box-shadow: var(--shadow-xl);
  width: 90%; max-width: 500px; max-height: 85vh; overflow-y: auto;
  animation: slideUp 250ms ease;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 20px; color: var(--text-muted); padding: 4px; }
.modal-body { padding: 20px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border); }

/* Loading overlay */
.loading-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.3); z-index: 3000;
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 200ms ease;
}
.loading-overlay.hidden { display: none; }
.loading-spinner {
  background: var(--bg-card); border-radius: var(--radius-lg); box-shadow: var(--shadow-xl);
  padding: 40px 48px; text-align: center;
}
.spinner {
  width: 40px; height: 40px; margin: 0 auto 12px;
  border: 4px solid var(--border); border-top-color: var(--primary); border-radius: 50%;
  animation: spin 600ms linear infinite;
}
.loading-text { color: var(--text-secondary); font-size: 14px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast */
.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 2000;
  background: var(--text); color: #fff; padding: 10px 24px;
  border-radius: var(--radius); font-size: 14px;
  animation: slideDown 250ms ease; pointer-events: none;
  max-width: 90vw; text-align: center;
}

/* Tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; font-size: 13px; }
.table th { text-align: left; padding: 10px 12px; background: var(--bg); color: var(--text-secondary); font-weight: 500; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border-light); color: var(--text); }
.table tr:hover td { background: rgba(0,0,0,0.01); }

/* Pagination */
.pagination { display: flex; align-items: center; justify-content: center; gap: 4px; margin-top: 16px; }
.pagination button {
  padding: 6px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-white); color: var(--text); font-size: 13px;
}
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination button:disabled { opacity: 0.5; }

/* Animations */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

/* Utils */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.gap-sm { gap: 8px; }
.gap { gap: 12px; }
.gap-lg { gap: 20px; }
.mt-sm { margin-top: 8px; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }
