/* ==========================================================================
   Key Huy System - UI Components, Tables, Modals, Forms & Badges
   ========================================================================== */

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  user-select: none;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--primary-gradient);
  color: #fff;
  border: none;
  box-shadow: 0 4px 14px rgba(244, 63, 94, 0.4);
}
.btn-primary:hover {
  box-shadow: 0 6px 20px rgba(244, 63, 94, 0.6);
  filter: brightness(1.08);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.07);
  color: #f1f5f9;
  border: 1px solid var(--border-color);
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-success {
  background: var(--emerald-gradient);
  color: #fff;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
}
.btn-success:hover {
  filter: brightness(1.1);
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.35);
}
.btn-danger:hover {
  filter: brightness(1.1);
}

.btn-warning {
  background: var(--gold-gradient);
  color: #1e1b4b;
  font-weight: 800;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.35);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 14px 28px;
  font-size: 1.05rem;
  border-radius: var(--radius-lg);
}

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

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

.form-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: #cbd5e1;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.form-label-desc {
  font-size: 0.72rem;
  font-weight: 400;
  color: #94a3b8;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-family: var(--font-sans);
  font-size: 0.92rem;
  color: #fff;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(244, 63, 94, 0.2);
}

.form-textarea {
  resize: vertical;
  min-height: 100px;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  line-height: 1.6;
}

.form-select option {
  background: #1e293b;
  color: #fff;
}

/* Input with prefix / suffix */
.input-group {
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.input-group .form-input {
  border: none;
  background: transparent;
}

.input-prefix, .input-suffix {
  padding: 0 12px;
  color: #94a3b8;
  font-size: 0.85rem;
  font-weight: 600;
}

/* Badges & Tags */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-primary {
  background: rgba(244, 63, 94, 0.15);
  color: #fb7185;
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.badge-success {
  background: var(--success-bg);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-warning {
  background: var(--warning-bg);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-danger {
  background: var(--danger-bg);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-info {
  background: var(--info-bg);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.badge-purple {
  background: rgba(139, 92, 246, 0.15);
  color: #c084fc;
  border: 1px solid rgba(139, 92, 246, 0.3);
}

/* Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-md);
}

.custom-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.88rem;
}

.custom-table th {
  background: rgba(255, 255, 255, 0.03);
  color: #94a3b8;
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.custom-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
  color: #e2e8f0;
  vertical-align: middle;
}

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

.custom-table tbody tr {
  transition: background-color var(--transition-fast);
}

.custom-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.td-mono {
  font-family: var(--font-mono);
  font-weight: 700;
}

.td-highlight {
  color: #fff;
  font-weight: 800;
}

/* Search Bar & Filters Header */
.filter-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.search-box {
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0 14px;
  flex: 1;
  min-width: 240px;
  max-width: 400px;
}

.search-icon {
  color: #64748b;
  margin-right: 8px;
}

.search-input {
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  padding: 10px 0;
  font-size: 0.88rem;
  width: 100%;
}

/* Modal Dialog */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 7, 18, 0.82);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-box {
  background: #0f172a;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg), 0 0 32px rgba(244, 63, 94, 0.15);
  transform: scale(0.95);
  transition: transform var(--transition-normal);
  overflow: hidden;
}

.modal-overlay.open .modal-box {
  transform: scale(1);
}

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

.modal-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: #fff;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 1.3rem;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

.modal-close-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  background: rgba(0, 0, 0, 0.2);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 200;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: #1e293b;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-lg);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 600;
  min-width: 280px;
  max-width: 420px;
  animation: slideInToast 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  transition: all var(--transition-fast);
}

.toast-success {
  border-left: 4px solid var(--success);
}
.toast-danger {
  border-left: 4px solid var(--danger);
}
.toast-warning {
  border-left: 4px solid var(--warning);
}
.toast-info {
  border-left: 4px solid var(--info);
}

@keyframes slideInToast {
  from {
    opacity: 0;
    transform: translateX(40px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Tabs Navigation */
.tabs-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 20px;
  overflow-x: auto;
}

.tab-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 0.9rem;
  font-weight: 700;
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: var(--transition-fast);
  white-space: nowrap;
}

.tab-btn:hover {
  color: #fff;
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
