/**
 * @file
 * Shared modal styles for EB UI module.
 *
 * These styles are used by both the YAML editor and grid-based editors
 * for validation, preview, and import modals.
 */

/* ============================================
   CSS CUSTOM PROPERTIES (Shared)
   ============================================ */

:root {
  /* Surface */
  --eb-surface: #ffffff;
  --eb-surface-overlay: rgba(0, 0, 0, 0.5);

  /* Gray Scale */
  --eb-gray-5: hsl(220, 14%, 98%);
  --eb-gray-15: hsl(220, 12%, 93%);

  /* Borders */
  --eb-border-light: hsl(220, 12%, 93%);

  /* Text */
  --eb-text-primary: hsl(220, 8%, 25%);
  --eb-text-secondary: hsl(220, 8%, 55%);

  /* Semantic */
  --eb-error: hsl(0, 84%, 60%);
  --eb-error-light: hsl(0, 84%, 96%);

  /* Spacing */
  --eb-space-1: 4px;
  --eb-space-2: 8px;
  --eb-space-3: 12px;
  --eb-space-4: 16px;
  --eb-space-5: 20px;
  --eb-space-8: 32px;

  /* Border Radius */
  --eb-radius-sm: 4px;
  --eb-radius-xl: 12px;

  /* Transitions */
  --eb-transition-fast: 0.1s ease;
}

/* ============================================
   MODAL BASE STYLING
   ============================================ */

.eb-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
}

.eb-modal--open {
  display: block;
}

.eb-modal__backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--eb-surface-overlay);
}

.eb-modal__dialog {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--eb-surface);
  border-radius: var(--eb-radius-xl);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
  max-width: 800px;
  width: 90%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.eb-modal__dialog--small {
  max-width: 500px;
}

.eb-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--eb-space-4) var(--eb-space-5);
  border-bottom: 1px solid var(--eb-border-light);
}

.eb-modal__title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--eb-text-primary);
}

.eb-modal__close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--eb-text-secondary);
  padding: var(--eb-space-1);
  line-height: 1;
  border-radius: var(--eb-radius-sm);
  transition: all var(--eb-transition-fast);
}

.eb-modal__close:hover {
  color: var(--eb-text-primary);
  background: var(--eb-gray-5);
}

.eb-modal__close:focus {
  outline: 2px solid hsl(160, 84%, 39%);
  outline-offset: -2px;
}

.eb-modal__content {
  flex: 1;
  overflow-y: auto;
  padding: var(--eb-space-4) var(--eb-space-5);
}

.eb-modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--eb-space-2);
  padding: var(--eb-space-4) var(--eb-space-5);
  border-top: 1px solid var(--eb-border-light);
  background: var(--eb-gray-5);
  border-radius: 0 0 var(--eb-radius-xl) var(--eb-radius-xl);
}

.eb-modal__loading {
  text-align: center;
  padding: var(--eb-space-8);
  color: var(--eb-text-secondary);
}

.eb-modal__error {
  color: var(--eb-error);
  padding: var(--eb-space-4);
  background-color: var(--eb-error-light);
  border-radius: var(--eb-radius-sm);
  border-left: 3px solid var(--eb-error);
}

.eb-modal__message {
  color: var(--eb-text-secondary);
  padding: var(--eb-space-4);
  text-align: center;
  font-style: italic;
}

/* Prevent body scroll when modal is open */
body.eb-modal-open {
  overflow: hidden;
}

/* ============================================
   PREVIEW CONTENT STYLING
   ============================================ */

/* Validation warning banner */
.eb-preview__warning-banner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background-color: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: 4px;
  margin-bottom: 1rem;
}

.eb-preview__warning-icon {
  font-size: 1.25rem;
  color: #856404;
  flex-shrink: 0;
}

.eb-preview__warning-text {
  font-size: 0.875rem;
  color: #856404;
  font-weight: 500;
}

/* Header section */
.eb-preview {
  text-align: center;
  padding: 1.5rem 1.5rem 1rem;
}

.eb-preview__icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}

.eb-preview--ready .eb-preview__icon {
  color: #1976d2;
}

.eb-preview__message {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: #1976d2;
}

.eb-preview__subtitle {
  color: #666;
  font-size: 0.875rem;
}

.eb-preview__empty {
  text-align: center;
  padding: 2rem;
  color: #666;
  font-style: italic;
}

/* Stats bar */
.eb-preview__stats {
  display: flex;
  justify-content: center;
  gap: 2rem;
  padding: 1rem;
  background-color: #f5f5f5;
  border-radius: 4px;
  margin-bottom: 1rem;
}

.eb-preview__stat {
  text-align: center;
}

.eb-preview__stat-value {
  display: block;
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
}

.eb-preview__stat--create .eb-preview__stat-value {
  color: #2e7d32;
}

