/* ─────────────────────────────────────────────────────────────
   item-drawer.css
   Slide-in drawer for wardrobe item editing.
   All selectors scoped to .id-* / #id-* to avoid collisions.
   Hooks into the same CSS variables as policy-drawer:
   --muted, --heading, --body, --paper, --border, --card.
───────────────────────────────────────────────────────────── */

/* ── Overlay ─────────────────────────────────────────────── */

.id-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.32);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}
.id-overlay.open {
  opacity: 1;
  pointer-events: all;
}

/* ── Drawer shell ─────────────────────────────────────────── */

.id-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 420px;
  max-width: 100vw;
  height: 100%;
  background: var(--card, #fff);
  border-left: 1px solid var(--border, #e5e7eb);
  box-shadow: -8px 0 40px rgba(0, 0, 0, 0.09);
  z-index: 201;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.26s cubic-bezier(0.4, 0, 0.2, 1);
}
.id-drawer.open {
  transform: translateX(0);
}

/* ── Header ──────────────────────────────────────────────── */

.id-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border, #e5e7eb);
  flex-shrink: 0;
}
.id-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.id-close {
  background: none;
  border: none;
  font-size: 20px;
  line-height: 1;
  color: var(--muted, #9ca3af);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.12s, background 0.12s;
}
.id-close:hover {
  color: var(--heading, #111);
  background: var(--paper, #f3f4f6);
}

/* Category badge */
.id-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.9px;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 3px;
  font-family: 'DM Mono', 'Fira Code', 'Cascadia Code', monospace;
}

/* Editable name input */
.id-name-input {
  width: 100%;
  box-sizing: border-box;
  font-size: 16px;
  font-weight: 600;
  color: var(--heading, #111);
  background: transparent;
  border: none;
  border-bottom: 1px solid transparent;
  padding: 2px 0 4px;
  outline: none;
  transition: border-color 0.15s;
}
.id-name-input:focus {
  border-bottom-color: #6366f1;
}
.id-name-input::placeholder {
  color: var(--muted, #9ca3af);
  font-weight: 400;
}

/* ── Hidden / Specific toggle ─────────────────────────────── */

.id-toggle-label {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  user-select: none;
}
.id-toggle-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.id-toggle-track {
  position: relative;
  width: 32px;
  height: 18px;
  background: var(--muted, #9ca3af);
  border-radius: 9px;
  transition: background 0.18s;
  flex-shrink: 0;
}
.id-toggle-input:checked + .id-toggle-track {
  background: #6366f1;
}
.id-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 3px rgba(0,0,0,0.22);
}
.id-toggle-input:checked + .id-toggle-track .id-toggle-thumb {
  transform: translateX(14px);
}
.id-toggle-text {
  font-size: 11px;
  color: var(--muted, #9ca3af);
  font-family: 'DM Mono', 'Fira Code', 'Cascadia Code', monospace;
}

/* ── Scrollable body ─────────────────────────────────────── */

.id-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.id-body::-webkit-scrollbar { width: 3px; }
.id-body::-webkit-scrollbar-track { background: transparent; }
.id-body::-webkit-scrollbar-thumb {
  background: var(--border, #e5e7eb);
  border-radius: 2px;
}

/* ── Sections ─────────────────────────────────────────────── */

.id-section {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border, #e5e7eb);
}
.id-section:last-child { border-bottom: none; }
.id-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted, #9ca3af);
  margin-bottom: 10px;
}
.id-param-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--muted, #6b7280);
  font-family: 'DM Mono', 'Fira Code', 'Cascadia Code', monospace;
}

/* ── Select ──────────────────────────────────────────────── */

.id-select {
  width: 100%;
  box-sizing: border-box;
  font-size: 12px;
  font-family: 'DM Mono', 'Fira Code', 'Cascadia Code', monospace;
  padding: 7px 10px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 5px;
  background: var(--paper, #f9fafb);
  color: var(--heading, #111);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%239ca3af'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: border-color 0.12s;
}
.id-select:focus {
  outline: none;
  border-color: #6366f1;
  background-color: #fff;
}

/* ── Number inputs ───────────────────────────────────────── */

.id-num-input {
  width: 100%;
  box-sizing: border-box;
  font-size: 13px;
  font-family: 'DM Mono', 'Fira Code', 'Cascadia Code', monospace;
  padding: 7px 10px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 5px;
  background: var(--paper, #f9fafb);
  color: var(--heading, #111);
  text-align: center;
  transition: border-color 0.12s, background 0.12s;
  -moz-appearance: textfield;
}
.id-num-input::-webkit-outer-spin-button,
.id-num-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.id-num-input:focus {
  outline: none;
  border-color: #6366f1;
  background: #fff;
}
.id-num-input::placeholder { color: var(--muted, #9ca3af); font-style: italic; }

/* ── Condition / intensity chip groups ───────────────────── */

.id-chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.id-chip {
  font-size: 11px;
  font-family: 'DM Mono', 'Fira Code', 'Cascadia Code', monospace;
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid var(--border, #d1d5db);
  background: var(--paper, #f3f4f6);
  color: var(--body, #374151);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  line-height: 1;
}
.id-chip:hover { background: var(--border, #e5e7eb); }
.id-chip--on {
  background: #e0e7ff;
  border-color: #a5b4fc;
  color: #3730a3;
  font-weight: 600;
}
.id-chip--on:hover { background: #c7d2fe; }
.id-chip--excl {
  border-style: dashed;
}
.id-chip--excl-on {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #b91c1c;
  border-style: dashed;
  font-weight: 600;
}
.id-chip--excl-on:hover { background: #fecaca; }

/* ── Tag list ────────────────────────────────────────────── */

.id-tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 7px 10px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 5px;
  background: var(--paper, #f9fafb);
  min-height: 38px;
  transition: border-color 0.12s;
  cursor: text;
}
.id-tag-list:focus-within {
  border-color: #6366f1;
  background: #fff;
}
.id-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-family: 'DM Mono', 'Fira Code', 'Cascadia Code', monospace;
  background: #e0e7ff;
  color: #3730a3;
  padding: 3px 8px 3px 9px;
  border-radius: 3px;
}
.id-tag-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: #6366f1;
  font-size: 15px;
  line-height: 1;
  padding: 0;
  opacity: 0.55;
  transition: opacity 0.12s;
}
.id-tag-remove:hover { opacity: 1; }
.id-tag-input {
  border: none;
  outline: none;
  background: transparent;
  font-size: 12px;
  font-family: 'DM Mono', 'Fira Code', 'Cascadia Code', monospace;
  color: var(--heading, #111);
  min-width: 80px;
  flex: 1;
}
.id-tag-input::placeholder { color: var(--muted, #9ca3af); }

/* ── Textarea ─────────────────────────────────────────────── */

.id-textarea {
  width: 100%;
  box-sizing: border-box;
  font-size: 13px;
  font-family: inherit;
  line-height: 1.6;
  padding: 8px 10px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 5px;
  background: var(--paper, #f9fafb);
  color: var(--body, #374151);
  resize: vertical;
  transition: border-color 0.12s, background 0.12s;
}
.id-textarea:focus {
  outline: none;
  border-color: #6366f1;
  background: #fff;
}
.id-textarea::placeholder { color: var(--muted, #9ca3af); }

/* ── Footer ──────────────────────────────────────────────── */

.id-footer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border, #e5e7eb);
  flex-shrink: 0;
  background: var(--card, #fff);
}
.id-footer-btns {
  display: flex;
  gap: 10px;
}
.id-btn {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  padding: 9px 16px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s, opacity 0.12s;
  border: none;
}
.id-btn--ghost {
  background: var(--paper, #f3f4f6);
  color: var(--body, #374151);
  border: 1px solid var(--border, #e5e7eb);
}
.id-btn--ghost:hover { background: var(--border, #e5e7eb); }
.id-btn--primary {
  flex: 2;
  background: #111;
  color: #fff;
}
.id-btn--primary:hover:not(:disabled) { background: #374151; }
.id-btn--primary:disabled {
  opacity: 0.32;
  cursor: not-allowed;
}
.id-btn--danger {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fca5a5;
}
.id-btn--danger:hover { background: #fecaca; }

/* ── Inline error ────────────────────────────────────────── */

.id-error {
  font-size: 12px;
  font-family: 'DM Mono', 'Fira Code', 'Cascadia Code', monospace;
  color: #b91c1c;
  background: #fee2e2;
  border-radius: 5px;
  padding: 8px 12px;
  line-height: 1.5;
}

/* ── Edit button injected into existing item cards ───────── */

.id-item-wrap {
  position: relative;
}
.id-edit-btn {
  position: absolute;
  bottom: 12px;
  right: 12px;
  font-size: 12px;
  padding: 0;
  cursor: pointer;
  color: var(--muted, #9ca3af);
  background: none;
  border: none;
  transition: color 0.12s;
  line-height: 1;
}
.id-edit-btn:hover {
  color: var(--body, #374151);
}

/* ── Mobile ──────────────────────────────────────────────── */

@media (max-width: 480px) {
  .id-drawer {
    width: 100vw;
    border-left: none;
  }
}
