/* ============================================
   SAHIOYE UNIVERSAL TOOL SHELL — 3-Panel Layout
   Shared across ALL tools. Works with existing
   category CSS (pdf-tools.css, img-tools.css etc.)
   ============================================ */

/* ── Override: Prevent category CSS file input overlay conflicts ── */
.shell-upload .tool-workspace input[type="file"]#shellFileInput {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  border: 0 !important;
  pointer-events: none !important;
  opacity: 0 !important;
}

/* ── Shell Sections (Upload → Workspace → Result) ── */
.shell-upload,
.shell-workspace,
.shell-result { display: none; }
.shell-upload.active { display: block; }
.shell-workspace.active { display: block; }
.shell-result.active { display: block; }

/* ── 3-Panel Workspace Layout ── */
.shell-panels {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  min-height: 500px;
}

/* Left Panel — Thumbnails / Navigation */
.shell-left {
  width: 200px;
  flex-shrink: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 16px);
  padding: 16px 12px;
  box-shadow: var(--shadow-card);
  position: sticky;
  top: 100px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.shell-left__title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

/* Thumbnail Items */
.shell-thumb {
  border: 2px solid transparent;
  border-radius: var(--radius-sm, 8px);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  background: #fff;
}
.shell-thumb.active { border-color: var(--primary, #ef4444); }
.shell-thumb:hover { border-color: var(--border-hover); transform: scale(1.03); }
.shell-thumb img,
.shell-thumb canvas {
  width: 100%;
  display: block;
  border-radius: 4px;
}
.shell-thumb__label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-align: center;
  padding: 4px 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: var(--bg-card);
}
.shell-thumb__badge {
  position: absolute;
  top: 4px;
  left: 4px;
  background: rgba(0,0,0,0.7);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
}
.shell-thumb__delete {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  background: var(--primary, #ef4444);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 0.65rem;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.shell-thumb:hover .shell-thumb__delete { display: flex; }

/* Add More Button in Left Panel */
.shell-add-more {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm, 8px);
  padding: 16px 8px;
  text-align: center;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1.5rem;
  transition: all 0.2s ease;
}
.shell-add-more:hover {
  border-color: var(--border-hover);
  color: var(--primary-light, #f87171);
  background: var(--gradient-subtle);
}
.shell-add-more span {
  display: block;
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

/* Center Panel — Main Preview */
.shell-center {
  flex: 1;
  min-width: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 16px);
  padding: 24px;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
}
.shell-center::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 3px;
  background: var(--gradient-primary, linear-gradient(135deg, #ef4444, #f97316));
}
.shell-center__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.shell-center__filename {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-primary);
  word-break: break-all;
}
.shell-center__info {
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.shell-center__reset {
  width: 32px;
  height: 32px;
  background: rgba(239,68,68,0.1);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--primary, #ef4444);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  transition: all 0.2s ease;
}
.shell-center__reset:hover {
  background: var(--primary, #ef4444);
  color: #fff;
  transform: scale(1.1);
}
.shell-center__preview {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 350px;
}
.shell-center__preview canvas,
.shell-center__preview img {
  max-width: 100%;
  max-height: 500px;
  border-radius: 8px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.15);
}

/* Right Panel — Dynamic Settings */
.shell-right {
  width: 320px;
  flex-shrink: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 16px);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: sticky;
  top: 100px;
  max-height: calc(100vh - 120px);
}
.shell-right__header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
}
.shell-right__title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.shell-right__body {
  padding: 20px;
  flex: 1;
  overflow-y: auto;
}
.shell-right__footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-surface, rgba(15,15,35,1));
}

