/* ===========================
   FileForge — style.css
   Dark precision industrial theme
   =========================== */

/* ---------- Tokens ---------- */
:root {
  --bg:   #090b11;
  --s0:   #0d1018;
  --s1:   #111520;
  --s2:   #161b28;
  --s3:   #1c2333;
  --s4:   #222a3e;
  --s5:   #2a344d;

  --blue:   #5b9cf6;
  --blue2:  #3b7de8;
  --teal:   #2dd4bf;
  --green:  #34d399;
  --red:    #f87171;
  --amber:  #fbbf24;
  --purple: #a78bfa;
  --orange: #fb923c;

  --t1: #e8eaf0;
  --t2: #9aa3b8;
  --t3: #5c6880;
  --t4: #2e3850;

  --b:  rgba(255,255,255,0.06);
  --b2: rgba(255,255,255,0.10);
  --b3: rgba(255,255,255,0.16);

  --r: 6px;
  --r2: 10px;

  --ff: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --fm: ui-monospace, 'Cascadia Code', 'Fira Code', Consolas, monospace;

  --card-h: 56px;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: var(--ff);
  background: var(--bg);
  color: var(--t1);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button { cursor: pointer; font-family: var(--ff); border: none; background: none; }
input, select { font-family: var(--ff); }
label { cursor: pointer; }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--s5); border-radius: 3px; }

/* ---------- Header ---------- */
.hdr {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--s0);
  border-bottom: 1px solid var(--b);
  backdrop-filter: blur(12px);
}
.hdr-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 20px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.logo-mark {
  font-size: 22px;
  color: var(--blue);
  line-height: 1;
  filter: drop-shadow(0 0 8px var(--blue));
}
.logo-text {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--t1);
}
.logo-tag {
  font-size: 10px;
  color: var(--t3);
  font-family: var(--fm);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border: 1px solid var(--b2);
  border-radius: 3px;
  padding: 1px 5px;
}

.hdr-controls {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Mode bar */
.mode-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}
.mode-label {
  font-size: 11px;
  color: var(--t3);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  white-space: nowrap;
}
.mode-select {
  background: var(--s3);
  color: var(--t1);
  border: 1px solid var(--b2);
  border-radius: var(--r);
  padding: 5px 28px 5px 10px;
  font-size: 12px;
  outline: none;
  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='%235c6880'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  cursor: pointer;
  transition: border-color .15s;
}
.mode-select:focus { border-color: var(--blue); }
.mode-select option, .mode-select optgroup { background: var(--s2); }

.mode-compat-badge {
  font-size: 11px;
  font-family: var(--fm);
  color: var(--green);
  background: rgba(52,211,153,.12);
  border: 1px solid rgba(52,211,153,.25);
  border-radius: 10px;
  padding: 2px 8px;
  white-space: nowrap;
}

/* ---------- Buttons ---------- */
.btn-primary {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--blue);
  color: #fff;
  border-radius: var(--r);
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 600;
  transition: background .15s, transform .1s;
  white-space: nowrap;
}
.btn-primary:hover { background: var(--blue2); }
.btn-primary:active { transform: scale(.97); }

.dl-count {
  background: rgba(0,0,0,0.25);
  border-radius: 10px;
  padding: 1px 6px;
  font-size: 11px;
}

.btn-ghost {
  background: transparent;
  color: var(--t2);
  border: 1px solid var(--b2);
  border-radius: var(--r);
  padding: 7px 12px;
  font-size: 12px;
  transition: color .15s, border-color .15s;
  white-space: nowrap;
}
.btn-ghost:hover { color: var(--t1); border-color: var(--b3); }

.btn-sm { padding: 4px 10px; font-size: 11px; }

/* ---------- Drop Zone ---------- */
.dropzone {
  max-width: 960px;
  margin: 32px auto;
  padding: 0 20px;
}
.dz-inner {
  border: 2px dashed var(--b2);
  border-radius: var(--r2);
  background: var(--s1);
  padding: 48px 24px;
  text-align: center;
  transition: border-color .2s, background .2s;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.dz-inner::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% -20%, rgba(91,156,246,.08) 0%, transparent 60%);
  pointer-events: none;
}
.dropzone.drag-over .dz-inner {
  border-color: var(--blue);
  background: rgba(91,156,246,.07);
}

