/* ============================================================
   MIHOMO BUILDER — CUSTOM MRS
   ============================================================ */

.custom-mrs-card {
  overflow: visible !important;
}

.custom-mrs-card > .card-body {
  overflow: visible !important;
}

.custom-mrs-head-icon {
  background: rgba(99, 102, 241, 0.11);
  color: #4f46e5;
}

.custom-mrs-form {
  margin: 0;
}

.custom-mrs-form-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 148px;
  gap: 0.85rem;
  align-items: end;
}

.custom-mrs-form-field {
  min-width: 0;
  position: relative;
  z-index: 20;
}

.custom-mrs-label-row {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  width: fit-content;
  max-width: 100%;
  margin-bottom: 0.42rem;
  position: relative;
  z-index: 30;
}

.custom-mrs-label {
  display: inline-flex !important;
  width: auto !important;
  flex: 0 0 auto;
  margin: 0 !important;
  white-space: normal;
}

.custom-mrs-tooltip-trigger {
  flex: 0 0 auto;
}

.custom-mrs-add-btn {
  min-height: 52px;
  border: 1px solid rgba(59, 130, 246, 0.2);
  background: rgba(59, 130, 246, 0.07);
  color: #1556b2;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  font-size: 0.92rem;
  font-weight: 700;
  padding: 0.85rem 1rem;
  cursor: pointer;
  transition:
    transform 0.2s ease,
    border-color 0.2s ease,
    background 0.2s ease,
    box-shadow 0.2s ease,
    color 0.2s ease;
}

.custom-mrs-add-btn:hover,
.custom-mrs-add-btn:focus {
  transform: translateY(-1px);
  border-color: rgba(59, 130, 246, 0.28);
  background: rgba(59, 130, 246, 0.12);
  color: #0f4c9b;
  box-shadow: 0 8px 18px rgba(17, 24, 39, 0.05);
}

.custom-mrs-add-btn .material-icons {
  font-size: 1.1rem;
}

.custom-mrs-list {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.custom-mrs-item {
  border: 1px solid rgba(229, 231, 235, 0.92);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(248, 250, 252, 0.94) 100%);
  padding: 0.9rem 0.95rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.custom-mrs-item-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.custom-mrs-item-main {
  min-width: 0;
  width: 100%;
}

.custom-mrs-item-title-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.custom-mrs-item-title {
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1.3;
  color: #111827;
}

.custom-mrs-type-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  color: #4338ca;
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.14);
}

.custom-mrs-item-meta {
  margin-top: 0.45rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.custom-mrs-meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  border-radius: 999px;
  background: rgba(248, 250, 252, 0.95);
  border: 1px solid rgba(229, 231, 235, 0.92);
  font-size: 0.78rem;
  padding: 0.28rem 0.55rem;
  line-height: 1.1;
  white-space: nowrap;
  color: #374151;
  font-weight: 600;
}

.custom-mrs-meta-chip i {
  font-size: 0.75rem;
}

.custom-mrs-item-url {
  margin-top: 0.7rem;
  border: 1px solid rgba(229, 231, 235, 0.88);
  background: rgba(255, 255, 255, 0.78);
  border-radius: 14px;
  padding: 0.62rem 0.72rem;
}

.custom-mrs-item-url code {
  display: block;
  font-size: 0.79rem;
  line-height: 1.45;
  color: #374151;
  white-space: normal;
  word-break: break-all;
  background: transparent;
  padding: 0;
}

.custom-mrs-item-actions {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 46px;
  gap: 0.85rem;
  align-items: end;
}

.custom-mrs-action-form {
  min-width: 0;
}

.custom-mrs-inline-label {
  display: block;
  margin-bottom: 0.52rem;
}

.custom-mrs-select {
  width: 100%;
  min-height: 46px;
}

.custom-mrs-item-actions .mihomo-select,
.custom-mrs-item-actions select {
  width: 100%;
  min-height: 46px;
}

.custom-mrs-delete-form {
  display: flex;
  align-items: end;
  justify-content: center;
}

.custom-mrs-delete-btn {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  border: 1px solid rgba(239, 68, 68, 0.18);
  background: rgba(239, 68, 68, 0.06);
  color: #b91c1c;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition:
    transform 0.2s ease,
    background 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease,
    box-shadow 0.2s ease;
}

.custom-mrs-delete-btn:hover,
.custom-mrs-delete-btn:focus {
  transform: translateY(-1px);
  background: rgba(239, 68, 68, 0.11);
  border-color: rgba(239, 68, 68, 0.26);
  color: #991b1b;
  box-shadow: 0 8px 18px rgba(17, 24, 39, 0.05);
}

.custom-mrs-delete-btn .material-icons {
  font-size: 1.1rem;
}

/* ============================================================
   CUSTOM MRS TOOLTIP
   ============================================================ */

.custom-mrs-tooltip-details {
  position: relative;
  flex: 0 0 auto;
  z-index: 40;
}

.custom-mrs-tooltip-summary {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: rgba(107, 114, 128, 0.13);
  color: #6b7280;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  list-style: none;
  outline: none;
  user-select: none;
  -webkit-user-select: none;
}

.custom-mrs-tooltip-summary::-webkit-details-marker {
  display: none;
}

.custom-mrs-tooltip-summary::marker {
  content: "";
}

.custom-mrs-tooltip-summary i {
  font-size: 0.8rem;
  pointer-events: none;
}

.custom-mrs-tooltip-details[open] .custom-mrs-tooltip-summary {
  background: rgba(79, 70, 229, 0.14);
  color: #4f46e5;
}

.custom-mrs-tooltip-panel {
  position: absolute;
  left: 0;
  top: calc(100% + 10px);
  z-index: 120;
  width: min(360px, calc(100vw - 32px));
  padding: 0.72rem 0.78rem;
  border-radius: 14px;
  background: rgba(17, 24, 39, 0.97);
  color: #f9fafb;
  font-size: 0.78rem;
  line-height: 1.45;
  font-weight: 500;
  box-shadow: 0 14px 30px rgba(17, 24, 39, 0.22);
  user-select: text;
  -webkit-user-select: text;
}

.custom-mrs-tooltip-panel a {
  display: inline-block;
  margin-top: 0.25rem;
  color: #bfdbfe;
  font-weight: 700;
  text-decoration: none;
  word-break: break-all;
}

.custom-mrs-tooltip-panel a:hover {
  text-decoration: underline;
}

@media (max-width: 768px) {
  .custom-mrs-form-row {
    grid-template-columns: 1fr;
  }

  .custom-mrs-add-btn {
    width: 100%;
  }

  .custom-mrs-item-actions {
    grid-template-columns: 1fr;
  }

  .custom-mrs-delete-form {
    width: 100%;
  }

  .custom-mrs-delete-btn {
    width: 100%;
    height: 44px;
    border-radius: 14px;
  }
}

@media (max-width: 576px) {
  .custom-mrs-item {
    padding: 0.82rem 0.85rem;
    border-radius: 16px;
  }

  .custom-mrs-item-title {
    font-size: 0.9rem;
  }

  .custom-mrs-item-url code {
    font-size: 0.76rem;
  }

  .custom-mrs-add-btn {
    min-height: 48px;
    border-radius: 14px;
    padding: 0.8rem 0.9rem;
  }

  .custom-mrs-label-row {
    align-items: flex-start;
  }

  .custom-mrs-tooltip-panel {
    left: auto;
    right: 0;
    width: min(320px, calc(100vw - 32px));
  }
}

@media (prefers-reduced-motion: reduce) {
  .custom-mrs-add-btn,
  .custom-mrs-delete-btn {
    transition: none !important;
  }
}