/* Bottom Action Bar (inside right panel footer) */
.shell-action-btn {
  width: 100%;
  padding: 16px;
  background: var(--gradient-primary, linear-gradient(135deg, #ef4444, #f97316));
  border: none;
  border-radius: var(--radius-md, 12px);
  color: white;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 54px;
}
.shell-action-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(239,68,68,0.35);
}
.shell-action-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.shell-progress {
  width: 100%;
  height: 6px;
  background: rgba(255,255,255,0.06);
  border-radius: 3px;
  margin-top: 10px;
  overflow: hidden;
  display: none;
}
.shell-progress.active { display: block; }
.shell-progress__fill {
  height: 100%;
  background: var(--gradient-primary, linear-gradient(135deg, #ef4444, #f97316));
  border-radius: 3px;
  width: 0%;
  transition: width 0.3s ease;
}

/* ── Result Section ── */
.shell-result-card {
  max-width: 720px;
  margin: 0 auto;
  padding: 40px;
  background: var(--bg-card);
  border: 1px solid rgba(6,214,160,0.2);
  border-radius: var(--radius-xl, 24px);
  box-shadow: var(--shadow-card);
  text-align: center;
  position: relative;
  overflow: hidden;
  animation: resultPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.shell-result-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 3px;
  background: linear-gradient(90deg, #06d6a0, #22d3ee);
}
.shell-result__icon {
  font-size: 3.5rem;
  margin-bottom: 12px;
  display: block;
}
.shell-result__title {
  font-size: 1.3rem;
  font-weight: 800;
  color: #06d6a0;
  margin-bottom: 20px;
}
.shell-result__stats { margin-bottom: 24px; }
.shell-result__actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}
.shell-download-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 16px 36px;
  background: linear-gradient(135deg, #06d6a0, #22d3ee);
  border: none;
  border-radius: var(--radius-md, 12px);
  color: #0a0a1a;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
}
.shell-download-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(6,214,160,0.3);
}
.shell-share-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 1rem;
}
.shell-share-btn:hover {
  background: var(--primary, #ef4444);
  color: #fff;
  border-color: var(--primary);
  transform: translateY(-2px);
}

/* Workflow Continue */
.shell-workflows {
  padding-top: 20px;
  border-top: 1px solid rgba(6,214,160,0.15);
}
.shell-workflows__label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
}
.shell-workflows__btns {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}
.shell-workflow-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius-sm, 8px);
  cursor: pointer;
  transition: all 0.2s ease;
}
.shell-workflow-btn:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-card);
}

/* ── Size Comparison Widget ── */
.shell-size-compare {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 20px;
  background: var(--gradient-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 12px);
  margin-bottom: 20px;
}
.shell-size-item { text-align: center; }
.shell-size-item__label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.shell-size-item__value {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-primary);
}
.shell-size-arrow {
  font-size: 1.1rem;
  font-weight: 700;
}
.shell-size-arrow.reduced { color: #06d6a0; }
.shell-size-arrow.increased { color: #ef4444; }

/* ── Custom Filename Input (inside right panel) ── */
.shell-filename-row {
  display: flex;
  align-items: center;
  gap: 0;
  margin-top: 12px;
}
.shell-filename-input {
  flex: 1;
  padding: 10px 14px;
  background: var(--bg-surface, #0f0f23);
  border: 1px solid var(--border);
  border-right: none;
  border-radius: 8px 0 0 8px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s;
}
.shell-filename-input:focus { border-color: var(--primary, #ef4444); }
.shell-filename-ext {
  padding: 10px 14px;
  background: var(--gradient-subtle);
  border: 1px solid var(--border);
  border-radius: 0 8px 8px 0;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
}

/* ── Settings Panel Components ── */
.shell-setting-group {
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.shell-setting-group:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.shell-setting-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.shell-option-card {
  padding: 14px;
  border: 2px solid transparent;
  border-radius: var(--radius-sm, 8px);
  background: var(--bg-surface, #0f0f23);
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.shell-option-card:hover { background: var(--bg-card-hover); border-color: var(--border-hover); }
.shell-option-card.active { border-color: var(--primary, #ef4444); background: rgba(239,68,68,0.05); }
.shell-option-card__title { font-size: 0.9rem; font-weight: 700; color: var(--text-primary); margin-bottom: 2px; }
.shell-option-card__desc { font-size: 0.75rem; color: var(--text-secondary); line-height: 1.4; }

/* ── Browse Button in Upload Zone ── */
.shell-browse-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 32px;
  margin-top: 16px;
  background: var(--gradient-primary, linear-gradient(135deg, #ef4444, #f97316));
  border: none;
  border-radius: var(--radius-md, 12px);
  color: #fff;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  z-index: 10;
}
.shell-browse-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(239,68,68,0.35);
}

/* ── Responsive ── */
@media (max-width: 1024px) {
  .shell-panels { flex-direction: column; padding: 0 16px; }
  .shell-left {
    width: 100%;
    position: static;
    max-height: none;
    flex-direction: row;
    overflow-x: auto;
    gap: 8px;
    padding: 12px;
  }
  .shell-left__title { display: none; }
  .shell-thumb { width: 80px; flex-shrink: 0; }
  .shell-add-more { width: 80px; flex-shrink: 0; padding: 12px 8px; }
  .shell-center { width: 100%; }
  .shell-right {
    width: 100%;
    position: static;
    max-height: none;
  }
}
@media (max-width: 600px) {
  .shell-panels { padding: 0 12px; }
  .shell-left { gap: 6px; padding: 8px; }
  .shell-thumb { width: 60px; }
  .shell-center { padding: 16px; }
  .shell-center__preview { min-height: 200px; }
  .shell-right__body { padding: 16px; }
  .shell-result-card { padding: 24px 16px; }
  .shell-result__actions { flex-direction: column; }
}
