/* ═══════════════════════════════════════════════════════════════
   layout.css
   ═══════════════════════════════════════════════════════════════ */

body {
  display: grid;
  grid-template-rows: 52px 1fr 28px;
  height: 100vh;
  overflow: hidden;
}

/* ── HEADER ──────────────────────────────────────────────────── */
#app-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  z-index: 50;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.brand-icon {
  width: 28px; height: 28px;
  color: var(--accent);
  filter: drop-shadow(0 0 6px var(--accent-glow));
}

.brand-name {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-version {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  padding: 2px 6px;
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
}

.header-tabs {
  display: flex;
  gap: 4px;
  flex: 1;
  justify-content: center;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  transition: all var(--t-fast);
}

.tab-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

.tab-btn.active {
  background: var(--accent-faint);
  color: var(--accent);
  border-color: var(--accent);
}

.tab-btn i { font-size: 15px; }

.header-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.hue-control {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 14px;
}

.hue-control input[type="range"] {
  width: 90px;
  background: linear-gradient(to right,
    hsl(0,80%,58%), hsl(30,80%,58%), hsl(60,80%,58%),
    hsl(120,80%,58%), hsl(180,80%,58%), hsl(210,80%,58%),
    hsl(270,80%,58%), hsl(300,80%,58%), hsl(330,80%,58%), hsl(360,80%,58%)
  );
  height: 5px;
}

/* ── MAIN CONTENT ────────────────────────────────────────────── */
#main-content {
  overflow: hidden;
  position: relative;
}

.tab-panel {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.tab-panel.hidden { display: none; }

/* ── STATUS BAR ──────────────────────────────────────────────── */
#status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

/* ── DROPZONE ────────────────────────────────────────────────── */
.dropzone {
  border: 2px dashed var(--border-mid);
  border-radius: var(--radius-xl);
  padding: 48px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background: var(--bg-surface);
  transition: border-color var(--t-fast), background var(--t-fast);
  cursor: pointer;
}

.dropzone:hover,
.dropzone.drag-over {
  border-color: var(--accent);
  background: var(--accent-faint);
}

.drop-icon { font-size: 52px; color: var(--accent); opacity: 0.5; }
.drop-icon-sm { font-size: 28px; color: var(--accent); opacity: 0.4; }

.drop-title { font-size: 18px; font-weight: 700; color: var(--text-secondary); }
.drop-sub   { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); letter-spacing: 0.05em; }

.dropzone-sm {
  padding: 20px;
  border-radius: var(--radius-lg);
  flex-direction: row;
  gap: 12px;
}

.dropzone-sm p { font-size: 12px; color: var(--text-muted); }

/* ── ARCHIVE BROWSER ─────────────────────────────────────────── */
#archive-browser {
  display: flex;
  flex-direction: column;
  gap: 0;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  flex: 1;
}

#browser-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.toolbar-left { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; }
.toolbar-mid  { display: flex; align-items: center; }
.toolbar-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

#breadcrumb {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.bread-part {
  cursor: pointer;
  padding: 2px 5px;
  border-radius: var(--radius-sm);
  transition: background var(--t-fast), color var(--t-fast);
}
.bread-part:hover { background: var(--bg-hover); color: var(--text-primary); }
.bread-sep { color: var(--text-muted); }

.search-box {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 5px 10px;
}
.search-box i { color: var(--text-muted); font-size: 13px; }
.search-box input {
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 12px;
  outline: none;
  width: 180px;
}
.search-box input::placeholder { color: var(--text-muted); }

#archive-info-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 6px 16px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  flex-wrap: wrap;
}

#info-filename { color: var(--text-secondary); font-weight: 500; }

/* ── FILE TABLE ──────────────────────────────────────────────── */
#file-table-wrap {
  overflow: auto;
  flex: 1;
}

#file-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

#file-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg-surface);
}

#file-table th {
  padding: 8px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
}

#file-table th.sortable { cursor: pointer; }
#file-table th.sortable:hover { color: var(--text-primary); }
#file-table th.sort-asc  .ti-chevrons-up-down::before { content: "\ea78"; }
#file-table th.sort-desc .ti-chevrons-up-down::before { content: "\ea77"; }

#file-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--t-fast);
  cursor: pointer;
}

#file-table tbody tr:hover    { background: var(--bg-hover); }
#file-table tbody tr.selected { background: var(--accent-faint); }
#file-table tbody tr.selected td { color: var(--text-primary); }

#file-table td {
  padding: 7px 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.col-check  { width: 36px; }
.col-name   { min-width: 260px; }
.col-size   { width: 100px; text-align: right; }
.col-comp   { width: 110px; text-align: right; }
.col-ratio  { width: 70px;  text-align: right; }
.col-date   { width: 150px; }
.col-actions { width: 100px; text-align: center; }

.file-name-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  color: var(--text-primary);
}

.file-icon { font-size: 15px; color: var(--accent); }
.folder-icon { color: var(--warning); }

.ratio-bar {
  display: inline-block;
  height: 3px;
  background: var(--accent);
  border-radius: 2px;
  vertical-align: middle;
  margin-right: 5px;
  opacity: 0.6;
}

/* ── SELECTION BAR ───────────────────────────────────────────── */
#selection-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--accent-faint);
  border-top: 1px solid var(--accent);
  font-size: 12px;
  color: var(--accent);
}

