/* ============================================================
   v6 Pattern dialogs — Rename / Change Category / Delete
   ============================================================
   Same story as context-menu.css: PatternLibrary has always built
   this markup, but its only rules lived in the legacy style.css
   that v6 removed. With none of them loaded the overlay was
   `position: static` and transparent, so all three dialogs
   rendered as an invisible full-width strip below the fold —
   reachable from the pattern card's "More options" menu, and
   therefore dead ends.
*/

/* NOT wrapped in @layer, deliberately.
   style-v2.css is entirely unlayered and opens with
   `*, *::before, *::after { margin: 0; padding: 0 }`. Unlayered CSS beats
   LAYERED css regardless of specificity, so every padding declared inside
   @layer v6-components computes to 0 — verified in the browser against this
   file and against the pre-existing .v6-versions__menu-header. Staying
   unlayered lets normal specificity apply (.toast 0,1,0 > * 0,0,0). None of
   the selectors below appear anywhere in style-v2.css, so nothing else
   competes for them. */

  .pattern-dialog-overlay {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal, 900);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
    animation: v6-dialog-fade var(--duration-fast, 120ms) ease;
  }

  .pattern-dialog {
    width: 100%;
    max-width: 420px;
    max-height: calc(100vh - 48px);
    display: flex;
    flex-direction: column;
    overflow: hidden;

    background: var(--v6-panel, var(--surface-300, #18181b));
    border: 1px solid var(--v6-border-strong, rgba(255, 255, 255, 0.14));
    border-radius: var(--radius-lg, 8px);
    box-shadow: var(--shadow-4, 0 24px 64px rgba(0, 0, 0, 0.7));
    animation: v6-dialog-rise var(--duration-normal, 180ms) var(--ease-out-quart, ease);
  }

  .pattern-dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-default, rgba(255, 255, 255, 0.1));
  }

  .pattern-dialog-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary, #fafafa);
  }

  .pattern-dialog-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    border-radius: var(--radius-md, 6px);
    background: none;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    color: var(--text-secondary, #a1a1aa);
    transition: background var(--duration-fast, 120ms) ease,
                color var(--duration-fast, 120ms) ease;
  }

  .pattern-dialog-close:hover {
    background: var(--v6-panel-hover, rgba(255, 255, 255, 0.07));
    color: var(--text-primary, #fafafa);
  }

  .pattern-dialog-body {
    padding: 16px;
    overflow-y: auto;
    color: var(--text-primary, #fafafa);
    font-size: 13px;
    line-height: 1.5;
  }

  .pattern-dialog-body p { margin: 0 0 10px; }
  .pattern-dialog-body p:last-child { margin-bottom: 0; }

  .dialog-subtitle {
    color: var(--text-secondary, #a1a1aa);
    font-size: 12px;
  }

  .dialog-warning {
    color: #f87171;
    font-size: 12px;
  }

  .pattern-dialog-body label,
  .pattern-name-label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-secondary, #a1a1aa);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  .pattern-name-input,
  .modal-input {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--v6-border-strong, rgba(255, 255, 255, 0.14));
    border-radius: var(--radius-md, 6px);
    background: var(--surface-200, #131316);
    color: var(--text-primary, #fafafa);
    font-family: inherit;
    font-size: 13px;
    transition: border-color var(--duration-fast, 120ms) ease,
                box-shadow var(--duration-fast, 120ms) ease;
  }

  .pattern-name-input:focus,
  .modal-input:focus {
    outline: none;
    border-color: var(--accent-primary, #8b5cf6);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.22);
  }

  .pattern-dialog-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border-default, rgba(255, 255, 255, 0.1));
  }

  /* ---- Change Category ---- */
  .category-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
    margin-top: 12px;
  }

  .category-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 11px;
    border: 1px solid var(--v6-border-strong, rgba(255, 255, 255, 0.14));
    border-radius: var(--radius-md, 6px);
    background: var(--v6-panel-raised, var(--surface-400, #1f1f23));
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    font-size: 13px;
    color: var(--text-primary, #fafafa);
    transition: border-color var(--duration-fast, 120ms) ease,
                background var(--duration-fast, 120ms) ease;
  }

  .category-option:hover {
    background: var(--v6-panel-hover, rgba(255, 255, 255, 0.07));
    border-color: var(--cat-color, var(--accent-primary, #8b5cf6));
  }

  .category-option.selected {
    border-color: var(--cat-color, var(--accent-primary, #8b5cf6));
    box-shadow: inset 0 0 0 1px var(--cat-color, var(--accent-primary, #8b5cf6));
  }

  .category-color-dot {
    width: 10px;
    height: 10px;
    flex: 0 0 10px;
    border-radius: 50%;
    background: var(--cat-color, #64748b);
  }

  .category-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* ---- Delete confirmation ---- */
  .pattern-dialog-danger {
    border-color: rgba(239, 68, 68, 0.35);
  }

  @keyframes v6-dialog-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
  }

  @keyframes v6-dialog-rise {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
  }

  @media (prefers-reduced-motion: reduce) {
    .pattern-dialog-overlay,
    .pattern-dialog { animation: none; }
  }
