/* Base Modal System (Modularized) */

/* Overlay layer (hidden by default) */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.8);
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.3s ease-out;
}

.modal-overlay.show {
  display: flex;
}

/* Dialog container inside overlay */
.modal-overlay > .modal {
  background: #1e2228;
  border-radius: 12px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  position: relative;
  margin: auto;
  border: 1px solid #333;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  animation: modalSlideIn 0.3s ease-out;
  overflow: hidden;
}

#modal-large {
  width: min(1180px, calc(100vw - 48px));
  max-width: 1180px;
}

#modal-large .modal-body {
  padding: 28px 32px 32px;
}

/* Header */
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid #333;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #23272f;
  flex-shrink: 0;
}

.modal-header h3 {
  margin: 0;
  color: #fff;
  font-size: 18px;
  font-weight: 600;
}

/* Close button */
.modal-header .close,
.modal-close {
  background: none;
  border: none;
  color: #888;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: all 0.2s ease;
  display: inline-block;
}

.modal-header .close:hover,
.modal-header .close:focus,
.modal-close:hover {
  color: #fff;
  text-decoration: none;
}

/* Body */
.modal-body {
  padding: 24px;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1 1 auto;
  color: #fff;
  max-height: calc(90vh - 140px);
}

.modal-body::-webkit-scrollbar { width: 8px; }
.modal-body::-webkit-scrollbar-track { background: #2a2a2a; border-radius: 4px; }
.modal-body::-webkit-scrollbar-thumb { background: #555; border-radius: 4px; }
.modal-body::-webkit-scrollbar-thumb:hover { background: #666; }

/* Footer */
.modal-footer {
  padding: 1rem;
  border-top: 1px solid var(--border-color, #333);
  display: flex;
  justify-content: flex-end;
}

/* Buttons within modal */
.modal .btn {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}

.modal .btn-primary { background: linear-gradient(135deg, #5865f2, #4752c4); color: #fff; }
.modal .btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #4752c4, #3b429f);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(88, 101, 242, 0.3);
}

.modal .btn-secondary { background: #444; color: #fff; border: 1px solid #555; }
.modal .btn-secondary:hover { background: #555; border-color: #666; transform: translateY(-1px); }
.modal .btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

/* Form elements in modal */
.modal input,
.modal textarea,
.modal select {
  width: 100%;
  padding: 10px 12px;
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 6px;
  color: #fff;
  font-size: 14px;
  transition: all 0.2s ease;
  box-sizing: border-box;
}

.modal input:focus,
.modal textarea:focus,
.modal select:focus {
  border-color: #5865f2;
  outline: none;
  box-shadow: 0 0 0 2px rgba(88, 101, 242, 0.2);
}

.modal input::placeholder,
.modal textarea::placeholder { color: #888; }

.modal label { display: block; margin-bottom: 6px; color: #fff; font-weight: 500; font-size: 14px; }

/* Alerts and loading */
.modal .alert { padding: 12px 16px; border-radius: 6px; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; font-size: 14px; }
.modal .alert-success { background: rgba(76, 175, 80, 0.1); border: 1px solid rgba(76, 175, 80, 0.3); color: #81c784; }
.modal .alert-error { background: rgba(244, 67, 54, 0.1); border: 1px solid rgba(244, 67, 54, 0.3); color: #ef5350; }
.modal .alert-warning { background: rgba(255, 152, 0, 0.1); border: 1px solid rgba(255, 152, 0, 0.3); color: #ffb74d; }
.modal .alert-info { background: rgba(33, 150, 243, 0.1); border: 1px solid rgba(33, 150, 243, 0.3); color: #64b5f6; }

.modal .loading { display: flex; align-items: center; justify-content: center; padding: 40px; color: #888; }
.modal .loading i { margin-right: 8px; animation: spin 1s linear infinite; }

/* Animations */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalSlideIn { from { opacity: 0; transform: translateY(-20px) scale(0.95); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* Responsive */
@media (max-width: 768px) {
  .modal-overlay > .modal { max-width: none; width: 95vw; max-height: 90vh; margin: 0 auto; }
  .modal-header, .modal-body, .modal-footer { padding: 16px; }

  #modal-large {
    width: calc(100vw - 20px);
  }

  #modal-large .modal-body {
    padding: 20px;
  }
}

