/* ==========================================================================
   CSV TO JSON CONVERTER — Stylesheet
   Matrix Runway — Dev Tools Category
   ========================================================================== */

/* ── Container Layout (15% Margins / 70% Content Width on Large Screens) ── */
.csv-json-wrapper {
  width: 100%;
  min-height: calc(100vh - 140px);
  padding-top: 0;
  padding-bottom: 60px;
  background: var(--bg-primary);
}



.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--purple-600);
  text-decoration: none;
  margin-bottom: 12px;
  transition: transform var(--transition-fast);
}

.back-link:hover {
  transform: translateX(-3px);
  color: var(--purple-700);
}

.tool-main-title {
  font-family: var(--font-heading);
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--text-primary);
  margin: 0 0 8px 0;
  letter-spacing: -0.02em;
}

.tool-main-subtitle {
  font-size: 0.98rem;
  color: var(--text-secondary);
  max-width: 760px;
  margin: 0;
  line-height: 1.5;
}

/* ── Reverse / Converter Direction Switcher Pill ── */
.converter-switch-wrap {
  margin-top: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.converter-switch-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-full);
  padding: 4px 14px 4px 5px;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
  cursor: pointer;
  user-select: none;
}

.converter-switch-pill:hover {
  border-color: var(--purple-500);
  background: var(--bg-tertiary);
  box-shadow: 0 4px 14px rgba(124, 58, 237, 0.12);
  transform: translateY(-1px);
}

.converter-switch-pill:active {
  transform: translateY(0);
}

.converter-switch-pill .switch-tag {
  font-family: var(--font-heading);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1;
}

.converter-switch-pill .switch-tag.active {
  background: var(--purple-600);
  color: #ffffff;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  box-shadow: 0 2px 6px rgba(124, 58, 237, 0.25);
}

.converter-switch-pill .switch-icon-box {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(124, 58, 237, 0.1);
  color: var(--purple-600);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform var(--transition-normal), background var(--transition-fast), color var(--transition-fast);
}

[data-theme="dark"] .converter-switch-pill .switch-icon-box {
  background: rgba(167, 139, 250, 0.16);
  color: var(--purple-400);
}

.converter-switch-pill:hover .switch-icon-box {
  background: var(--purple-600);
  color: #ffffff;
  transform: rotate(180deg);
}

.converter-switch-pill .switch-tag.target {
  color: var(--text-secondary);
  padding: 4px 2px;
  transition: color var(--transition-fast);
}

.converter-switch-pill:hover .switch-tag.target {
  color: var(--purple-600);
}

[data-theme="dark"] .converter-switch-pill:hover .switch-tag.target {
  color: var(--purple-400);
}

.converter-switch-pill .switch-divider {
  width: 1px;
  height: 14px;
  background: var(--border);
  margin: 0 2px;
}

.converter-switch-pill .switch-hint {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  transition: color var(--transition-fast);
}

.converter-switch-pill:hover .switch-hint {
  color: var(--text-secondary);
}

@media (max-width: 540px) {
  .converter-switch-pill {
    padding: 3px 10px 3px 4px;
    gap: 6px;
  }
  .converter-switch-pill .switch-hint {
    display: none;
  }
  .converter-switch-pill .switch-divider {
    display: none;
  }
  .converter-switch-pill .switch-tag.active {
    padding: 5px 10px;
    font-size: 0.78rem;
  }
  .converter-switch-pill .switch-tag.target {
    font-size: 0.78rem;
  }
  .converter-switch-pill .switch-icon-box {
    width: 22px;
    height: 22px;
  }
}

/* ── Options & Controls Toolbar Card ── */
.options-bar-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.options-bar-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.option-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.option-label {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}

.delimiter-input-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.custom-select-control {
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--bg-secondary);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.custom-select-control option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.custom-select-control:focus {
  border-color: var(--purple-500);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}

.custom-delimiter-field {
  width: 140px;
  padding: 8px 10px;
  font-family: 'Fira Code', monospace;
  font-size: 0.88rem;
  color: var(--text-primary);
  background: var(--bg-secondary);
  border-radius: 8px;
  border: 1.5px solid var(--purple-400);
  outline: none;
}

.toggles-group {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.custom-checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  user-select: none;
}

.custom-checkbox-label input[type="checkbox"] {
  display: none;
}

.checkbox-box {
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--purple-400);
  border-radius: 4px;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.custom-checkbox-label input[type="checkbox"]:checked + .checkbox-box {
  background: var(--purple-600);
  border-color: var(--purple-600);
}

.custom-checkbox-label input[type="checkbox"]:checked + .checkbox-box::after {
  content: '✓';
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 800;
}

