/**
 * Console Maven - Custom Modal Styles
 * Replaces native browser dialogs with custom modals
 */

/* Modal Overlay */
.cm-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  animation: cm-fade-in 0.2s ease;
}

@keyframes cm-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Modal Box */
.cm-modal {
  background: #1e1e2e;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 24px;
  min-width: 320px;
  max-width: 500px;
  width: 90%;
  box-shadow:
    0 20px 25px -5px rgba(0, 0, 0, 0.1),
    0 10px 10px -5px rgba(0, 0, 0, 0.04),
    0 0 0 1px rgba(255, 255, 255, 0.05);
  animation: cm-slide-up 0.2s ease;
  position: relative;
}

@keyframes cm-slide-up {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Modal Header */
.cm-modal-header {
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.cm-modal-title {
  margin: 0;
  color: #fff;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* Modal Content */
.cm-modal-content {
  color: #e0e0e0;
}

.cm-modal-content p {
  margin: 0 0 20px 0;
  color: #fff;
  font-size: 15px;
  line-height: 1.6;
  word-wrap: break-word;
}

/* Alert modal - no checkbox */
.cm-modal-alert .cm-modal-content p {
  margin-bottom: 20px;
}

/* Multi-line messages */
.cm-modal-content p {
  white-space: pre-wrap;
}

/* Remember Checkbox */
.cm-modal-remember {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  color: #9ca3af;
  font-size: 14px;
  cursor: pointer;
  user-select: none;
  transition: color 0.2s ease;
}

.cm-modal-remember:hover {
  color: #d1d5db;
}

.cm-modal-remember input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: #7c3aed;
  border-radius: 4px;
}

/* Action Buttons */
.cm-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 8px;
}

.cm-btn-ok,
.cm-btn-cancel {
  padding: 10px 20px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-weight: 500;
  font-size: 14px;
  transition: all 0.2s ease;
  min-width: 80px;
  position: relative;
  overflow: hidden;
}

/* OK Button - Primary */
.cm-btn-ok {
  background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
  color: #fff;
  box-shadow: 0 2px 4px rgba(124, 58, 237, 0.3);
}

.cm-btn-ok:hover {
  background: linear-gradient(135deg, #6d28d9 0%, #5b21b6 100%);
  box-shadow: 0 4px 6px rgba(124, 58, 237, 0.4);
  transform: translateY(-1px);
}

.cm-btn-ok:active {
  transform: scale(0.98) translateY(0);
  box-shadow: 0 1px 2px rgba(124, 58, 237, 0.3);
}

.cm-btn-ok:focus {
  outline: none;
  box-shadow:
    0 0 0 3px rgba(124, 58, 237, 0.2),
    0 2px 4px rgba(124, 58, 237, 0.3);
}

/* Cancel Button - Secondary */
.cm-btn-cancel {
  background: #374151;
  color: #e5e7eb;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.cm-btn-cancel:hover {
  background: #4b5563;
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
}

.cm-btn-cancel:active {
  transform: scale(0.98) translateY(0);
}

.cm-btn-cancel:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(107, 114, 128, 0.3);
}

/* Responsive adjustments */
@media (max-width: 480px) {
  .cm-modal {
    min-width: 280px;
    width: 95%;
    padding: 20px;
    margin: 0 10px;
  }

  .cm-modal-actions {
    flex-direction: column-reverse;
    gap: 8px;
  }

  .cm-btn-ok,
  .cm-btn-cancel {
    width: 100%;
  }
}

/* Accessibility - High Contrast Mode */
@media (prefers-contrast: high) {
  .cm-modal {
    border: 2px solid #fff;
  }

  .cm-btn-ok {
    background: #7c3aed;
    border: 2px solid #fff;
  }

  .cm-btn-cancel {
    border: 2px solid #fff;
  }
}

/* Dark mode adjustments (already dark by default, but for system preference) */
@media (prefers-color-scheme: light) {
  .cm-modal {
    background: #ffffff;
    border-color: #e5e7eb;
  }

  .cm-modal-header {
    border-bottom-color: #e5e7eb;
  }

  .cm-modal-title {
    color: #1f2937;
  }

  .cm-modal-content p {
    color: #1f2937;
  }

  .cm-modal-remember {
    color: #6b7280;
  }

  .cm-modal-remember:hover {
    color: #374151;
  }

  .cm-btn-cancel {
    background: #f3f4f6;
    color: #374151;
    border-color: #d1d5db;
  }

  .cm-btn-cancel:hover {
    background: #e5e7eb;
  }
}

/* Animation for modal dismissal */
.cm-modal-overlay.cm-dismissing {
  animation: cm-fade-out 0.2s ease forwards;
}

.cm-modal-overlay.cm-dismissing .cm-modal {
  animation: cm-slide-down 0.2s ease forwards;
}

@keyframes cm-fade-out {
  to {
    opacity: 0;
  }
}

@keyframes cm-slide-down {
  to {
    transform: translateY(20px);
    opacity: 0;
  }
}