/* Patch & Settings Storage Styles — Canonical GM3 Tokens
   Enforces token-only colors, zero hardcoded hex, z-index ladder (1200/1300),
   and mobile alignment. */

.patch-actions-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.patch-action-btn {
  min-height: 40px;
  height: 40px;
  min-width: 40px;
  padding: 0 14px;
  border-radius: 9999px;
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background-color 0.18s ease, color 0.18s ease, transform 0.15s ease;
}

.patch-action-btn .material-symbols-outlined {
  font-size: 18px;
}

.patch-action-btn.is-dirty {
  background-color: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
}

.patch-action-btn.is-saved {
  background-color: var(--md-sys-color-green-tonal);
  color: var(--md-sys-color-on-green-tonal);
}

.patch-reset-btn {
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  border-radius: 9999px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.patch-reset-btn .material-symbols-outlined {
  font-size: 20px;
}

/* Modal z-index ladder: Backdrop (1200) | Modal Card (1300) */
.patch-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
}

.patch-modal-backdrop.is-open {
  display: flex;
}

.patch-modal-card {
  position: relative;
  z-index: 1300;
  width: 100%;
  max-width: 440px;
  background-color: var(--md-sys-color-surface-container-lowest);
  color: var(--md-sys-color-on-surface);
  border-radius: 24px;
  padding: 24px;
  border: none;
  display: flex;
  flex-direction: column;
  gap: 20px;
  box-sizing: border-box;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.28);
}

[data-theme="dark"] .patch-modal-card {
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.65);
}

.patch-modal-card .card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.patch-modal-card .card-title-cluster {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--md-sys-color-on-surface);
}

.patch-modal-card .card-title {
  font-family: var(--font-family-display, var(--md-ref-typeface-brand, 'Google Sans Flex', sans-serif));
  font-size: 18px;
  font-weight: 600;
  margin: 0;
  color: var(--md-sys-color-on-surface);
}

.patch-modal-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.patch-modal-field .control-label-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--md-sys-color-on-surface-variant);
}

.patch-modal-input-wrapper {
  position: relative;
  width: 100%;
}

.patch-modal-card .m3-input-field {
  width: 100%;
  min-height: 42px;
  height: 42px;
  padding: 0 42px 0 14px;
  font-size: 14px;
  box-sizing: border-box;
  background-color: var(--md-sys-color-surface-container-lowest);
  color: var(--md-sys-color-on-surface);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: 8px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.patch-modal-card .m3-input-field:focus {
  border-color: var(--md-sys-color-primary);
  box-shadow: 0 0 0 1px var(--md-sys-color-primary);
}

.patch-modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 4px;
}

.patch-modal-actions .btn {
  min-height: 40px;
  height: 40px;
  min-width: 40px;
  padding: 0 16px;
  border-radius: 9999px;
  font-size: 13.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.patch-modal-actions .btn-text {
  min-height: 40px;
  height: 40px;
  min-width: 40px;
  padding: 0 14px;
  border-radius: 9999px;
  font-size: 13.5px;
  font-weight: 600;
}

/* Mobile Top-Bar & Preset Strip responsiveness */
@media (max-width: 720px) {
  .preset-Controls-right .patch-actions-group {
    grid-column: 1 / -1;
    width: 100%;
    justify-content: flex-start;
  }
}

/* User Patch Pills & Delete Badge */
.m3-pill-tabs.gm3-connected-dsp .m3-pill-tab.user-patch-pill,
.m3-pill-tab.user-patch-pill {
  position: relative;
  padding-right: 40px;
}

.user-patch-label {
  display: inline-block;
  white-space: nowrap;
}

.user-patch-delete-btn {
  position: absolute;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  background-color: transparent;
  color: var(--md-sys-color-on-surface-variant);
  cursor: pointer;
  transition: opacity 0.15s ease, color 0.15s ease;
}

.user-patch-delete-icon {
  width: 20px;
  height: 20px;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: var(--md-sys-color-surface-container-highest);
  font-size: 12px;
  line-height: 1;
  transition: background-color 0.15s ease, color 0.15s ease;
}

@media (hover: hover) {
  .m3-pill-tab.user-patch-pill:hover .user-patch-delete-btn,
  .m3-pill-tab.user-patch-pill:focus-within .user-patch-delete-btn {
    opacity: 0.9;
    pointer-events: auto;
  }
  .user-patch-delete-btn:hover {
    opacity: 1;
  }
  .user-patch-delete-btn:hover .user-patch-delete-icon {
    background-color: var(--md-sys-color-error-container);
    color: var(--md-sys-color-on-error-container);
  }
}

@media (hover: none) {
  .m3-pill-tab.user-patch-pill .user-patch-delete-btn {
    opacity: 0.9;
    pointer-events: auto;
  }
}

.m3-pill-tabs.gm3-connected-dsp .m3-pill-tab.user-patch-pill.active::before {
  content: '';
  width: 5.5px;
  height: 5.5px;
  border-radius: 9999px;
  background-color: currentColor;
  margin-right: 2px;
}

.patch-delete-confirm-text {
  font-family: var(--md-ref-typeface-plain);
  font-size: 14px;
  line-height: 1.45;
  color: var(--md-sys-color-on-surface-variant);
  margin: 0;
}

.btn-delete-danger {
  background-color: var(--md-sys-color-error) !important;
  color: var(--md-sys-color-on-error) !important;
}

@media (hover: hover) {
  .btn-delete-danger:hover {
    filter: brightness(0.92);
  }
}