/* ── Dual Panel Converter Grid (Left & Right) ── */
.converter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.panel-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

/* Drag & drop magnet highlight on left panel */
.panel-card.left-panel {
  position: relative;
  transition: border-color var(--transition-fast), background-color var(--transition-fast), box-shadow var(--transition-fast);
}

.panel-card.left-panel.drag-over {
  border-color: var(--purple-600) !important;
  background-color: rgba(139, 92, 246, 0.05) !important;
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2), var(--shadow-md) !important;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.panel-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.panel-title {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: 6px;
}

.badge-csv {
  background: rgba(16, 185, 129, 0.12);
  color: #059669;
}

.badge-json {
  background: rgba(139, 92, 246, 0.12);
  color: var(--purple-600);
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  flex-shrink: 0;
}

/* Action Buttons */
.btn-action-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-primary);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  box-sizing: border-box;
  transition: all var(--transition-fast);
}

.btn-action-sm:hover {
  background: var(--bg-tertiary);
  border-color: var(--purple-400);
}

.btn-action-purple {
  background: var(--purple-500);
  color: #ffffff;
  border-color: var(--purple-500);
}

.btn-action-purple:hover {
  background: var(--purple-600);
  border-color: var(--purple-600);
}

.btn-action-success {
  background: #10b981;
  color: #ffffff;
  border-color: #10b981;
}

.btn-action-success:hover {
  background: #059669;
  border-color: #059669;
}

.btn-action-zip {
  background: #f59e0b;
  color: #ffffff;
  border-color: #f59e0b;
}

.btn-action-zip:hover {
  background: #d97706;
  border-color: #d97706;
}

.btn-action-danger {
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.2);
}

.btn-action-danger:hover {
  background: rgba(239, 68, 68, 0.08);
  border-color: #ef4444;
}

/* Dropzone Box */
.dropzone-box {
  border: 2px dashed var(--purple-400);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 12px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.dropzone-box:hover {
  border-color: var(--purple-600);
  background: var(--bg-primary);
}

.dropzone-box.drag-over {
  border-color: var(--purple-600);
  background: var(--bg-tertiary);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

.dropzone-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.dropzone-icon {
  width: 18px;
  height: 18px;
  color: var(--purple-600);
}

.link-btn {
  background: none;
  border: none;
  color: var(--purple-600);
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
}

/* ── File Badge Container & Header ── */
.file-badge-container {
  margin-bottom: 12px;
  background: var(--bg-tertiary);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}

.file-badge-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.btn-add-more-files {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 700;
  color: #ffffff;
  background: var(--purple-600);
  border: 1px solid var(--purple-600);
  border-radius: 8px;
  padding: 6px 14px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(124, 58, 237, 0.25);
  transition: background var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
  user-select: none;
}

.btn-add-more-files:hover {
  background: var(--purple-500);
  border-color: var(--purple-500);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(124, 58, 237, 0.35);
}

.btn-add-more-files:active {
  transform: translateY(0);
}

.file-badge-stats {
  display: flex;
  align-items: center;
  gap: 10px;
}

.file-count-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Multi-file badge list (2-Column Grid) */
.file-badge-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: flex-start;
  gap: 6px;
  max-height: 120px;
  overflow-y: auto;
  padding: 2px;
  -webkit-overflow-scrolling: touch;
}

/* Custom Scrollbar for file badge list */
.file-badge-list::-webkit-scrollbar {
  width: 5px;
}

.file-badge-list::-webkit-scrollbar-track {
  background: var(--bg-primary);
  border-radius: 4px;
}

.file-badge-list::-webkit-scrollbar-thumb {
  background: var(--purple-400);
  border-radius: 4px;
}

.file-badge-list::-webkit-scrollbar-thumb:hover {
  background: var(--purple-600);
}

.file-badge-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 0.76rem;
  font-weight: 600;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
  user-select: none;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
  transition: all var(--transition-fast);
}

.file-badge-item:hover {
  background: var(--bg-tertiary);
  border-color: var(--purple-400);
}

.file-badge-item.active {
  background: var(--purple-600);
  border-color: var(--purple-600);
  color: #ffffff;
  font-weight: 700;
  box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.25);
}

.file-badge-name {
  flex: 1;
  min-width: 0;
  max-width: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: inline-block;
  vertical-align: middle;
}

.file-badge-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1;
  padding: 0 2px;
  margin-left: 2px;
  transition: color var(--transition-fast);
}

.file-badge-remove:hover {
  color: #ef4444;
}

