/* Glassmorphism Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  min-inline-size: 0;
  max-inline-size: 100%;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(10px);
  transition: var(--transition-normal);
}

.card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: var(--shadow-lg);
}

.card-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Forms & Inputs */
.form-group {
  margin-bottom: 20px;
}

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

.form-control {
  width: 100%;
  padding: 12px 16px;
  background-color: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 0.95rem;
  transition: var(--transition-fast);
}

.form-control:focus {
  border-color: var(--color-primary);
  background-color: rgba(255, 255, 255, 0.07);
  box-shadow: 0 0 0 3px rgba(0, 240, 255, 0.15);
}

.form-control:focus:not(:focus-visible) {
  outline: none;
}

.form-control:focus-visible,
:where(a:any-link, button, .btn, select, textarea, input, [tabindex]:not([tabindex="-1"])):focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

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

select.form-control {
  appearance: none;
  -webkit-appearance: none;
  box-sizing: border-box;
  min-height: 42px;
  height: auto;
  padding: 0.5rem 2.25rem 0.5rem 0.85rem;
  line-height: 1.4;
  cursor: pointer;
  text-overflow: ellipsis;
  background-image: var(--select-chevron);
  background-repeat: no-repeat;
  background-position: right 0.65rem center;
  background-size: 16px 16px;
}

select.form-control.form-control-sm {
  min-height: 36px;
  height: auto;
  padding: 0.35rem 2.1rem 0.35rem 0.7rem;
  font-size: 0.85rem;
  line-height: 1.35;
  background-position: right 0.55rem center;
}

select.form-control.form-control-xs {
  min-height: 32px;
  height: auto;
  padding: 0.25rem 1.9rem 0.25rem 0.6rem;
  font-size: 0.8rem;
  line-height: 1.3;
  background-position: right 0.45rem center;
  background-size: 14px 14px;
}

select.form-control:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

select.form-control option {
  background: #0f1524;
  color: var(--text-primary);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-family: var(--font-family);
  transition: var(--transition-fast);
  @media (prefers-reduced-motion: reduce) {
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
  }
}

.btn-primary {
  background: linear-gradient(135deg, var(--color-primary), #00aaff);
  color: #040811;
  box-shadow: var(--shadow-glow);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--color-primary-hover), #0088cc);
  transform: translateY(-1px);
  @media (prefers-reduced-motion: reduce) {
    transform: none;
  }
}

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

.btn-success:hover {
  background: var(--color-success-hover);
  transform: translateY(-1px);
  @media (prefers-reduced-motion: reduce) {
    transform: none;
  }
}

.btn-danger {
  background: var(--color-danger);
  color: white;
}

.btn-danger:hover {
  background: var(--color-danger-hover);
  transform: translateY(-1px);
  @media (prefers-reduced-motion: reduce) {
    transform: none;
  }
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.btn-icon {
  padding: 8px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Tables */
.table-container,
.table-responsive {
  display: block;
  inline-size: 100%;
  max-inline-size: 100%;
  min-inline-size: 0;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}

.table-container {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
}

.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.table th {
  background: rgba(255, 255, 255, 0.02);
  padding: 16px;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.table td {
  padding: 16px;
  font-size: 0.95rem;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-color);
  background: rgba(20, 26, 40, 0.2);
}

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

.table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge-success { background: rgba(16, 185, 129, 0.15); color: var(--color-success); border: 1px solid rgba(16, 185, 129, 0.2); }
.badge-danger { background: rgba(244, 63, 94, 0.15); color: var(--color-danger); border: 1px solid rgba(244, 63, 94, 0.2); }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: var(--color-warning); border: 1px solid rgba(245, 158, 11, 0.2); }
.badge-info { background: rgba(139, 92, 246, 0.15); color: var(--color-info); border: 1px solid rgba(139, 92, 246, 0.2); }

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(4, 7, 13, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0s linear 0.3s;
  overflow-y: auto;
  padding: 20px;
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  z-index: 1050;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0s linear 0s;
}

@media (prefers-reduced-motion: reduce) {
  .modal-overlay,
  .modal-overlay.open {
    transition: opacity 0.15s ease, visibility 0s linear 0s;
  }
}

.modal-content {
  background: #0f1524;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 650px;
  max-height: 90vh;
  max-height: 90dvh;
  overflow-y: auto;
  padding: 32px;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: var(--transition-normal);
  @media (prefers-reduced-motion: reduce) {
    transform: none;
    transition: opacity 0.15s ease;
  }
}

.modal-overlay.open .modal-content {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  transition: var(--transition-fast);
}

.modal-close:hover {
  color: var(--text-primary);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
}

.toast {
  background: rgba(20, 26, 40, 0.95);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 24px;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-primary);
  min-width: 300px;
  transform: translateY(20px);
  opacity: 0;
  transition: var(--transition-normal);
  @media (prefers-reduced-motion: reduce) {
    transform: none;
    transition: opacity 0.15s ease;
  }
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

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

/* Native <dialog> modals */
dialog.native-modal-dialog {
  margin: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  background: #0f1524;
  color: var(--text-primary);
  width: min(540px, 92vw);
  max-height: 90vh;
  max-height: 90dvh;
  overflow-y: auto;
  padding: 28px;
  box-shadow: var(--shadow-lg);
}

dialog.native-modal-dialog:modal {
  overscroll-behavior: contain;
}

dialog.native-modal-dialog::backdrop {
  overflow: hidden;
  overscroll-behavior: contain;
  background: rgba(4, 7, 13, 0.75);
  backdrop-filter: blur(8px);
}
