/* ==========================================================
   MP3 Tag Editor - Pi7
   Scoped under .mt-stage. Uses shared Pi7 tokens where available.
   Card-based layout: one card per file, big cover + inline fields.
   ========================================================== */

.mt-stage{
  margin: 14px auto 0;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.mt-stage input[type="file"]{ display: none; }

/* --- Bulk actions bar (visible only when 2+ files) --- */
.mt-bulk{
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  background: #f8f9ff;
  border: 1px solid #eef0fa;
  border-radius: 8px;
}
.mt-bulk-label{
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-right: 4px;
}
.mt-bulk-btn{
  background: #fff;
  border: 1px solid #e5e7f0;
  color: var(--pcolor);
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.mt-bulk-btn:hover{
  border-color: var(--pcolor);
  background: #eef0fa;
}

/* --- Cards container --- */
.mt-cards{
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

/* --- Single file card ---
   Grid layout:
     Row 1: cover column (fixed 120px) | fields column (fills remaining)
     Row 2: filename spans full width (no more overlap with Track input) */
.mt-card{
  position: relative;
  background: #fff;
  border: 1px solid #eef0fa;
  border-radius: 8px;
  padding: 16px 16px 12px;
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  grid-template-areas:
    "cover fields"
    "filename filename";
  gap: 8px 18px;
  width: 100%;
  box-sizing: border-box;
}
.mt-card > .mt-cover{ grid-area: cover; }
.mt-card > .mt-fields{ grid-area: fields; min-width: 0; }
.mt-card > .mt-filename{ grid-area: filename; }

/* --- Cover column --- */
.mt-cover{
  position: relative;
  flex-shrink: 0;
  width: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.mt-cover-slot{
  position: relative;
  width: 120px;
  height: 120px;
  border-radius: 6px;
  background: #f8f9ff;
  border: 1px dashed #c9cee5;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s;
}
.mt-cover-slot:hover{
  border-color: var(--pcolor);
  border-style: solid;
}
.mt-cover-slot.has-image{
  border-style: solid;
  border-color: #e5e7f0;
}
.mt-cover-img{
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.mt-cover-placeholder{
  color: #c9cee5;
  pointer-events: none;
  display: block;
  margin-bottom: 4px;
}
.mt-cover-hint{
  font-size: 10px;
  color: var(--muted);
  text-align: center;
  pointer-events: none;
  padding: 0 6px;
}
.mt-cover-slot{
  flex-direction: column;
}
.mt-cover-slot.has-image .mt-cover-placeholder,
.mt-cover-slot.has-image .mt-cover-hint{ display: none; }
.mt-cover-slot::after{
  content: 'Click to change';
  position: absolute;
  inset: auto 0 0 0;
  background: rgba(68, 73, 166, 0.85);
  color: #fff;
  font-size: 11px;
  padding: 4px 6px;
  text-align: center;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}
.mt-cover-slot:hover::after{ opacity: 1; }
.mt-cover-remove{
  background: transparent;
  border: none;
  color: #b00d44;
  font-size: 12px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}
.mt-cover-remove:hover{ background: #fff5f7; }
.mt-cover-remove.hide{ display: none; }

/* --- Fields column --- */
.mt-fields{
  flex: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  min-width: 0;
}
.mt-field{
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.mt-field-full{ grid-column: 1 / -1; }
.mt-field-third{ grid-column: span 2; }
.mt-field-quarter{ grid-column: span 1; }
.mt-fill-filename{
  grid-column: 1 / -1;
  justify-self: start;
  background: transparent;
  border: none;
  color: var(--pcolor);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 6px;
  margin-top: -2px;
  border-radius: 3px;
}
.mt-fill-filename:hover{
  background: #eef0fa;
  text-decoration: underline;
}
.mt-field > span{
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.mt-field input{
  padding: 8px 10px;
  font-size: 14px;
  border: 1px solid #e5e7f0;
  border-radius: 4px;
  background: #fff;
  outline: none;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
  font-family: inherit;
}
.mt-field input:hover{ border-color: var(--muted); }
.mt-field input:focus{
  border-color: var(--pcolor);
  box-shadow: 0 0 0 2px rgba(68, 73, 166, 0.15);
}

/* --- Remove-file button (in the filename row, right-aligned) --- */
.mt-remove{
  background: #fff;
  border: 1px solid #e5e7f0;
  color: #b00d44;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.mt-remove:hover{ background: #fff5f7; border-color: #f5c5d3; }

/* --- Filename footer on each card (grid row 2, full width).
   Flex row: [format pill + filename] on the left, [Remove button] on the right. */
.mt-filename{
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 8px;
  border-top: 1px solid #f0f2fa;
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted);
}
.mt-filename-info{
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
}
.mt-filename-name{
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.mt-format-pill{
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 8px;
  background: #eef0fa;
  color: var(--pcolor);
  margin-right: 4px;
  vertical-align: 1px;
  white-space: nowrap;
  flex-shrink: 0;
}
.mt-format-pill.readonly{
  background: #fff5f7;
  color: #b00d44;
}
.mt-readonly-note{
  font-size: 12px;
  color: #b00d44;
  margin-top: 6px;
}

/* --- Actions bar (Add More + Download) --- */
.mt-actions{
  display: flex;
  gap: 10px;
  align-items: stretch;
}
.mt-add-more{
  flex: 0 0 auto;
  padding: 12px 20px;
  background: #fff;
  border: 1px dashed #c9cee5;
  border-radius: 6px;
  color: var(--pcolor);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
}
.mt-add-more:hover{
  border-style: solid;
  border-color: var(--pcolor);
  background: #f8f9ff;
}
.mt-actions .process-btn{
  flex: 1;
  padding: 12px 26px;
}

/* --- Processing (batch save) --- */
.processing{
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  background: #fff;
  border-radius: 8px;
  border: 1px solid #eef0fa;
  color: var(--pcolor);
  font-size: 14px;
}
.proc-spin{
  width: 22px;
  height: 22px;
  border: 3px solid var(--pcolor);
  border-top-color: rgba(255,255,255,0.3);
  border-radius: 50%;
  animation: mt-spin 0.8s linear infinite;
}
@keyframes mt-spin{ to { transform: rotate(360deg); } }

/* --- Process button (reuse Pi7 pattern) --- */
.process-btn{
  background: linear-gradient(135deg, #4449a6, #373c8f);
  color: #fff;
  border: none;
  padding: 14px 26px;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  display: block;
  box-shadow: 0 6px 18px rgba(68, 73, 166, 0.30);
  transition: transform 0.15s, box-shadow 0.15s;
}
.process-btn:hover:not(:disabled){
  transform: translateY(-1px);
  box-shadow: 0 10px 26px rgba(68, 73, 166, 0.42);
}
.process-btn:disabled{
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

/* --- Article-section shared bits --- */
.articlesec table{
  width: 100%;
  border-collapse: collapse;
  margin: 18px 0;
  font-size: 14px;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(68, 73, 166, 0.06);
}
.articlesec thead{ background: var(--pcolor); color: #fff; }
.articlesec th{
  text-align: left;
  padding: 12px 14px;
  font-weight: 600;
  font-size: 13px;
}
.articlesec td{
  padding: 11px 14px;
  border-top: 1px solid #eef0fa;
  color: #262626;
  vertical-align: top;
}
.articlesec tbody tr:nth-child(even){ background: #f8f9ff; }
.illus{
  margin: 24px 0 36px;
  display: flex;
  justify-content: center;
}
.illus img{
  max-width: 100%;
  height: auto;
  border-radius: 16px;
  box-shadow: 0 14px 40px rgba(68, 73, 166, 0.14);
}

/* --- Responsive: mobile stacks cover on top of fields --- */
@media (max-width: 700px){
  .mt-card{
    grid-template-columns: 1fr;
    grid-template-areas:
      "cover"
      "fields"
      "filename";
    justify-items: center;
    padding: 14px;
  }
  .mt-cover{
    width: 100%;
    max-width: 200px;
  }
  .mt-cover-slot{
    width: 160px;
    height: 160px;
  }
  .mt-fields{
    grid-template-columns: repeat(2, 1fr);
    width: 100%;
  }
  .mt-field-third,
  .mt-field-quarter{
    grid-column: span 1;
  }
  .mt-filename{
    width: 100%;
    text-align: center;
  }
  .mt-remove{
    top: 6px;
    right: 6px;
  }
  .mt-actions{
    flex-direction: column;
  }
  .mt-bulk{
    padding: 10px;
  }
  .mt-bulk-label{
    flex: 0 0 100%;
  }
}