/* Textarea Wrapper & Monospace Box */
.textarea-wrapper {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.code-textarea {
  width: 100%;
  min-height: 380px;
  font-family: 'Fira Code', 'Courier New', monospace;
  font-size: 0.86rem;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-secondary);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  outline: none;
  resize: vertical;
  box-sizing: border-box;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.code-textarea:focus {
  border-color: var(--purple-500);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.12);
}

.readonly-textarea {
  background: var(--bg-tertiary);
}

/* Error Banner */
.error-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  font-size: 0.84rem;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 8px;
  margin-top: 10px;
}

/* Multi-file Dropdown in Right Panel */
.multi-file-selector-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: 8px;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

.selector-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  flex-shrink: 0;
}

.select-sm {
  padding: 5px 28px 5px 10px;
  font-size: 0.82rem;
  font-weight: 600;
  flex: 1;
  min-width: 0;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b5cf6' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 12px 12px;
  cursor: pointer;
}

/* Stats Bar */
.stats-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 12px;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border-radius: 8px;
  font-size: 0.8rem;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.stat-label {
  color: var(--text-muted);
  font-weight: 600;
}

.stat-value {
  color: var(--text-primary);
  font-weight: 700;
}

.stat-divider {
  width: 1px;
  height: 12px;
  background: var(--border-hover);
}

/* ── Table Preview Card ── */
.table-preview-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.table-preview-header {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.preview-title-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
}

.preview-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  background: rgba(139, 92, 246, 0.12);
  color: var(--purple-700);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  white-space: nowrap;
  flex-shrink: 0;
}

.preview-hint-text {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* Table Responsive Container */
.table-responsive-container {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  max-height: 420px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.preview-data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  text-align: left;
}

.preview-data-table th {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-weight: 700;
  font-family: var(--font-heading);
  padding: 10px 14px;
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 2;
  white-space: nowrap;
}

.preview-data-table td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  white-space: nowrap;
}

.preview-data-table tbody tr:hover {
  background: var(--bg-tertiary);
}

.empty-table-msg {
  text-align: center;
  color: var(--text-muted);
  padding: 30px 14px !important;
  font-style: italic;
}

/* Toast Notification Banner */




@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Helper hidden class */
.hidden-element {
  display: none !important;
}

/* ══════════════════════════════════════════════════════════════════════════ */
/* ══════════════════════════════════════════════════════════════════════════ */

/* ── Tablet Devices (<= 1024px) ── */
@media (max-width: 1024px) {
  .code-textarea {
    min-height: 320px;
  }
}

/* ── Medium Tablet / Stacked Grid (<= 900px) ── */
@media (max-width: 900px) {
  .converter-grid {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .code-textarea {
    min-height: 280px;
  }
}

/* ── Mobile Devices (<= 640px) ── */
@media (max-width: 640px) {
  .csv-json-wrapper {
    padding-bottom: 40px;
  }



  .tool-main-title {
    font-size: 1.65rem;
  }

  .tool-main-subtitle {
    font-size: 0.9rem;
  }

  .options-bar-card {
    padding: 14px;
  }

  .options-bar-grid {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
  }

  .option-group {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }

  .delimiter-input-wrapper {
    width: 100%;
    flex-direction: column;
  }

  .custom-select-control {
    width: 100%;
  }

  .custom-delimiter-field {
    width: 100%;
  }

  .toggles-group {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 14px;
  }

  .panel-card {
    padding: 14px;
  }

  .panel-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .panel-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .btn-action-sm {
    flex: 1;
    justify-content: center;
    padding: 8px 10px;
    font-size: 0.82rem;
  }

  .code-textarea {
    min-height: 240px;
    font-size: 0.82rem;
    padding: 10px;
  }

  .stats-bar {
    flex-wrap: wrap;
    gap: 8px;
    justify-content: space-between;
  }

  .stat-divider {
    display: none;
  }

  .table-preview-card {
    padding: 14px;
  }

  .table-preview-header {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }

  .preview-title {
    font-size: 0.95rem;
  }

  .badge-pill {
    font-size: 0.72rem;
    padding: 3px 10px;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .preview-data-table th,
  .preview-data-table td {
    padding: 8px 10px;
    font-size: 0.82rem;
  }

  

  
}

/* ── Extra Small Mobile Devices (<= 420px) ── */
@media (max-width: 420px) {
.tool-main-title {
    font-size: 1.45rem;
  }

  .btn-action-sm {
    min-width: 48%;
  }
}

/* ══════════════════════════════════════════════════════════════════════════ */
/* ══════════════════════════════════════════════════════════════════════════ */
[data-theme="dark"] select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

[data-theme="dark"] .badge-pill {
  background: rgba(139, 92, 246, 0.25);
  color: #c4b5fd;
}

[data-theme="dark"] .error-banner {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(239, 68, 68, 0.35);
  color: #fca5a5;
}
