/* ==========================================================================
   ApexConvert - High-End Modern Conversion Workstation
   Original, Distinct Design with Categorized Format Selector Popover
   ========================================================================== */

:root {
  --brand-primary: #3b82f6;
  --brand-primary-hover: #2563eb;
  --brand-primary-glow: rgba(59, 130, 246, 0.22);
  
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-dropzone: #f1f5f9;
  
  --border-light: #e2e8f0;
  --border-card: #cbd5e1;
  --border-focus: #3b82f6;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  
  --success: #10b981;
  --success-hover: #059669;
  --danger: #ef4444;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px -2px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 24px -4px rgba(0, 0, 0, 0.12);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   Navigation Bar
   ========================================================================== */
.app-topbar {
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-light);
  height: 60px;
}

.topbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-main);
}

.brand-badge {
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.brand-title {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.brand-title strong {
  color: var(--brand-primary);
}

.brand-tagline {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* ==========================================================================
   Hero Region
   ========================================================================== */
.hero-region {
  text-align: center;
  padding: 32px 16px 20px;
}

.hero-heading {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: -0.8px;
  margin-bottom: 8px;
  color: var(--text-main);
}

.hero-desc {
  font-size: 1.05rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.quick-presets-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.preset-btn {
  background: #ffffff;
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: 9999px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.preset-btn:hover {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
  background: #eff6ff;
}

.preset-btn.active {
  background: #eff6ff;
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

/* ==========================================================================
   3-Column Workbench Stage Grid
   ========================================================================== */
.workbench-layout {
  display: grid;
  grid-template-columns: 300px minmax(500px, 740px) 300px;
  justify-content: center;
  gap: 24px;
  max-width: 1420px;
  margin: 0 auto;
  padding: 0 16px 48px;
  align-items: start;
  flex: 1;
}

.workbench-ad-rail {
  width: 300px;
}

.workbench-core {
  width: 100%;
}

/* Clean Ad Space Containers */
.ad-frame {
  background-color: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
}

.ad-300x250 {
  width: 300px;
  height: 250px;
}

.ad-300x600 {
  width: 300px;
  height: 600px;
}

.ad-728x90 {
  width: 100%;
  height: 90px;
}

#ad-slot-top {
  margin-bottom: 16px;
}

#ad-slot-mid {
  margin-top: 18px;
  margin-bottom: 24px;
}

.ad-placeholder-box {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #f8fafc;
}

.ad-placeholder-text {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-light);
  letter-spacing: 0.6px;
  text-transform: uppercase;
}

/* ==========================================================================
   Main Workstation Card
   ========================================================================== */
.converter-workstation {
  background-color: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 36px 28px;
  position: relative;
  transition: all 0.2s ease;
}

.workstation-empty {
  border: 2px dashed var(--border-card);
  border-radius: var(--radius-md);
  background-color: var(--bg-dropzone);
  padding: 44px 20px;
  text-align: center;
  position: relative;
  transition: background-color 0.15s, border-color 0.15s;
}

.workstation-empty.dragover {
  background-color: rgba(59, 130, 246, 0.06);
  border-color: var(--brand-primary);
}

.workstation-file-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}

/* Pre-upload Target Format Banner */
.pre-upload-format-banner {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: 9999px;
  padding: 5px 14px;
  margin-bottom: 20px;
  position: relative;
  z-index: 5;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.pre-upload-format-text {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-muted);
}

.btn-fmt-pill-highlight {
  background: #eff6ff;
  border: 1.5px solid var(--brand-primary);
  color: var(--brand-primary);
  font-size: 0.9rem;
  padding: 5px 14px;
  box-shadow: 0 1px 2px rgba(59, 130, 246, 0.15);
}

.btn-fmt-pill-highlight:hover {
  background: #dbeafe;
}

/* Split Button */
.action-btn-group {
  position: relative;
  display: inline-block;
  z-index: 5;
  margin-bottom: 14px;
}

.split-control {
  display: inline-flex;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 14px var(--brand-primary-glow);
}

.btn-main-upload {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #ffffff;
  border: none;
  padding: 14px 26px;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  border-radius: var(--radius-md) 0 0 var(--radius-md);
  transition: background 0.15s;
}

.btn-main-upload:hover {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
}

.btn-arrow-toggle {
  background-color: #2563eb;
  color: #ffffff;
  border: none;
  border-left: 1px solid rgba(255, 255, 255, 0.25);
  padding: 14px 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  transition: background 0.15s;
}

.btn-arrow-toggle:hover {
  background-color: #1d4ed8;
}

/* Source Dropdown Popover */
.source-popover {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 8px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  width: 220px;
  padding: 6px 0;
  z-index: 20;
  text-align: left;
}

.popover-item {
  width: 100%;
  display: block;
  padding: 10px 18px;
  background: transparent;
  border: none;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  text-align: left;
  transition: background 0.12s;
}

.popover-item:hover {
  background-color: #eff6ff;
  color: var(--brand-primary);
}

.limit-caption {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-weight: 500;
}

.terms-caption {
  font-size: 0.74rem;
  color: var(--text-light);
  max-width: 520px;
  margin: 0 auto;
}

.terms-caption a {
  color: var(--text-muted);
  text-decoration: underline;
}

/* ==========================================================================
   URL Input View
   ========================================================================== */
.workstation-url-view {
  background-color: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 22px;
  text-align: left;
  position: relative;
  z-index: 6;
  max-width: 560px;
  margin: 0 auto;
}

.url-view-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.btn-dismiss {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--text-light);
}

.btn-dismiss:hover {
  color: var(--danger);
}

.url-input-cluster {
  display: flex;
  gap: 10px;
}

.url-field {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  font-size: 0.94rem;
  outline: none;
  font-family: inherit;
}

.url-field:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* ==========================================================================
   Queue State & File Rows (Sleek Modern SaaS Layout)
   ========================================================================== */
.workstation-queue {
  text-align: left;
  position: relative;
  z-index: 6;
}

.queue-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 16px;
}

