/* ============================================
   COMPONENTS.CSS - Reusable UI Components
   ============================================ */

/* ========== Buttons ========== */
.btn {
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background-color var(--transition-fast),
              color var(--transition-fast),
              transform var(--transition-fast),
              box-shadow var(--transition-fast);
  font-family: var(--font-family);
  text-align: center;
  display: inline-block;
  user-select: none;
  line-height: 1.5;
}

.btn:hover {
  transform: scale(1.02);
  filter: brightness(1.1);
}

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

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-success {
  background: var(--success);
  color: #ffffff;
}

.btn-warning {
  background: var(--warning);
  color: #1a1a2e;
}

.btn-info {
  background: var(--info);
  color: #ffffff;
}

.btn-danger {
  background: var(--error);
  color: #ffffff;
}

.btn-outline {
  background: transparent;
  border: 2px solid var(--text-secondary);
  color: var(--text-primary);
  padding: 10px 22px;
}

.btn-outline:hover {
  background: var(--bg-card);
  border-color: var(--accent);
}

.btn-lg {
  padding: 16px 32px;
  font-size: 1.25rem;
}

.btn-sm {
  padding: 8px 16px;
  font-size: 0.875rem;
}

.btn-block {
  width: 100%;
  display: block;
}

/* ========== Cards ========== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  margin-bottom: 1rem;
}

.card-header {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.card-body {
  color: var(--text-primary);
}

.card-footer {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* ========== Forms ========== */
.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 1rem;
  font-family: var(--font-family);
  transition: border-color var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--accent);
  outline: none;
}

.form-input::placeholder {
  color: var(--text-muted);
}

.form-textarea {
  resize: vertical;
  min-height: 100px;
}

.form-error {
  color: var(--error);
  font-size: 0.875rem;
  margin-top: 0.25rem;
  display: block;
}

.form-help {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: 0.25rem;
  display: block;
}

/* ========== Progress Bar ========== */
.progress-bar {
  background: var(--bg-secondary);
  border-radius: 999px;
  height: 12px;
  overflow: hidden;
  position: relative;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transition: width var(--transition-normal);
  min-width: 2%;
}

.progress-bar-fill.success {
  background: var(--success);
}

.progress-bar-fill.warning {
  background: var(--warning);
}

.progress-bar-fill.info {
  background: var(--info);
}

/* ========== Badges ========== */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
}

.badge-success {
  background: var(--success);
  color: #ffffff;
}

.badge-warning {
  background: var(--warning);
  color: #1a1a2e;
}

.badge-info {
  background: var(--info);
  color: #ffffff;
}

.badge-error {
  background: var(--error);
  color: #ffffff;
}

.badge-primary {
  background: var(--accent);
  color: #ffffff;
}

.badge-secondary {
  background: var(--bg-secondary);
  color: var(--text-secondary);
}

/* ========== Modal ========== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  backdrop-filter: blur(4px);
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 2rem;
  max-width: 500px;
  width: 90%;
  box-shadow: var(--shadow-lg);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

.modal-content {
  margin-bottom: 1.5rem;
  color: var(--text-primary);
}

.modal-actions {
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
}

.modal-actions .btn {
  min-width: 100px;
}

/* ========== Alerts ========== */
.alert {
  padding: 1rem 1.5rem;
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
  border-left: 4px solid;
}

.alert-error {
  background: rgba(230, 57, 70, 0.15);
  border-left-color: var(--error);
  color: var(--text-primary);
}

.alert-success {
  background: rgba(42, 157, 143, 0.15);
  border-left-color: var(--success);
  color: var(--text-primary);
}

.alert-info {
  background: rgba(69, 123, 157, 0.15);
  border-left-color: var(--info);
  color: var(--text-primary);
}

.alert-warning {
  background: rgba(233, 196, 106, 0.15);
  border-left-color: var(--warning);
  color: var(--text-primary);
}

/* ========== Loading Spinner ========== */
@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--bg-secondary);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner-lg {
  width: 48px;
  height: 48px;
  border-width: 4px;
}

.spinner-sm {
  width: 20px;
  height: 20px;
  border-width: 2px;
}

.loading-overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 2rem;
  min-height: 200px;
}

.loading-text {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* ========== Navbar ========== */
.navbar {
  background: var(--bg-secondary);
  padding: 0.75rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-sm);
}

.navbar-brand {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
}

.navbar-actions {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.navbar-link {
  color: var(--text-secondary);
  font-weight: 500;
  transition: color var(--transition-fast);
}

.navbar-link:hover {
  color: var(--text-primary);
}

/* ========== Toast Notifications ========== */
@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOutRight {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

.toast-container {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 400px;
}

.toast {
  background: var(--bg-card);
  padding: 1rem 1.5rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  animation: slideInRight 0.3s ease;
  border-left: 4px solid;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.toast.toast-success {
  border-left-color: var(--success);
}

.toast.toast-error {
  border-left-color: var(--error);
}

.toast.toast-info {
  border-left-color: var(--info);
}

.toast.toast-warning {
  border-left-color: var(--warning);
}

.toast.removing {
  animation: slideOutRight 0.3s ease;
}

/* ========== List Group ========== */
.list-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.list-group-item {
  background: var(--bg-card);
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background-color var(--transition-fast);
}

.list-group-item:hover {
  background: var(--bg-surface);
}

/* ========== Divider ========== */
.divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
  margin: 1.5rem 0;
}

/* ========== Empty State ========== */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-secondary);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.empty-state-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.empty-state-description {
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
  .modal {
    padding: 1.5rem;
    width: 95%;
  }

  .toast-container {
    left: 1rem;
    right: 1rem;
    max-width: none;
  }

  .navbar {
    padding: 0.75rem 1rem;
  }
}
