/* ═══════════════════════════════════════════════════════════
   components.css — Buttons, Inputs, Modals, Cards
   ═══════════════════════════════════════════════════════════ */

/* ── Buttons ── */
.btn {
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  font-weight: var(--font-weight-medium);
  font-size: var(--text-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  transition: all var(--transition-fast);
  cursor: pointer;
  border: none;
  outline: none;
}

.btn-primary {
  background: var(--color-primary);
  color: white;
}
.btn-primary:hover {
  background: var(--color-primary-light);
  box-shadow: var(--shadow-glow);
}

.btn-secondary {
  background: var(--color-bg-card);
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
}
.btn-secondary:hover {
  border-color: var(--color-border-strong);
  color: var(--color-text-primary);
}

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

.btn-danger {
  background: transparent;
  color: var(--color-error);
  border: 1px solid var(--color-error);
}
.btn-danger:hover {
  background: rgba(239, 68, 68, 0.1);
}

.btn-sm {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  border-radius: var(--radius-sm);
}

.btn-block {
  width: 100%;
}

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

.btn .spinner {
  width: 16px;
  height: 16px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* ── Inputs ── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

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

.form-input {
  padding: var(--space-3) var(--space-4);
  background: var(--color-bg-input);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-primary);
  font-size: var(--text-sm);
  transition: all var(--transition-fast);
  width: 100%;
}
.form-input:focus {
  border-color: var(--color-primary);
  outline: none;
  box-shadow: 0 0 0 3px var(--color-primary-glow);
}
.form-input::placeholder {
  color: var(--color-text-muted);
}

.form-input.error {
  border-color: var(--color-error);
}

.form-error {
  font-size: var(--text-xs);
  color: var(--color-error);
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  width: 48px;
  height: 26px;
  cursor: pointer;
}

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

.toggle-slider {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--color-bg-hover);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  transition: all var(--transition-fast);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--color-text-muted);
  top: 2px;
  right: 2px;
  transition: all var(--transition-fast);
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(-22px);
  background: white;
}

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn var(--transition-fast) ease;
}

.modal {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  width: 90%;
  max-width: 480px;
  animation: scaleIn var(--transition-base) ease;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
}

.modal-title {
  font-size: var(--text-xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-primary);
}

.modal-close {
  padding: var(--space-1);
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  font-size: var(--text-lg);
  transition: all var(--transition-fast);
}
.modal-close:hover {
  background: var(--color-bg-hover);
  color: var(--color-text-primary);
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.modal-footer {
  display: flex;
  justify-content: flex-start;
  gap: var(--space-3);
  margin-top: var(--space-6);
}

/* ── Toast / Notification ── */
.toast-container {
  position: fixed;
  top: 32px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  background: transparent;
  border: none;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  padding: 8px 16px;
  color: var(--color-primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.25s ease, transform 0.25s ease;
  animation: fadeSlideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  direction: rtl;
  text-align: center;
}

.toast-message {
  font-family: var(--font-family);
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-primary-light);
  text-shadow: 0 2px 10px rgba(239, 68, 68, 0.25);
  letter-spacing: 0.3px;
}

/* ── Data Table ── */
.data-table-wrapper {
  overflow-x: auto;
  padding: var(--space-2);
  max-width: 100%;
  box-sizing: border-box;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-xs);
}

.data-table th {
  padding: var(--space-2) var(--space-3);
  background: var(--color-primary-dark);
  color: white;
  font-weight: var(--font-weight-medium);
  white-space: nowrap;
  position: sticky;
  top: 0;
  text-align: right;
}

.data-table td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
}

.data-table tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}
.data-table tr:hover {
  background: rgba(255, 255, 255, 0.04);
}

.data-table-footer {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-align: center;
  direction: rtl;
}

.table-action-btn:hover {
  background: rgba(255, 255, 255, 0.08) !important;
  border-color: rgba(255, 255, 255, 0.18) !important;
  color: #ffffff !important;
  transform: translateY(-1px);
}
.table-action-btn:active {
  transform: translateY(0);
}

/* ── Badge ── */
.badge {
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: var(--font-weight-medium);
}
.badge-admin {
  background: var(--color-primary-subtle);
  color: var(--color-primary);
}
.badge-user {
  background: rgba(255,255,255,0.05);
  color: var(--color-text-muted);
}

