/* ============================================================
   COMPONENTS.CSS — Button, Card, Form, Table, Badge, Modal, Toast
   KazeX Sport Manager PWA
   ============================================================ */

/* ---------- BUTTONS ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-6);
  padding: var(--space-10) var(--space-16);
  font-family: var(--font-family);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  line-height: 1;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  min-height: 44px;
  user-select: none;
  -webkit-user-select: none;
  position: relative;
  overflow: hidden;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary {
  background: linear-gradient(135deg, var(--color-primary) 0%, #0d6d66 100%);
  color: var(--color-text-inverse);
  box-shadow: 0 2px 8px rgba(15, 118, 110, 0.25);
}
.btn-primary:hover { box-shadow: 0 4px 16px rgba(15, 118, 110, 0.35); }

.btn-danger {
  background: var(--color-danger);
  color: var(--color-text-inverse);
}
.btn-danger:hover { background: #b91c1c; }

.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
}
.btn-ghost:hover { background: var(--color-surface-active); }

.btn-outline {
  background: transparent;
  color: var(--color-primary);
  border-color: var(--color-primary);
}
.btn-outline:hover { background: var(--color-primary-subtle); }

.btn-sm { padding: var(--space-6) var(--space-12); min-height: 36px; font-size: var(--text-sm); }
.btn-lg { padding: var(--space-12) var(--space-20); min-height: 48px; font-size: var(--text-md); }
.btn-block { width: 100%; }
.btn-icon { padding: var(--space-8); min-width: 44px; }

/* Ripple effect */
.btn .ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
  transform: scale(0);
  animation: ripple-anim 0.5s ease-out;
  pointer-events: none;
}
@keyframes ripple-anim {
  to { transform: scale(4); opacity: 0; }
}

/* ---------- CARD ---------- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-xl);
  padding: var(--space-20);
  box-shadow: var(--shadow-xs);
  transition: all 0.2s ease;
}
.card-hover:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-12); }
.card-title { font-size: var(--text-md); font-weight: var(--weight-semibold); }
.card-body { }
.card-footer { margin-top: var(--space-12); padding-top: var(--space-12); border-top: 1px solid var(--color-border-light); }

/* ---------- FORM ---------- */
.form-group { margin-bottom: var(--space-16); }
.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-6);
}
.form-hint { font-size: var(--text-xs); color: var(--color-text-muted); margin-top: var(--space-4); }
.form-error { font-size: var(--text-xs); color: var(--color-danger); margin-top: var(--space-4); }

.input, .select, .textarea {
  width: 100%;
  padding: var(--space-10) var(--space-12);
  font-family: var(--font-family);
  font-size: var(--text-base);
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  min-height: 44px;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb), 0.12);
  outline: none;
}
.input::placeholder { color: var(--color-text-placeholder); }
.input.input-error { border-color: var(--color-danger); }

.input-wrapper {
  position: relative;
}
.input-wrapper .input { padding-right: 44px; }
.input-icon-btn {
  position: absolute;
  right: 0;
  top: 0;
  width: 44px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
}

.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
.textarea { min-height: 80px; resize: vertical; }

.form-row { display: flex; gap: var(--space-12); }
.form-row .form-group { flex: 1; }

/* ---------- BADGE ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-2) var(--space-8);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  border-radius: var(--radius-full);
  line-height: 1.4;
}
.badge-success { background: var(--color-success-light); color: var(--color-success); }
.badge-warning { background: var(--color-warning-light); color: var(--color-warning); }
.badge-danger { background: var(--color-danger-light); color: var(--color-danger); }
.badge-info { background: var(--color-info-light); color: var(--color-info); }
.badge-primary { background: var(--color-primary-light); color: var(--color-primary); }
.badge-neutral { background: var(--color-surface-active); color: var(--color-text-muted); }
.badge-outline {
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

/* ---------- TABLE ---------- */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
.table th {
  text-align: left;
  padding: var(--space-10) var(--space-12);
  font-weight: var(--weight-medium);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}
.table td {
  padding: var(--space-10) var(--space-12);
  border-bottom: 1px solid var(--color-border-light);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--color-surface-hover); }