.dz-icon {
  font-size: 40px;
  line-height: 1;
  margin-bottom: 12px;
  color: var(--blue);
  filter: drop-shadow(0 0 12px var(--blue));
  animation: pulse 3s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: .7; filter: drop-shadow(0 0 8px var(--blue)); }
  50% { opacity: 1; filter: drop-shadow(0 0 18px var(--blue)); }
}

.dz-headline {
  font-size: 17px;
  font-weight: 600;
  color: var(--t1);
  margin-bottom: 4px;
}
.dz-sub {
  font-size: 13px;
  color: var(--t3);
  margin-bottom: 20px;
}
.dz-link {
  color: var(--blue);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.dz-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}
.chip {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  border-radius: 4px;
  padding: 3px 8px;
  opacity: .7;
}

/* ---------- Queue ---------- */
.queue {
  max-width: 960px;
  margin: 0 auto 40px;
  padding: 0 20px;
}
.queue-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding: 0 2px;
}
.queue-count {
  font-size: 11px;
  color: var(--t3);
  font-family: var(--fm);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}
.queue-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ---------- File Card ---------- */
.fc {
  background: var(--s1);
  border: 1px solid var(--b);
  border-radius: var(--r2);
  overflow: hidden;
  animation: cardIn .2s ease-out forwards;
  transition: border-color .15s;
}
.fc:hover { border-color: var(--b2); }
.fc.compat-yes { border-color: rgba(52,211,153,.25); }
.fc.compat-no  { border-color: rgba(251,191,36,.2); }

