/* ft-save.css — styles for the save/restore UI shipped alongside ft-save.js.
   Keep this file dependency-free; it must render cleanly on every tool page
   whether or not the tool's own stylesheet is present. */

/* ---------- workspace pill (lives in each tool header) ---------- */
.ft-ws-pill,
.ft-ws-pill-empty {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.4;
  font-weight: 500;
  border: 1px solid #d7dbe0;
  background: #fff;
  color: #1f2933;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
  user-select: none;
}
.ft-ws-pill:hover,
.ft-ws-pill-empty:hover { background: #f4f6f8; border-color: #aab2bc; }

.ft-ws-pill-empty { color: #6b7280; font-style: italic; }

.ft-ws-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 2px rgba(34,197,94,0.15);
}
.ft-ws-pill-empty .ft-ws-dot { background: #9ca3af; box-shadow: none; }

.ft-ws-count {
  display: inline-block;
  min-width: 18px;
  text-align: center;
  padding: 0 6px;
  border-radius: 10px;
  background: #eef1f5;
  color: #384252;
  font-size: 11px;
  font-weight: 600;
}

/* save-slot container used by installHeaderControls() */
.ft-save-slot {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---------- buttons (scoped, don't fight tool styles) ---------- */
.ft-btn {
  appearance: none;
  border: 1px solid #d7dbe0;
  background: #fff;
  color: #1f2933;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  line-height: 1.3;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.ft-btn:hover { background: #f4f6f8; border-color: #aab2bc; }
.ft-btn:focus-visible { outline: 2px solid #2563eb; outline-offset: 1px; }

.ft-btn-primary {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}
.ft-btn-primary:hover { background: #1d4ed8; border-color: #1d4ed8; }

.ft-btn-ghost {
  background: transparent;
  border-color: transparent;
  color: #4b5563;
}
.ft-btn-ghost:hover { background: #eef1f5; color: #1f2933; border-color: transparent; }

.ft-btn-danger {
  background: #fff;
  border-color: #fca5a5;
  color: #b91c1c;
}
.ft-btn-danger:hover { background: #fef2f2; border-color: #ef4444; }

.ft-btn-sm {
  padding: 3px 8px;
  font-size: 12px;
  border-radius: 5px;
}

/* ---------- inputs inside modals ---------- */
.ft-input {
  appearance: none;
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border: 1px solid #d7dbe0;
  border-radius: 6px;
  font-size: 14px;
  background: #fff;
  color: #1f2933;
}
.ft-input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}

/* ---------- modal ---------- */
.ft-modal-root {
  position: fixed;
  inset: 0;
  z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  color: #1f2933;
}
.ft-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.48);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: ft-fade-in 0.15s ease;
}
.ft-modal {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #fff;
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow: auto;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(2, 6, 23, 0.3),
              0 4px 12px rgba(2, 6, 23, 0.08);
  padding: 22px 24px 20px;
  animation: ft-pop-in 0.18s ease;
}
.ft-modal h2 {
  margin: 0 0 4px;
  font-size: 17px;
  font-weight: 600;
  color: #0f172a;
}
.ft-modal p.ft-modal-sub {
  margin: 0 0 14px;
  font-size: 13px;
  color: #64748b;
}

.ft-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.ft-field {
  margin: 10px 0;
}
.ft-field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #334155;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 4px;
}

/* ---------- item list (saves inside a workspace) ---------- */
.ft-item-list {
  list-style: none;
  padding: 0;
  margin: 6px 0 0;
  max-height: 46vh;
  overflow: auto;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}
.ft-item-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 10px;
  padding: 10px 12px;
  border-bottom: 1px solid #eef1f5;
  align-items: center;
}
.ft-item-row:last-child { border-bottom: 0; }
.ft-item-row:hover { background: #f8fafc; }

.ft-item-row .ft-item-name {
  font-weight: 500;
  color: #0f172a;
  font-size: 14px;
  word-break: break-word;
}
.ft-item-meta {
  grid-column: 1 / 2;
  font-size: 12px;
  color: #64748b;
  margin-top: 2px;
}
.ft-item-actions {
  grid-column: 2 / 3;
  grid-row: 1 / span 2;
  display: flex;
  gap: 4px;
  align-self: center;
}

/* tag (tool slug / category badges) */
.ft-tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 10px;
  background: #eef1f5;
  color: #334155;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* ---------- empty states ---------- */
.ft-empty {
  padding: 24px 16px;
  text-align: center;
  color: #64748b;
  font-size: 13px;
  background: #f8fafc;
  border: 1px dashed #d7dbe0;
  border-radius: 8px;
}

/* ---------- storage bar ---------- */
.ft-storage-bar {
  position: relative;
  height: 6px;
  background: #eef1f5;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 6px;
}
.ft-storage-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: linear-gradient(90deg, #22c55e, #16a34a);
  transition: width 0.2s ease, background 0.2s ease;
}
.ft-storage-fill[data-level="warn"] { background: linear-gradient(90deg, #f59e0b, #d97706); }
.ft-storage-fill[data-level="crit"] { background: linear-gradient(90deg, #ef4444, #b91c1c); }
.ft-storage-label {
  font-size: 11px;
  color: #64748b;
  margin-top: 4px;
  display: flex;
  justify-content: space-between;
}

/* ---------- toast notifications ---------- */
.ft-toast-host {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10000;
  pointer-events: none;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
}
.ft-toast {
  pointer-events: auto;
  min-width: 220px;
  max-width: 360px;
  padding: 10px 14px;
  border-radius: 8px;
  background: #0f172a;
  color: #f8fafc;
  font-size: 13px;
  line-height: 1.4;
  box-shadow: 0 8px 24px rgba(2, 6, 23, 0.25);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.ft-toast-show {
  opacity: 1;
  transform: translateY(0);
}
.ft-toast-ok   { background: #166534; }
.ft-toast-err  { background: #991b1b; }
.ft-toast-info { background: #1e40af; }

/* ---------- animations ---------- */
@keyframes ft-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes ft-pop-in {
  from { opacity: 0; transform: translate(-50%, -48%) scale(0.98); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* ---------- small screens ---------- */
@media (max-width: 540px) {
  .ft-modal { padding: 18px 16px; }
  .ft-item-row { grid-template-columns: 1fr; }
  .ft-item-actions {
    grid-column: 1 / -1;
    grid-row: auto;
    justify-content: flex-start;
    margin-top: 6px;
  }
  .ft-toast-host { left: 12px; right: 12px; bottom: 12px; }
  .ft-toast { max-width: none; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .ft-modal-backdrop,
  .ft-modal,
  .ft-toast,
  .ft-storage-fill { animation: none !important; transition: none !important; }
}