/* ---------- MODAL ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: modal-in 0.2s ease;
}
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: var(--z-modal-backdrop);
}
.modal-content {
  position: relative;
  z-index: var(--z-modal);
  background: var(--color-surface);
  border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slide-up 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 -8px 40px rgba(0,0,0,0.15);
}
.modal-sm .modal-content,
.modal-content.modal-sm { max-width: 360px; }
.modal-content.modal-fullscreen {
  max-width: 100%;
  height: 100vh;
  border-radius: 0;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-20) var(--space-24);
  border-bottom: 1px solid var(--color-border-light);
}
.modal-title { font-size: var(--text-lg); font-weight: var(--weight-bold); letter-spacing: -0.3px; }
.modal-body { padding: var(--space-24); }
.modal-footer {
  padding: var(--space-16) var(--space-24);
  border-top: 1px solid var(--color-border-light);
}
.modal-footer-split { display: flex; gap: var(--space-12); }
.modal-footer-split .btn { flex: 1; }

@keyframes modal-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide-up { from { transform: translateY(100%); } to { transform: translateY(0); } }

@media (min-width: 768px) {
  .modal { align-items: center; }
  .modal-content { border-radius: var(--radius-2xl); margin: var(--space-20); box-shadow: var(--shadow-xl); }
}

/* ---------- TOAST ---------- */
.toast-container {
  position: fixed;
  top: var(--space-16);
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
  width: calc(100% - var(--space-32));
  max-width: 400px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--space-10);
  padding: var(--space-12) var(--space-16);
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--color-text-muted);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  animation: toast-in 0.3s ease;
  pointer-events: auto;
}
.toast-success { border-left-color: var(--color-success); }
.toast-error { border-left-color: var(--color-danger); }
.toast-warning { border-left-color: var(--color-warning); }
.toast-info { border-left-color: var(--color-info); }
.toast-icon { flex-shrink: 0; width: 20px; height: 20px; }
.toast-message { flex: 1; }
.toast-close {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  padding: var(--space-4);
}
.toast.toast-out { animation: toast-out 0.25s ease forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-out { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-12px); } }

/* ---------- SKELETON LOADER ---------- */
.skeleton {
  background: linear-gradient(90deg, var(--color-border-light) 25%, var(--color-surface-hover) 50%, var(--color-border-light) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}
.skeleton-card { height: 100px; margin-bottom: var(--space-12); }
.skeleton-list { height: 200px; }
.skeleton-text { height: 14px; margin-bottom: var(--space-8); }
.skeleton-text-sm { height: 10px; width: 60%; margin-bottom: var(--space-6); }
.skeleton-avatar { width: 40px; height: 40px; border-radius: var(--radius-full); }
@keyframes skeleton-shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }

/* ---------- EMPTY STATE ---------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-48) var(--space-24);
  text-align: center;
}
.empty-state-icon {
  width: 64px;
  height: 64px;
  color: var(--color-text-placeholder);
  margin-bottom: var(--space-16);
}
.empty-state-title {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  margin-bottom: var(--space-8);
}
.empty-state-desc {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  max-width: 280px;
  margin-bottom: var(--space-20);
}

/* ---------- CONFIRM DIALOG ---------- */
.confirm-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: var(--color-warning-light);
  color: var(--color-warning);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-16);
}
.confirm-title { text-align: center; margin-bottom: var(--space-8); }
.confirm-message { text-align: center; font-size: var(--text-sm); }

/* ---------- ICON SIZES ---------- */
.icon-xs { width: 14px; height: 14px; }
.icon-sm { width: 18px; height: 18px; }
.icon-md { width: 22px; height: 22px; }
.icon-lg { width: 28px; height: 28px; }
.icon-xl { width: 36px; height: 36px; }

/* LIST ITEM, KPI CARD, SEARCH BAR — Đã chuyển sang app.css */

/* SEARCH BAR — Đã chuyển sang app.css */

/* ---------- TAB / CHIP FILTER ---------- */
.chip-group {
  display: flex;
  gap: var(--space-8);
  overflow-x: auto;
  padding-bottom: var(--space-4);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.chip-group::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-6) var(--space-12);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-muted);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
  min-height: 36px;
}
.chip:hover { border-color: var(--color-primary); color: var(--color-primary); }
.chip.active { background: var(--color-primary); color: var(--color-text-inverse); border-color: var(--color-primary); }

/* ---------- DIVIDER ---------- */
.divider { height: 1px; background: var(--color-border-light); margin: var(--space-16) 0; }

/* ---------- NUMBER INPUT STEPPER ---------- */
.stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.stepper-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-surface);
  border: none;
  cursor: pointer;
  color: var(--color-text);
  font-size: var(--text-lg);
  transition: background var(--transition-fast);
}
.stepper-btn:hover { background: var(--color-surface-active); }
.stepper-value {
  width: 40px;
  text-align: center;
  font-weight: var(--weight-semibold);
  font-size: var(--text-base);
  border: none;
  border-left: 1px solid var(--color-border);
  border-right: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text);
}
