/**
 * ToolDuck — Spreadsheet Tools Stylesheet
 * ===============================================================
 * Powers:
 *   - /excel-to-csv/ (Excel to CSV Converter)
 *   - /csv-to-excel/ (CSV to Excel Converter)
 */

.spt-app {
  display: flex;
  flex-direction: column;
  gap: var(--space-4, 1.25rem);
  width: 100%;
}

.spt-app [hidden] {
  display: none !important;
}

/* ---------------------------------------------------------------
   Drop Zone
   --------------------------------------------------------------- */
.spt-drop {
  background: radial-gradient(120% 90% at 50% 0%, var(--brand-soft, #f0fdf4) 0%, transparent 65%), var(--surface, #ffffff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: var(--radius-lg, 12px);
  padding: clamp(1.75rem, 4vw, 3rem) 1.25rem;
  text-align: center;
  transition: all 0.2s ease;
  cursor: pointer;
}

.spt-drop.is-dragover {
  border-color: var(--brand, #16a34a);
  background: var(--brand-soft, #f0fdf4);
  box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.12);
}

.spt-drop__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
  max-width: 32rem;
  margin: 0 auto;
}

.spt-drop__icon {
  width: 48px;
  height: 48px;
  color: var(--brand, #16a34a);
  margin-bottom: 0.25rem;
}

.spt-drop__title {
  font-size: clamp(1.1rem, 2.5vw, 1.35rem);
  font-weight: 700;
  color: var(--ink, #0f172a);
  margin: 0;
}

.spt-drop__sub {
  font-size: 0.92rem;
  color: var(--ink-3, #64748b);
  margin: 0;
}

.spt-drop__formats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: center;
  margin-top: 0.25rem;
}

.spt-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 4px;
  background: var(--bg-muted, #f1f5f9);
  color: var(--ink-2, #334155);
  border: 1px solid var(--border, #cbd5e1);
}

.spt-badge--primary {
  background: rgba(22, 163, 74, 0.1);
  color: #15803d;
  border-color: rgba(22, 163, 74, 0.25);
}

.spt-drop__limit {
  font-size: 0.8rem;
  color: var(--ink-4, #94a3b8);
  margin-top: 0.25rem;
}

/* ---------------------------------------------------------------
   File Info Bar
   --------------------------------------------------------------- */
.spt-file-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem;
  background: var(--surface, #ffffff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: var(--radius-md, 8px);
}

.spt-file-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.spt-file-icon {
  width: 24px;
  height: 24px;
  color: var(--brand, #16a34a);
  flex-shrink: 0;
}

.spt-file-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--ink, #0f172a);
}

.spt-file-meta {
  font-size: 0.82rem;
  color: var(--ink-3, #64748b);
}

/* ---------------------------------------------------------------
   Sheet Selector Pills
   --------------------------------------------------------------- */
.spt-sheets-card {
  background: var(--surface, #ffffff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: var(--radius-md, 8px);
  padding: 0.85rem 1.25rem;
}

.spt-sheets-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.65rem;
}

.spt-sheets-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink-2, #334155);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0;
}

.spt-sheets-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.spt-sheet-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.85rem;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 6px;
  border: 1.5px solid var(--border, #cbd5e1);
  background: var(--surface, #ffffff);
  color: var(--ink-2, #334155);
  cursor: pointer;
  transition: all 0.15s ease;
}

.spt-sheet-btn:hover {
  border-color: var(--brand, #16a34a);
  color: var(--brand, #16a34a);
}

.spt-sheet-btn.is-active {
  background: var(--brand, #16a34a);
  border-color: var(--brand, #16a34a);
  color: #ffffff;
}

.spt-sheet-badge {
  font-size: 0.75rem;
  padding: 0.1rem 0.35rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.08);
}

.spt-sheet-btn.is-active .spt-sheet-badge {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

/* ---------------------------------------------------------------
   Options & Configuration Bar
   --------------------------------------------------------------- */
.spt-options-card {
  background: var(--surface, #ffffff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: var(--radius-md, 8px);
  padding: 1rem 1.25rem;
}

.spt-options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.spt-option-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.spt-option-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-2, #334155);
}

.spt-select,
.spt-input {
  padding: 0.45rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid var(--border, #cbd5e1);
  border-radius: 6px;
  background: var(--surface, #ffffff);
  color: var(--ink, #0f172a);
  outline: none;
  transition: border-color 0.2s;
}

.spt-select:focus,
.spt-input:focus {
  border-color: var(--brand, #16a34a);
}

.spt-checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-subtle, #f1f5f9);
}

.spt-checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.825rem;
  font-weight: 500;
  color: var(--ink-2, #334155);
  cursor: pointer;
  user-select: none;
}

.spt-checkbox {
  cursor: pointer;
  accent-color: var(--brand, #16a34a);
}

/* ---------------------------------------------------------------
   Integrity & Security Notice Box
   --------------------------------------------------------------- */
.spt-notice {
  background: #f8fafc;
  border: 1px solid var(--border, #cbd5e1);
  border-left: 4px solid #0284c7;
  border-radius: 6px;
  padding: 0.75rem 1rem;
  font-size: 0.825rem;
  color: #334155;
  line-height: 1.5;
}

.spt-notice--security {
  border-left-color: #16a34a;
  background: #f0fdf4;
}

.spt-notice strong {
  color: #0f172a;
}

/* ---------------------------------------------------------------
   Status Bar & Error Banner
   --------------------------------------------------------------- */
.spt-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-left: 4px solid #ef4444;
  border-radius: 6px;
  padding: 0.85rem 1.15rem;
  color: #991b1b;
  font-size: 0.875rem;
  line-height: 1.45;
}

/* ---------------------------------------------------------------
   Preview Section
   --------------------------------------------------------------- */
.spt-preview-card {
  background: var(--surface, #ffffff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: var(--radius-lg, 12px);
  overflow: hidden;
}

.spt-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  background: #f8fafc;
  border-bottom: 1px solid var(--border, #e2e8f0);
}

.spt-preview-tabs {
  display: flex;
  background: var(--border, #e2e8f0);
  padding: 2px;
  border-radius: 6px;
  gap: 2px;
}

.spt-tab-btn {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--ink-3, #64748b);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.spt-tab-btn.is-active {
  background: #ffffff;
  color: var(--ink, #0f172a);
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

.spt-preview-meta {
  font-size: 0.8rem;
  color: var(--ink-3, #64748b);
}

.spt-table-wrap {
  max-height: 480px;
  overflow: auto;
  border-bottom: 1px solid var(--border, #e2e8f0);
}

.spt-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.825rem;
  white-space: nowrap;
}

.spt-table th {
  position: sticky;
  top: 0;
  background: #f1f5f9;
  color: #334155;
  font-weight: 700;
  padding: 0.55rem 0.85rem;
  border-right: 1px solid #e2e8f0;
  border-bottom: 2px solid #cbd5e1;
  text-align: left;
  z-index: 2;
}

.spt-table th.spt-row-num,
.spt-table td.spt-row-num {
  width: 45px;
  min-width: 45px;
  max-width: 45px;
  text-align: center;
  background: #f8fafc;
  color: #94a3b8;
  font-weight: 600;
  user-select: none;
  border-right: 1px solid #e2e8f0;
}

.spt-table td {
  padding: 0.45rem 0.85rem;
  border-right: 1px solid #f1f5f9;
  border-bottom: 1px solid #f1f5f9;
  color: #1e293b;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.spt-table tr:hover td {
  background: #f8fafc;
}

.spt-text-view {
  width: 100%;
  height: 360px;
  padding: 0.85rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.825rem;
  line-height: 1.5;
  background: var(--surface, #ffffff);
  color: var(--ink, #0f172a);
  border: none;
  resize: vertical;
  white-space: pre;
  overflow: auto;
  outline: none;
}

/* ---------------------------------------------------------------
   Action Toolbar
   --------------------------------------------------------------- */
.spt-actions-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: var(--surface, #ffffff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: var(--radius-md, 8px);
}

.spt-actions-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Dark theme overrides */
html[data-theme="dark"] .spt-drop {
  background: radial-gradient(120% 90% at 50% 0%, rgba(22, 163, 74, 0.1) 0%, transparent 65%), var(--surface);
}

html[data-theme="dark"] .spt-preview-header {
  background: #0f172a;
}

html[data-theme="dark"] .spt-table th {
  background: #1e293b;
  color: #e2e8f0;
  border-color: #334155;
}

html[data-theme="dark"] .spt-table th.spt-row-num,
html[data-theme="dark"] .spt-table td.spt-row-num {
  background: #0f172a;
  color: #64748b;
  border-color: #1e293b;
}

html[data-theme="dark"] .spt-table td {
  color: #f1f5f9;
  border-color: #1e293b;
}

html[data-theme="dark"] .spt-table tr:hover td {
  background: #1e293b;
}

html[data-theme="dark"] .spt-notice {
  background: #0f172a;
  color: #cbd5e1;
  border-color: #334155;
}

html[data-theme="dark"] .spt-notice strong {
  color: #f8fafc;
}