@keyframes cardIn {
  from { opacity: 0; transform: translateY(6px) scale(.99); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.fc-row {
  display: flex;
  align-items: center;
  height: var(--card-h);
  padding: 0 10px 0 10px;
  gap: 10px;
}

/* Thumb */
.fc-thumb {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 6px;
  overflow: hidden;
  background: var(--s3);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.fc-thumb-canvas {
  width: 36px;
  height: 36px;
  object-fit: cover;
  display: block;
}
.fc-thumb-icon {
  font-size: 18px;
  line-height: 1;
}

/* Info */
.fc-info {
  width: 190px;
  flex-shrink: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.fc-name {
  font-size: 12px;
  font-family: var(--fm);
  color: var(--t1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}
.fc-meta {
  display: flex;
  align-items: center;
  gap: 5px;
}
.fc-badge {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  border-radius: 3px;
  padding: 1px 5px;
}
.fc-size {
  font-size: 10px;
  color: var(--t3);
  font-family: var(--fm);
}

/* State area */
.fc-s {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}

/* idle */
.fc-s-idle .fc-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  flex: 1;
  min-width: 0;
}
.pill {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: 4px;
  padding: 3px 8px;
  border: 1px solid var(--b2);
  color: var(--t2);
  background: transparent;
  cursor: pointer;
  transition: all .12s;
  white-space: nowrap;
  font-family: var(--fm);
}
.pill:hover { border-color: var(--b3); color: var(--t1); }
.pill.sel-image { border-color: var(--blue); color: var(--blue); background: rgba(91,156,246,.1); }
.pill.sel-audio { border-color: var(--purple); color: var(--purple); background: rgba(167,139,250,.1); }
.pill.sel-video { border-color: var(--amber); color: var(--amber); background: rgba(251,191,36,.1); }
.pill.sel-doc   { border-color: var(--teal); color: var(--teal); background: rgba(45,212,191,.1); }

.btn-opts {
  font-size: 11px;
  color: var(--t3);
  border: 1px solid var(--b);
  border-radius: var(--r);
  padding: 4px 10px;
  white-space: nowrap;
  transition: all .12s;
  flex-shrink: 0;
}
.btn-opts:hover { color: var(--t2); border-color: var(--b2); }
.btn-opts[aria-expanded="true"] { color: var(--blue); border-color: rgba(91,156,246,.4); }

.btn-convert {
  font-size: 11px;
  font-weight: 600;
  background: rgba(91,156,246,.15);
  color: var(--blue);
  border: 1px solid rgba(91,156,246,.3);
  border-radius: var(--r);
  padding: 5px 14px;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all .12s;
}
.btn-convert:hover { background: rgba(91,156,246,.25); }
.btn-convert:disabled { opacity: .4; pointer-events: none; }

/* processing */
.fc-s-processing {
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 3px;
}
.fc-progress-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}
.fc-progress-bar {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--s4);
  overflow: hidden;
}
.fc-progress-fill {
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--blue), var(--teal));
  width: 0%;
  transition: width .15s ease;
  position: relative;
  overflow: hidden;
}
.fc-progress-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.3), transparent);
  animation: shimmer 1.2s linear infinite;
}
@keyframes shimmer {
  from { transform: translateX(-100%); }
  to   { transform: translateX(100%); }
}
.fc-progress-pct {
  font-size: 11px;
  font-family: var(--fm);
  color: var(--t2);
  width: 30px;
  text-align: right;
  flex-shrink: 0;
}
.fc-progress-msg {
  font-size: 10px;
  color: var(--t3);
  font-family: var(--fm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* done */
.fc-s-done {
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 3px;
  flex-wrap: nowrap;
}
.fc-done-badges {
  display: flex;
  align-items: center;
  gap: 5px;
}
.fc-done-badges .fc-from-badge,
.fc-done-badges .fc-to-badge {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: 3px;
  padding: 1px 5px;
  font-family: var(--fm);
}
.fc-arrow { color: var(--t4); font-size: 11px; }
.fc-done-sizes {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-family: var(--fm);
  color: var(--t3);
}
.fc-size-delta {
  font-size: 10px;
  border-radius: 3px;
  padding: 1px 5px;
}
.delta-smaller { color: var(--green); background: rgba(52,211,153,.1); }
.delta-larger  { color: var(--amber); background: rgba(251,191,36,.1); }

/* done row shares space with download / reconvert */
.fc-s-done {
  flex-direction: row;
  align-items: center;
  flex-wrap: wrap;
}
.fc-done-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.btn-download {
  font-size: 11px;
  font-weight: 600;
  background: rgba(52,211,153,.15);
  color: var(--green);
  border: 1px solid rgba(52,211,153,.3);
  border-radius: var(--r);
  padding: 5px 12px;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all .12s;
}
.btn-download:hover { background: rgba(52,211,153,.25); }

.btn-reconvert {
  font-size: 11px;
  color: var(--t3);
  border: 1px solid var(--b);
  border-radius: var(--r);
  padding: 5px 10px;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all .12s;
}
.btn-reconvert:hover { color: var(--t2); border-color: var(--b2); }

/* error */
.fc-err-msg {
  font-size: 11px;
  color: var(--red);
  font-family: var(--fm);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.btn-retry {
  font-size: 11px;
  font-weight: 600;
  background: rgba(248,113,113,.12);
  color: var(--red);
  border: 1px solid rgba(248,113,113,.3);
  border-radius: var(--r);
  padding: 5px 10px;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all .12s;
}
.btn-retry:hover { background: rgba(248,113,113,.22); }
.btn-change-fmt {
  font-size: 11px;
  color: var(--t3);
  border: 1px solid var(--b);
  border-radius: var(--r);
  padding: 5px 10px;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all .12s;
}
.btn-change-fmt:hover { color: var(--t2); border-color: var(--b2); }

/* mode-error */
.fc-mode-err-msg {
  font-size: 11px;
  color: var(--amber);
  font-family: var(--fm);
  flex: 1;
}

/* remove btn */
.fc-remove {
  font-size: 16px;
  color: var(--t4);
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all .12s;
  line-height: 1;
}
.fc-remove:hover { color: var(--red); background: rgba(248,113,113,.1); }

/* Options panel */
.fc-opts-panel {
  border-top: 1px solid var(--b);
  background: var(--s0);
  padding: 12px 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}
.fc-opt {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 140px;
}
.fc-opt label {
  font-size: 11px;
  color: var(--t3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: default;
}
.opt-val {
  font-family: var(--fm);
  color: var(--blue);
  font-size: 11px;
}
input[type="range"].opt-quality {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--s4);
  outline: none;
  cursor: pointer;
}
input[type="range"].opt-quality::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--blue);
  cursor: pointer;
}
.resize-row {
  display: flex;
  align-items: center;
  gap: 5px;
}
.opt-w, .opt-h {
  width: 60px;
  background: var(--s3);
  border: 1px solid var(--b2);
  border-radius: var(--r);
  padding: 4px 7px;
  color: var(--t1);
  font-size: 12px;
  font-family: var(--fm);
  outline: none;
  transition: border-color .12s;
}
.opt-w:focus, .opt-h:focus { border-color: var(--blue); }
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; }
.times { color: var(--t4); font-size: 12px; }
.btn-lock {
  font-size: 14px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r);
  border: 1px solid var(--b2);
  transition: all .12s;
  opacity: .6;
}
.btn-lock[aria-pressed="true"] { opacity: 1; border-color: rgba(91,156,246,.4); background: rgba(91,156,246,.08); }
.btn-lock:hover { opacity: 1; }
.opt-method, .opt-dpi {
  background: var(--s3);
  border: 1px solid var(--b2);
  border-radius: var(--r);
  padding: 4px 24px 4px 8px;
  color: var(--t1);
  font-size: 12px;
  outline: none;
  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='%235c6880'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 7px center;
  cursor: pointer;
}