.eb-preview__stat--update .eb-preview__stat-value {
  color: #1976d2;
}

.eb-preview__stat--delete .eb-preview__stat-value {
  color: #c62828;
}

.eb-preview__stat--no-change .eb-preview__stat-value {
  color: #757575;
}

.eb-preview__stat--other .eb-preview__stat-value,
.eb-preview__stat--total .eb-preview__stat-value {
  color: #1976d2;
}

.eb-preview__stat-label {
  font-size: 12px;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Operation groups */
.eb-preview__groups {
  max-height: 350px;
  overflow-y: auto;
}

.eb-preview__group {
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  margin-bottom: 0.5rem;
}

.eb-preview__group[open] {
  border-color: #bbdefb;
}

.eb-preview__group--create[open] {
  border-color: #c8e6c9;
}

.eb-preview__group--delete[open] {
  border-color: #ffcdd2;
}

.eb-preview__group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  cursor: pointer;
  background-color: #fafafa;
  border-radius: 4px;
}

.eb-preview__group[open] .eb-preview__group-header {
  border-radius: 4px 4px 0 0;
}

.eb-preview__group--create .eb-preview__group-header {
  background-color: #f1f8e9;
}

.eb-preview__group--create[open] .eb-preview__group-header {
  background-color: #dcedc8;
}

.eb-preview__group--update .eb-preview__group-header {
  background-color: #e3f2fd;
}

.eb-preview__group--update[open] .eb-preview__group-header {
  background-color: #bbdefb;
}

.eb-preview__group--delete .eb-preview__group-header {
  background-color: #ffebee;
}

.eb-preview__group--delete[open] .eb-preview__group-header {
  background-color: #ffcdd2;
}

.eb-preview__group--no-change .eb-preview__group-header {
  background-color: #fafafa;
}

.eb-preview__group--no-change[open] .eb-preview__group-header {
  background-color: #eeeeee;
}

.eb-preview__group-header:hover {
  filter: brightness(0.97);
}

.eb-preview__group-title {
  font-weight: 600;
  color: #333;
}

.eb-preview__group-count {
  color: #fff;
  padding: 0.125rem 0.5rem;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
}

.eb-preview__group--create .eb-preview__group-count {
  background-color: #2e7d32;
}

.eb-preview__group--update .eb-preview__group-count {
  background-color: #1976d2;
}

.eb-preview__group--delete .eb-preview__group-count {
  background-color: #c62828;
}

.eb-preview__group--no-change .eb-preview__group-count {
  background-color: #757575;
}

.eb-preview__group--other .eb-preview__group-count {
  background-color: #1976d2;
}

.eb-preview__group-items {
  border-top: 1px solid #e0e0e0;
  background-color: #fff;
}

.eb-preview__group--create .eb-preview__group-items {
  border-top-color: #c8e6c9;
}

.eb-preview__group--delete .eb-preview__group-items {
  border-top-color: #ffcdd2;
}

/* Individual operation items */
.eb-preview__item {
  border-bottom: 1px solid #f5f5f5;
}

.eb-preview__item:last-child {
  border-bottom: none;
}

.eb-preview__item-summary {
  padding: 0.5rem 1rem;
  cursor: pointer;
  font-size: 13px;
  color: #333;
}

.eb-preview__item-summary:hover {
  background-color: #f5f5f5;
}

.eb-preview__item-desc {
  display: block;
}

.eb-preview__item-details {
  padding: 0.75rem 1rem;
  background-color: #fafafa;
  border-top: 1px solid #eee;
}

.eb-preview__item-details pre {
  background-color: #fff;
  border: 1px solid #e0e0e0;
  padding: 0.75rem;
  border-radius: 4px;
  overflow-x: auto;
  font-size: 11px;
  margin: 0;
  max-height: 200px;
  overflow-y: auto;
}

/* Preview warnings */
.eb-preview__warnings {
  margin-top: 0.75rem;
  padding: 0.5rem;
  background-color: #fff8e1;
  border: 1px solid #ffe082;
  border-radius: 4px;
}

.eb-preview__warning {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.25rem 0;
}

.eb-preview__warning:first-child {
  padding-top: 0;
}

.eb-preview__warning:last-child {
  padding-bottom: 0;
}

.eb-preview__warning-icon {
  color: #f59e0b;
  flex-shrink: 0;
}

.eb-preview__warning-message {
  font-size: 12px;
  color: #78350f;
}

/* ============================================
   VALIDATION MODAL STYLING
   ============================================ */

.eb-validation {
  text-align: center;
  padding: 1.5rem 1.5rem 1rem;
}

.eb-validation__icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}

.eb-validation--success .eb-validation__icon {
  color: #2e7d32;
}

.eb-validation--error .eb-validation__icon {
  color: #c62828;
}