/* ── CREATE LAYOUT ───────────────────────────────────────────── */
#create-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 16px;
  flex: 1;
}

#create-files-panel,
#create-options-panel {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.panel-header i { color: var(--accent); }
.panel-header .btn { margin-left: auto; }

#create-file-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

.create-file-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  transition: background var(--t-fast);
}

.create-file-row:hover { background: var(--bg-hover); }
.create-file-row .file-icon { color: var(--accent); font-size: 14px; }
.create-file-name { flex: 1; color: var(--text-primary); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.create-file-size { font-family: var(--font-mono); color: var(--text-muted); font-size: 11px; flex-shrink: 0; }
.create-file-remove { color: var(--text-muted); background: none; border: none; font-size: 14px; padding: 2px 4px; border-radius: var(--radius-sm); transition: color var(--t-fast); flex-shrink: 0; }
.create-file-remove:hover { color: var(--danger); }

#create-stats {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

#create-stats .btn { margin-left: auto; }

/* ── OPTIONS PANEL ───────────────────────────────────────────── */
#create-options-panel { padding: 14px; gap: 14px; }
#create-options-panel .panel-header { margin: -14px -14px 0; }

.option-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.option-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge-opt {
  font-size: 10px;
  background: var(--bg-active);
  color: var(--text-muted);
  padding: 1px 6px;
  border-radius: 20px;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
}

.format-btns, .comp-levels {
  display: flex;
  gap: 6px;
}

.fmt-btn, .level-btn {
  flex: 1;
  padding: 8px 6px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-mid);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 12px;
  font-family: var(--font-ui);
  font-weight: 600;
  text-align: center;
  line-height: 1.3;
  transition: all var(--t-fast);
}

.fmt-btn:hover, .level-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.fmt-btn.active, .level-btn.active {
  background: var(--accent-faint);
  border-color: var(--accent);
  color: var(--accent);
}

.level-btn small { font-size: 10px; color: var(--text-muted); font-weight: 400; display: block; }
.level-btn.active small { color: var(--accent); opacity: 0.8; }

.input-row {
  display: flex;
  align-items: center;
  gap: 0;
}

.text-input {
  width: 100%;
  padding: 7px 10px;
  background: var(--bg-base);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 13px;
  outline: none;
  transition: border-color var(--t-fast);
}

.text-input:focus { border-color: var(--accent); }

.input-row .text-input { border-radius: var(--radius-md) 0 0 var(--radius-md); }

.input-ext {
  padding: 7px 10px;
  background: var(--bg-active);
  border: 1px solid var(--border-mid);
  border-left: none;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

textarea.text-input { resize: vertical; min-height: 60px; }

.btn-create {
  width: 100%;
  justify-content: center;
  padding: 10px;
  font-size: 14px;
  margin-top: auto;
}

/* ── PROGRESS ────────────────────────────────────────────────── */
.prog-label {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.prog-track {
  height: 4px;
  background: var(--bg-active);
  border-radius: 2px;
  overflow: hidden;
}

.prog-track > div {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  width: 0%;
  transition: width 80ms linear;
}

/* ── MODAL ───────────────────────────────────────────────────── */
#modal-backdrop, #preview-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}

#modal-backdrop.hidden, #preview-backdrop.hidden { display: none; }

#extract-modal, #preview-modal {
  background: var(--bg-raised);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 480px;
  max-width: 95vw;
  overflow: hidden;
}

#preview-modal {
  width: 700px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 14px;
}

.modal-header i { color: var(--accent); margin-right: 6px; }

.modal-body {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
}

#preview-content {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 500px;
  overflow-y: auto;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  line-height: 1.7;
}

#preview-img {
  max-width: 100%;
  max-height: 500px;
  border-radius: var(--radius-md);
  object-fit: contain;
}

/* ── TOAST ───────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 9999;
  pointer-events: none;
}

.toast {
  background: var(--bg-raised);
  border: 1px solid var(--border-mid);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 8px 16px;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-primary);
  box-shadow: var(--shadow-md);
  animation: toast-in 200ms ease forwards;
  white-space: nowrap;
}

.toast.removing { animation: toast-out 200ms ease forwards; }

@keyframes toast-in  { from { opacity:0; transform:translateY(8px);  } to { opacity:1; transform:translateY(0); } }
@keyframes toast-out { from { opacity:1; transform:translateY(0);     } to { opacity:0; transform:translateY(-8px); } }

/* ── EXTRACT DIRECTION GRID ──────────────────────────────────── */
.direction-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.dir-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 12px 10px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-mid);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-family: var(--font-ui);
  text-align: center;
  cursor: pointer;
  transition: all var(--t-fast);
}

.dir-btn i {
  font-size: 22px;
  color: var(--text-muted);
  transition: color var(--t-fast);
}

.dir-btn:hover {
  border-color: var(--accent);
  background: var(--accent-faint);
  color: var(--text-primary);
}

.dir-btn:hover i { color: var(--accent); }

.dir-btn.active {
  border-color: var(--accent);
  background: var(--accent-faint);
  color: var(--accent);
}

.dir-btn.active i { color: var(--accent); }

.dir-label {
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
}

.dir-desc {
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1.4;
}

.dir-btn.active .dir-desc { color: var(--accent); opacity: 0.75; }

.upload-pick-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.upload-pick-row .text-input { flex: 1; }