/* ---------- Badge colours ---------- */
.badge-image  { background: rgba(91,156,246,.15); color: var(--blue); }
.badge-pdf    { background: rgba(248,113,113,.15); color: var(--red); }
.badge-docx   { background: rgba(147,210,255,.12); color: #93d2ff; }
.badge-xlsx   { background: rgba(52,211,153,.12);  color: var(--green); }
.badge-pptx   { background: rgba(251,191,36,.12);  color: var(--amber); }
.badge-rtf    { background: rgba(45,212,191,.12);  color: var(--teal); }
.badge-audio  { background: rgba(167,139,250,.12); color: var(--purple); }
.badge-video  { background: rgba(251,191,36,.12);  color: var(--amber); }
.badge-epub   { background: rgba(52,211,153,.12);  color: var(--green); }
.badge-other  { background: var(--s3); color: var(--t3); }

/* ---------- Chip colours (drop zone) ---------- */
.chip-image  { background: rgba(91,156,246,.12); color: var(--blue); }
.chip-pdf    { background: rgba(248,113,113,.12); color: var(--red); }
.chip-docx   { background: rgba(147,210,255,.09); color: #93d2ff; }
.chip-xlsx   { background: rgba(52,211,153,.09);  color: var(--green); }
.chip-pptx   { background: rgba(251,191,36,.09);  color: var(--amber); }
.chip-epub   { background: rgba(52,211,153,.09);  color: var(--green); }
.chip-audio  { background: rgba(167,139,250,.09); color: var(--purple); }
.chip-video  { background: rgba(251,191,36,.09);  color: var(--amber); }
.chip-rtf    { background: rgba(45,212,191,.09);  color: var(--teal); }

/* ---------- ffmpeg loading overlay ---------- */
.ffmpeg-loading {
  position: fixed;
  inset: 0;
  background: rgba(9,11,17,.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 999;
  backdrop-filter: blur(4px);
}
.ffmpeg-spinner {
  font-size: 32px;
  animation: spin 1.5s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.ffmpeg-msg { color: var(--t2); font-size: 13px; }
.ffmpeg-sub { color: var(--t3); font-size: 11px; font-family: var(--fm); }

/* ---------- Responsiveness ---------- */
@media (max-width: 640px) {
  .hdr-inner { flex-wrap: wrap; height: auto; padding: 10px 16px; gap: 8px; }
  .hdr-controls { flex-wrap: wrap; }
  .logo-tag { display: none; }
  .fc-info { width: 130px; }
  .dropzone { margin: 16px auto; }
  .dz-inner { padding: 32px 16px; }
}

/* Re-convert badge variant in mode */
.fc-reconvert-mode {
  font-size: 10px;
  color: var(--amber);
  background: rgba(251,191,36,.1);
  border: 1px solid rgba(251,191,36,.25);
  border-radius: 10px;
  padding: 2px 8px;
  white-space: nowrap;
}

/* Hide utility */
[hidden] { display: none !important; }