/* js/archive.css — right-side drawer for the v1.2 archive feature.
   Loaded by index.html alongside the existing styles.css. Uses the same design tokens
   declared in :root at the top of styles.css (--ink, --muted, --line, --paper, --panel,
   --teal, --teal-dark, --coral, --amber, --rose, --green-soft, --amber-soft, --coral-soft,
   --shadow). Keep this file self-contained: it only references the archive- prefix. */

.archive-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(25, 26, 26, 0.36);
  opacity: 0;
  pointer-events: none;
  transition: opacity 240ms ease;
  z-index: 40;
}

.archive-backdrop[data-open="true"] {
  opacity: 1;
  pointer-events: auto;
}

@media (min-width: 1024px) {
  .archive-backdrop { display: none; }
}

.archive-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 360px;
  max-width: 92vw;
  background: var(--panel);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 280ms ease;
  z-index: 50;
  font-size: 13px;
  color: var(--ink);
}

.archive-drawer[data-open="true"] {
  transform: translateX(0);
}

@media (min-width: 1024px) {
  body[data-archive-open="true"] .workspace {
    transform: translateX(-360px);
  }
  .workspace {
    transition: transform 280ms ease;
  }
}

@media (max-width: 1023px) {
  body[data-archive-open="true"] .workspace {
    pointer-events: none;
    filter: blur(0.5px);
  }
}

.archive-drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(15, 118, 110, 0.04);
}

.archive-drawer__title {
  font-size: 15px;
  font-weight: 700;
  color: var(--teal-dark);
  margin: 0;
}

.archive-drawer__close {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

.archive-drawer__close:hover {
  border-color: var(--teal);
  color: var(--teal-dark);
}

.archive-drawer__body {
  flex: 1 1 auto;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.archive-search {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.archive-search input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  background: var(--paper);
  color: var(--ink);
}

.archive-search input:focus {
  outline: none;
  border-color: var(--teal);
  background: var(--panel);
}

.archive-section {
  border-bottom: 1px solid var(--line);
}

.archive-section__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px 4px;
}

.archive-section__head h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 700;
  margin: 0;
}

.archive-section__head button {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--panel);
  color: var(--teal-dark);
  border: 1px solid var(--line);
}

.archive-section__head button:hover {
  border-color: var(--teal);
}

.archive-list {
  list-style: none;
  margin: 0;
  padding: 4px 8px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.archive-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--paper);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color 140ms ease, background 140ms ease;
}

.archive-card:hover,
.archive-card[aria-selected="true"] {
  border-color: var(--teal);
  background: var(--green-soft);
}

.archive-card__title {
  font-weight: 600;
  font-size: 13px;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.archive-card__desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.archive-card__meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
}

.archive-card__delete {
  align-self: flex-end;
  font-size: 11px;
  background: transparent;
  border: none;
  color: var(--coral);
  padding: 0;
  cursor: pointer;
}

.archive-card__delete:hover {
  text-decoration: underline;
}

.archive-empty {
  padding: 12px 16px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

.archive-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid transparent;
}

.archive-status--draft     { background: #eceee8; color: #4a4f4a; border-color: var(--line); }
.archive-status--submitted { background: #e2efff; color: #1d4e89; border-color: #b8d4f1; }
.archive-status--succeeded { background: var(--green-soft); color: var(--teal-dark); border-color: rgba(15, 118, 110, 0.24); }
.archive-status--failed    { background: var(--coral-soft); color: var(--coral); border-color: rgba(201, 79, 55, 0.3); }
.archive-status--expired   { background: var(--amber-soft); color: var(--amber); border-color: rgba(183, 121, 31, 0.3); }

.archive-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.archive-row__main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.archive-row__title {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.archive-row__meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
}

.archive-row__actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: stretch;
}

.archive-row__actions button {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--panel);
  color: var(--teal-dark);
  border: 1px solid var(--line);
}

.archive-row__actions button:hover {
  border-color: var(--teal);
}

.archive-row__actions button[data-variant="danger"] {
  color: var(--coral);
  border-color: rgba(201, 79, 55, 0.4);
}

.archive-foot {
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: var(--paper);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.archive-foot__row {
  display: flex;
  gap: 8px;
}

.archive-foot input,
.archive-foot textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  resize: vertical;
}

.archive-foot button.primary {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
  flex: 1;
  padding: 8px 12px;
  border-radius: 8px;
}

.archive-foot button.primary:hover {
  background: var(--teal-dark);
  border-color: var(--teal-dark);
}

.archive-foot button.muted {
  background: var(--panel);
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 8px 12px;
  border-radius: 8px;
}

.archive-foot button.muted:hover {
  border-color: var(--coral);
  color: var(--coral);
}

.archive-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 12px;
  z-index: 80;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}

.archive-toast[data-visible="true"] { opacity: 1; }

.archive-toast[data-level="error"] { background: var(--coral); }
.archive-toast[data-level="success"] { background: var(--teal-dark); }