.eb-validation__message {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.eb-validation--success .eb-validation__message {
  color: #2e7d32;
}

.eb-validation--error .eb-validation__message {
  color: #c62828;
}

.eb-validation__summary {
  color: #666;
}

.eb-validation__subtitle {
  color: #666;
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

/* Stats bar for error summary */
.eb-validation__stats {
  display: flex;
  justify-content: center;
  gap: 2rem;
  padding: 1rem;
  background-color: #f5f5f5;
  border-radius: 4px;
  margin-bottom: 1rem;
}

.eb-validation__stat {
  text-align: center;
}

.eb-validation__stat-value {
  display: block;
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
}

.eb-validation__stat--error .eb-validation__stat-value {
  color: #c62828;
}

.eb-validation__stat--success .eb-validation__stat-value {
  color: #2e7d32;
}

.eb-validation__stat--total .eb-validation__stat-value {
  color: #1976d2;
}

.eb-validation__stat-label {
  font-size: 12px;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Error groups */
.eb-validation__error-groups {
  max-height: 350px;
  overflow-y: auto;
}

.eb-validation__error-group {
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  margin-bottom: 0.5rem;
}

.eb-validation__error-group[open] {
  border-color: #ffcdd2;
}

.eb-validation__error-group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  cursor: pointer;
  background-color: #fafafa;
  border-radius: 4px;
}

.eb-validation__error-group[open] .eb-validation__error-group-header {
  background-color: #ffebee;
  border-radius: 4px 4px 0 0;
}

.eb-validation__error-group-header:hover {
  background-color: #f0f0f0;
}

.eb-validation__error-group[open] .eb-validation__error-group-header:hover {
  background-color: #ffcdd2;
}

.eb-validation__error-group-title {
  font-weight: 600;
  color: #333;
}

.eb-validation__error-group-count {
  background-color: #c62828;
  color: #fff;
  padding: 0.125rem 0.5rem;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
}

.eb-validation__error-group-items {
  border-top: 1px solid #ffcdd2;
  background-color: #fff;
}

.eb-validation__error-item {
  padding: 0.5rem 1rem;
  border-bottom: 1px solid #ffebee;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.eb-validation__error-item:last-child {
  border-bottom: none;
}

.eb-validation__error-message {
  color: #b71c1c;
}

.eb-validation__error-context {
  color: #666;
  font-size: 12px;
  font-family: monospace;
  background-color: #f5f5f5;
  padding: 0.125rem 0.375rem;
  border-radius: 3px;
  display: inline-block;
}

.eb-validation__note {
  margin-top: 1rem;
  color: #666;
  font-size: 13px;
  text-align: center;
}

/* ============================================
   EXTENSION WARNINGS (Validation Modal)
   ============================================ */

.eb-extension-warnings {
  margin-top: 1rem;
  padding: 1rem;
  background-color: #fffbeb;
  border: 1px solid #f59e0b;
  border-radius: 4px;
}

.eb-extension-warnings__title {
  margin: 0 0 0.75rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: #92400e;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.eb-extension-warning {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(245, 158, 11, 0.2);
}

.eb-extension-warning:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.eb-extension-warning__icon {
  flex-shrink: 0;
  font-size: 1rem;
  color: #f59e0b;
}

.eb-extension-warning__message {
  font-size: 0.875rem;
  color: #78350f;
  line-height: 1.4;
}

/* Gin theme compatibility */
.gin .eb-extension-warnings {
  background-color: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.5);
}

/* ============================================
   IMPORT MODAL STYLING
   ============================================ */

.eb-import-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.eb-import-form__field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.eb-import-form__field label {
  font-weight: 600;
  color: #333;
}

.eb-import-form__field select {
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 14px;
}

.eb-import-form__field select:disabled {
  background-color: #f5f5f5;
  cursor: not-allowed;
}

.eb-import-form__loading {
  text-align: center;
  padding: 1rem;
  color: #1976d2;
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */

@media (max-width: 768px) {
  .eb-modal__dialog {
    width: 95%;
    max-height: 90vh;
  }

  .eb-validation__stats {
    flex-direction: column;
    gap: 1rem;
  }
}

/* ============================================
   GIN THEME COMPATIBILITY
   ============================================ */

.gin .eb-modal__dialog {
  box-shadow: var(--gin-shadow-level-3, 0 20px 40px rgba(0, 0, 0, 0.15));
}

.gin .eb-modal__title {
  color: var(--gin-text-color, var(--eb-text-primary));
}

.gin .eb-modal__close:focus {
  outline-color: var(--gin-color-primary, hsl(160, 84%, 39%));
}

/* ============================================
   CLARO THEME COMPATIBILITY
   ============================================ */

.claro .eb-modal__close:focus {
  outline-color: var(--color-focus, hsl(160, 84%, 39%));
}
