/* ========================================
   Base Modal Component
   Reusable modal overlay and container styles
   ======================================== */

.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal[hidden] {
  display: none;
}

/* Overlay */
.modal__overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
  z-index: 1;
}

/* Container */
.modal__container {
  position: relative;
  background: var(--bg-primary);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  max-width: 90vw;
  max-height: 90vh;
  z-index: 2;
}

/* Header */
.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.modal__title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

.modal__close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
}

.modal__close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.modal__close:active {
  background: var(--bg-active);
}

/* Footer */
.modal__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
}

/* Buttons */
.modal__btn {
  padding: 0.5rem 1.25rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, opacity 0.15s;
  white-space: nowrap;
}

.modal__btn--primary {
  background: var(--accent-color, #007bff);
  color: #ffffff;
}

.modal__btn--primary:hover:not(:disabled) {
  background: var(--accent-hover, #0056b3);
}

.modal__btn--primary:active:not(:disabled) {
  background: var(--accent-active, #004085);
}

.modal__btn--primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Remove default focus outlines and add custom ones */
.modal__btn:focus-visible,
.modal__close:focus-visible {
  outline: 2px solid var(--accent-color, #007bff);
  outline-offset: 2px;
}

.modal__btn--secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.modal__btn--secondary:hover {
  background: var(--bg-hover);
}

.modal__btn--secondary:active {
  background: var(--bg-active);
}

/* Dark theme adjustments */
[data-theme="dark"] .modal__overlay {
  background: rgba(0, 0, 0, 0.7);
}
