/* /css/style-improve-popup.css v1.0.0 */
/* Draggable floating popup for Style Improve output – dark theme */

/* ===== Overlay ===== */
.si-popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 9990;
  animation: si-popup-fade-in 0.2s ease-out;
}

/* ===== Panel ===== */
.si-popup {
  /* Force dark-theme values so popup is always readable */
  --surface-raised: #1e2333;
  --surface: #171b2d;
  --card-border: #2a2f45;
  --text-primary: #e2e8f0;
  --text-muted: #94a3b8;

  position: fixed;
  z-index: 9991;
  background: var(--surface-raised, #1e2333);
  border: 1px solid var(--card-border, #2a2f45);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.3);
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: system-ui, -apple-system, sans-serif;
  color: var(--text-primary, #e2e8f0);
  animation: si-popup-slide-in 0.25s ease-out;
}

/* ===== Drag handle / header ===== */
.si-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--surface, #1a1f2e);
  border-bottom: 1px solid var(--card-border, #2a2f45);
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  flex-shrink: 0;
}

.si-popup-header:active {
  cursor: grabbing;
}

.si-popup-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.si-popup-drag-icon {
  width: 16px;
  height: 16px;
  color: var(--text-muted, #64748b);
  flex-shrink: 0;
}

.si-popup-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary, #e2e8f0);
}

.si-popup-close {
  background: none;
  border: none;
  color: var(--text-muted, #64748b);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}

.si-popup-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary, #e2e8f0);
}

/* ===== Body (scrollable improved text) ===== */
.si-popup-body {
  padding: 16px;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
  font-size: 0.9rem;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}

.si-popup-body::-webkit-scrollbar {
  width: 6px;
}

.si-popup-body::-webkit-scrollbar-track {
  background: transparent;
}

.si-popup-body::-webkit-scrollbar-thumb {
  background: var(--card-border, #2a2f45);
  border-radius: 3px;
}

/* Highlight marks within the popup */
.si-popup-body mark {
  background: rgba(139, 92, 246, 0.25);
  color: #c4b5fd;
  border-radius: 2px;
  padding: 0 2px;
}

/* ===== Footer with action buttons ===== */
.si-popup-footer {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--card-border, #2a2f45);
  background: var(--surface, #1a1f2e);
  flex-shrink: 0;
}

.si-popup-btn {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--card-border, #2a2f45);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--surface-raised, #1e2333);
  color: var(--text-primary, #e2e8f0);
  white-space: nowrap;
}

.si-popup-btn:hover {
  border-color: var(--text-muted, #64748b);
  background: rgba(255, 255, 255, 0.05);
}

.si-popup-btn-replace {
  background: #7c3aed;
  color: #fff;
  border-color: #7c3aed;
}

.si-popup-btn-replace:hover {
  background: #6d28d9;
  border-color: #6d28d9;
}

.si-popup-btn-paste {
  background: #3b82f6;
  color: #fff;
  border-color: #3b82f6;
}

.si-popup-btn-paste:hover {
  background: #2563eb;
  border-color: #2563eb;
}

.si-popup-btn-close {
  background: var(--surface, #1a1f2e);
  color: var(--text-muted, #64748b);
  border-color: var(--card-border, #2a2f45);
}

.si-popup-btn-close:hover {
  color: var(--text-primary, #e2e8f0);
  background: var(--surface-raised, #1e2333);
}

/* ===== Animations ===== */
@keyframes si-popup-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes si-popup-slide-in {
  from { opacity: 0; transform: translateY(-16px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===== Mobile: bottom-sheet style ===== */
@media (max-width: 640px) {
  .si-popup {
    width: 100%;
    max-width: 100%;
    border-radius: 16px 16px 0 0;
    bottom: 0 !important;
    left: 0 !important;
    top: auto !important;
    max-height: 75vh;
    animation: si-popup-sheet-up 0.3s ease-out;
  }

  .si-popup-header {
    cursor: default;
  }

  .si-popup-drag-icon {
    display: none;
  }

  /* Visual drag indicator for bottom sheet */
  .si-popup-header::before {
    content: '';
    position: absolute;
    top: 6px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 4px;
    background: var(--card-border, #2a2f45);
    border-radius: 2px;
  }

  .si-popup-header {
    position: relative;
    padding-top: 18px;
  }

  .si-popup-footer {
    flex-direction: column;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }

  .si-popup-btn {
    padding: 12px 16px;
    font-size: 14px;
  }
}

@keyframes si-popup-sheet-up {
  from { opacity: 0; transform: translateY(100%); }
  to   { opacity: 1; transform: translateY(0); }
}

@supports (height: 100svh) {
  .si-popup {
    max-height: calc(100svh - 48px);
  }
  @media (max-width: 640px) {
    .si-popup {
      max-height: 75svh;
    }
  }
}