/* ── Custom Dialog Modal (Alert, Confirm, Prompt) ── */
.custom-dialog-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(8, 8, 8, 0.7);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 1;
  transition: opacity 0.15s ease;
}

.custom-dialog-backdrop.fade-out {
  opacity: 0;
}

.custom-dialog-box {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-xl);
  padding: var(--space-6) var(--space-8);
  width: 90%;
  max-width: 440px;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.8), 0 0 40px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  animation: dialogScaleIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  transition: transform 0.15s ease;
}

.custom-dialog-backdrop.fade-out .custom-dialog-box {
  transform: scale(0.95);
}

.custom-dialog-header {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  text-align: right;
  width: 100%;
}

.custom-dialog-title {
  font-size: var(--text-lg);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-primary);
  margin: 0;
}

.custom-dialog-desc {
  font-size: var(--text-sm);
  font-weight: var(--font-weight-regular);
  color: var(--color-text-secondary);
  line-height: 1.6;
  margin: 0;
}

.custom-dialog-body {
  width: 100%;
}

.custom-dialog-input-wrapper {
  width: 100%;
}

.custom-dialog-box .form-input {
  width: 100%;
  box-sizing: border-box;
  background: var(--color-bg-input);
  border: 1px solid var(--color-border);
  color: var(--color-text-primary);
  font-family: var(--font-family);
  font-size: var(--text-sm);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.custom-dialog-box .form-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-glow);
  outline: none;
}

.custom-dialog-actions {
  display: flex;
  gap: var(--space-3);
  width: 100%;
  justify-content: flex-end;
  flex-direction: row-reverse;
}

.custom-dialog-actions .btn {
  flex: 1;
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-sm);
  border-radius: var(--radius-md);
  min-width: 100px;
}

.custom-dialog-actions .btn-primary {
  background: var(--color-primary);
  color: white;
}

.custom-dialog-actions .btn-primary:hover {
  background: var(--color-primary-light);
}

.custom-dialog-actions .btn-secondary {
  background: transparent;
  border: 1px solid var(--color-border-strong);
  color: var(--color-text-secondary);
}

.custom-dialog-actions .btn-secondary:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--color-text-primary);
}

@keyframes dialogScaleIn {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* ── Profile Settings Modal ── */
.profile-modal-box {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-xl);
  padding: var(--space-6) var(--space-8);
  width: 90%;
  max-width: 460px;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.8), 0 0 40px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  animation: dialogScaleIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  transition: transform 0.15s ease;
  direction: rtl;
}

.profile-avatar-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
}

.profile-avatar-wrapper {
  position: relative;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--color-border-strong);
  background: var(--color-bg-input);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
}

.profile-avatar-wrapper:hover {
  border-color: var(--color-primary);
  transform: scale(1.02);
}

.profile-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-avatar-placeholder {
  font-size: 2.2rem;
  font-weight: var(--font-weight-bold);
  color: var(--color-text-secondary);
  text-transform: uppercase;
}

.profile-avatar-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 10px;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.profile-avatar-wrapper:hover .profile-avatar-overlay {
  opacity: 1;
}

.profile-avatar-overlay i {
  font-size: var(--text-base);
}

.profile-avatar-presets {
  display: flex;
  gap: var(--space-2);
  justify-content: center;
  flex-wrap: wrap;
  margin-top: var(--space-1);
}

.profile-avatar-preset {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: var(--font-weight-bold);
  color: white;
  text-transform: uppercase;
  box-shadow: var(--shadow-sm);
}

.profile-avatar-preset:hover {
  transform: scale(1.1);
}

.profile-avatar-preset.active {
  border-color: var(--color-primary);
  transform: scale(1.1);
}

.profile-form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  width: 100%;
  text-align: right;
}

.profile-form-group label {
  font-size: var(--text-xs);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-secondary);
}

.profile-form-group .form-input {
  width: 100%;
  box-sizing: border-box;
  background: var(--color-bg-input);
  border: 1px solid var(--color-border);
  color: var(--color-text-primary);
  font-family: var(--font-family);
  font-size: var(--text-sm);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.profile-form-group .form-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-glow);
  outline: none;
}