.queue-heading {
  font-weight: 800;
  font-size: 1.05rem;
}

.queue-batch-control {
  display: flex;
  align-items: center;
  gap: 10px;
}

.batch-label {
  font-size: 0.88rem;
  color: var(--text-muted);
  font-weight: 500;
}

.btn-fmt-pill {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
  padding: 6px 14px;
  border-radius: 9999px;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.86rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}

.btn-fmt-pill:hover {
  background: #dbeafe;
  border-color: #93c5fd;
}

.btn-add-file {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-main);
  transition: background 0.15s;
}

.btn-add-file:hover {
  background: #f1f5f9;
}

/* File Items List */
.file-items-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
  max-height: 360px;
  overflow-y: auto;
}

.file-card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  gap: 16px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.file-card-row:hover {
  border-color: var(--border-card);
  box-shadow: var(--shadow-sm);
}

.row-file-badge {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.badge-epub { background: #ede9fe; color: #6d28d9; }
.badge-pdf { background: #ffe4e6; color: #e11d48; }
.badge-doc { background: #eff6ff; color: #1d4ed8; }
.badge-img { background: #ecfeff; color: #0891b2; }
.badge-web { background: #f0fdf4; color: #15803d; }
.badge-txt { background: #f1f5f9; color: #475569; }

.row-file-info {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  overflow: hidden;
}

.row-file-texts {
  overflow: hidden;
}

.row-file-name {
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
  color: var(--text-main);
}

.row-file-size {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.row-file-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-item-format {
  background: #f8fafc;
  border: 1px solid var(--border-card);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-weight: 700;
  font-size: 0.86rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-main);
  transition: all 0.15s;
}

.btn-item-format:hover {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

.btn-item-delete {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--text-light);
  cursor: pointer;
  padding: 4px 6px;
  line-height: 1;
}

.btn-item-delete:hover {
  color: var(--danger);
}

/* Progress Panel */
.progress-panel {
  background-color: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin-bottom: 16px;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.progress-track-bar {
  height: 8px;
  background-color: var(--border-light);
  border-radius: 9999px;
  overflow: hidden;
}

.progress-fill-gradient {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #3b82f6, #10b981);
  transition: width 0.25s ease;
}

/* Queue Action Footer */
.queue-action-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 14px;
  border-top: 1px solid var(--border-light);
}

.btn-text-danger {
  background: none;
  border: none;
  color: var(--danger);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
}

.btn-primary-blue {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fff;
  border: none;
  padding: 12px 28px;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 12px var(--brand-primary-glow);
  transition: all 0.15s;
}

.btn-primary-blue:hover {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  transform: translateY(-1px);
}

.btn-success-green {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  border: none;
  padding: 12px 28px;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
  transition: all 0.15s;
}

.btn-success-green:hover {
  background: linear-gradient(135deg, #059669, #047857);
}

.btn-download-done {
  background: var(--success);
  color: #fff;
  border: none;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* ==========================================================================
   Categorized Format Selector Modal
   ========================================================================== */
.format-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.format-modal-card {
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  padding: 24px;
  animation: modalIn 0.15s ease-out;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.format-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.format-modal-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-main);
}

.format-search-wrap {
  margin-bottom: 14px;
}

.format-search-box {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.92rem;
  outline: none;
}

.format-search-box:focus {
  border-color: var(--brand-primary);
}

.format-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 10px;
}

.tab-pill {
  background: none;
  border: none;
  padding: 6px 12px;
  border-radius: 9999px;
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.tab-pill.active {
  background: #eff6ff;
  color: var(--brand-primary);
}

.formats-list-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  max-height: 280px;
  overflow-y: auto;
  padding-right: 4px;
}

.format-tile {
  background: #f8fafc;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  transition: all 0.12s;
  text-align: center;
}

.format-tile:hover {
  background: #eff6ff;
  border-color: var(--brand-primary);
  transform: translateY(-1px);
}

.format-tile-name {
  font-weight: 800;
  font-size: 0.94rem;
  color: var(--text-main);
}

.format-tile-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ==========================================================================
   Capabilities Bar & SEO Index
   ========================================================================== */
.capabilities-grid {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 24px 20px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  text-align: center;
  margin-bottom: 24px;
}

.capability-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.cap-icon {
  font-size: 1.8rem;
  margin-bottom: 8px;
}

.capability-item h3 {
  font-size: 1rem;
  font-weight: 800;
  margin-bottom: 6px;
}

.capability-item p {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.seo-index-box {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 22px 20px;
  text-align: center;
}

.seo-index-title {
  font-size: 1.05rem;
  font-weight: 800;
  margin-bottom: 14px;
  color: var(--text-main);
}

.seo-tags-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.seo-tag-link {
  background: #f8fafc;
  border: 1px solid var(--border-light);
  padding: 6px 14px;
  border-radius: 9999px;
  text-decoration: none;
  color: var(--text-main);
  font-weight: 600;
  font-size: 0.82rem;
  transition: all 0.12s;
}

.seo-tag-link:hover {
  background: #eff6ff;
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

/* Footer */
.app-footer {
  border-top: 1px solid var(--border-light);
  padding: 20px 0;
  margin-top: auto;
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--bg-card);
}

.footer-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.footer-legal-links {
  display: flex;
  align-items: center;
  gap: 8px;
}

.footer-legal-links a {
  color: var(--text-muted);
  text-decoration: none;
}

.footer-legal-links a:hover {
  color: var(--brand-primary);
}

/* Responsive */
@media (max-width: 1260px) {
  .workbench-layout {
    grid-template-columns: minmax(400px, 740px) 300px;
  }
  .rail-left {
    display: none;
  }
}

@media (max-width: 920px) {
  .workbench-layout {
    grid-template-columns: 1fr;
  }
  .rail-right {
    display: none;
  }
  .capabilities-grid {
    grid-template-columns: 1fr;
  }
  .formats-list-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
