/* ═══════════════════════════════════════════════
   CSV to JSON Converter — style.css
   Vercel-style + Apple Design CSS (from Day 1)
   ═══════════════════════════════════════════════ */

/* ─── Design Tokens ─── */
:root {
    --bg: #ffffff;
    --bg-soft: #f9fafb;
    --bg-muted: #f3f4f6;
    --fg: #111827;
    --fg-soft: #374151;
    --muted: #6b7280;
    --border: #e5e7eb;
    --border-soft: #f0f1f3;
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --accent-soft: #eef2ff;
    --success: #10b981;
    --danger: #ef4444;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.10);
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --font-mono: 'SF Mono', 'Cascadia Code', 'JetBrains Mono', 'Fira Code', monospace;
    --max-width: 800px;
}

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

html { scroll-behavior: smooth; }

body {
    font: 100%/1.5 var(--font);
    color: var(--fg);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ─── Layout ─── */
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 24px;
    width: 100%;
}

main.container {
    flex: 1;
    padding-top: 32px;
    padding-bottom: 48px;
}

/* ─── Header ─── */
.header {
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 56px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--fg);
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: -0.02em;
}

.logo-icon { font-size: 1.2rem; }
.logo-accent { color: var(--accent); margin: 0 2px; }

.header-badges {
    display: flex;
    gap: 8px;
}

.badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
}

.badge-free { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-soft); }
.badge-privacy { background: #ecfdf5; color: var(--success); border-color: #d1fae5; }
.badge-browser { background: var(--bg-muted); color: var(--muted); }

/* ─── Hero ─── */
.hero {
    text-align: center;
    padding: 48px 24px 24px;
}

.hero h1 {
    font-size: clamp(2rem, 5vw, 3rem);
    line-height: 1.05;
    letter-spacing: -0.03em;
    font-weight: 800;
    font-optical-sizing: auto;
}

.hero-accent {
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    margin-top: 16px;
    color: var(--muted);
    font-size: 1.1rem;
    max-width: 560px;
    margin-left: auto;
    margin-right: auto;
}

/* ─── Drop Zone ─── */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease;
    background: var(--bg-soft);
    -webkit-tap-highlight-color: transparent;
}

.drop-zone:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.drop-zone.dragover {
    border-color: var(--accent);
    background: var(--accent-soft);
    transform: scale(0.99);
    transition: transform 0.1s ease-out;
}

.drop-zone:active {
    transform: scale(0.99);
    transition: transform 0.1s ease-out;
}

.drop-zone-icon { font-size: 2.5rem; margin-bottom: 12px; }
.drop-zone-text { font-weight: 600; font-size: 1.1rem; }
.drop-zone-subtext { color: var(--muted); font-size: 0.9rem; margin-top: 4px; }

/* ─── File List ─── */
.file-list-section { margin-top: 24px; }

.file-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.file-list-title { font-weight: 600; }

.file-list {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-height: 240px;
    overflow-y: auto;
    -webkit-mask-image: linear-gradient(to bottom, transparent 0, black 8px, black calc(100% - 8px), transparent 100%);
    mask-image: linear-gradient(to bottom, transparent 0, black 8px, black calc(100% - 8px), transparent 100%);
}

.file-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-soft);
    animation: fadeIn 0.2s ease;
}

.file-item:last-child { border-bottom: none; }

.file-item-icon { font-size: 1.2rem; }

.file-item-name {
    flex: 1;
    font-weight: 500;
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-item-size {
    color: var(--muted);
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
}

.file-item-remove {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s ease, color 0.15s ease;
}

.file-item-remove:hover { background: var(--bg-muted); color: var(--danger); }
.file-item-remove:active { transform: scale(0.9); transition: transform 0.1s ease-out; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }

/* ─── Settings Panel ─── */
.settings-panel {
    margin-top: 24px;
    padding: 24px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.settings-title { font-size: 1rem; font-weight: 600; margin-bottom: 16px; }

.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.setting-item { display: flex; flex-direction: column; gap: 6px; }

.setting-item label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--muted);
}

.setting-item select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    font: inherit;
    cursor: pointer;
    transition: border-color 0.15s ease;
}

.setting-item select:focus { border-color: var(--accent); outline: none; }

/* ─── Preview Table ─── */
.preview-section { margin-top: 24px; }

.preview-hint {
    font-size: 0.8rem;
    color: var(--muted);
    margin-bottom: 8px;
    font-style: italic;
}

.section-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 12px;
    letter-spacing: -0.01em;
}

.preview-count { color: var(--muted); font-weight: 400; font-size: 0.9rem; }

.table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-height: 320px;
    overflow-y: auto;
}

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

.preview-table th {
    background: var(--bg-soft);
    text-align: left;
    padding: 8px 12px;
    font-weight: 600;
    color: var(--fg-soft);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    white-space: nowrap;
    vertical-align: top;
}

.preview-table th .col-name {
    display: block;
    margin-bottom: 4px;
}

.preview-table th .col-type {
    font-weight: 400;
    font-size: 0.75rem;
}

.preview-table th select.col-type-select {
    font-size: 0.75rem;
    padding: 2px 6px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    color: var(--muted);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.preview-table th select.col-type-select:focus {
    border-color: var(--accent);
    outline: none;
}

.preview-table th .json-path-input {
    font-size: 0.7rem;
    padding: 2px 6px;
    border: 1px solid var(--border-soft);
    border-radius: 4px;
    background: var(--bg);
    color: var(--accent);
    width: 100%;
    min-width: 80px;
    font-family: var(--font-mono);
    margin-top: 4px;
    -webkit-tap-highlight-color: transparent;
}

.preview-table th .json-path-input:focus {
    border-color: var(--accent);
    outline: none;
    background: var(--accent-soft);
}

.preview-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-soft);
    color: var(--fg-soft);
    white-space: nowrap;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.preview-table tr:last-child td { border-bottom: none; }
.preview-table tr:hover td { background: var(--bg-soft); }

/* ─── Mapping Controls ─── */
.mapping-controls {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.btn-mapping {
    font-size: 0.8rem;
    padding: 6px 12px;
}

/* ─── Convert Action ─── */
.convert-action {
    margin-top: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

/* ─── Related Grid (SEO internal links) ─── */
.related-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.related-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 20px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--fg);
    -webkit-tap-highlight-color: transparent;
    transition: border-color 0.15s ease, transform 0.1s ease-out;
}

.related-card:hover { border-color: var(--accent); }
.related-card:active { transform: scale(0.98); transition: transform 0.1s ease-out; }

.related-icon { font-size: 1.8rem; margin-bottom: 8px; }
.related-title { font-size: 0.85rem; font-weight: 600; line-height: 1.3; }

/* ─── Batch Controls ─── */
.batch-controls {
    margin-top: 12px;
    padding: 16px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.batch-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.batch-toggle input {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--accent);
}

.batch-output-mode {
    display: flex;
    gap: 20px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.batch-output-mode label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    color: var(--fg-soft);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.batch-output-mode input[type="radio"] {
    cursor: pointer;
    accent-color: var(--accent);
}

/* ─── Counter ─── */
.counter {
    font-size: 0.9rem;
    color: var(--muted);
}
.counter strong { color: var(--fg); }

/* ─── Buttons ─── */
.btn-primary {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 12px 28px;
    border-radius: var(--radius-sm);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s ease, transform 0.1s ease-out;
}

.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { transform: scale(0.97); transition: transform 0.1s ease-out; }
.btn-primary:disabled { background: var(--border); color: var(--muted); cursor: not-allowed; }

.btn-secondary {
    background: var(--bg);
    color: var(--fg);
    border: 1px solid var(--border);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font: inherit;
    font-weight: 500;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s ease, transform 0.1s ease-out;
}

.btn-secondary:hover { background: var(--bg-muted); }
.btn-secondary:active { transform: scale(0.97); transition: transform 0.1s ease-out; }

.btn-text {
    background: none;
    border: none;
    color: var(--muted);
    font: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.btn-text:hover { color: var(--accent); }
.btn-text:active { transform: scale(0.97); transition: transform 0.1s ease-out; }

/* ─── Output ─── */
.output-section { margin-top: 24px; }

/* ─── Progress Bar ─── */
.progress-bar-section {
    margin-top: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.progress-bar {
    flex: 1;
    height: 4px;
    background: var(--bg-muted);
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 0.85rem;
    color: var(--muted);
    white-space: nowrap;
}

.output-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 12px;
}

.output-actions { display: flex; gap: 8px; }

.output-code {
    background: #0d1117;
    color: #c9d1d9;
    padding: 20px;
    border-radius: var(--radius);
    overflow-x: auto;
    font: 0.85rem/1.5 var(--font-mono);
    max-height: 400px;
    overflow-y: auto;
}

.output-code code { background: none; padding: 0; }

/* ─── Features ─── */
.features-section {
    padding: 64px 0;
    background: var(--bg-soft);
}

.section-title-center {
    text-align: center;
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    margin-bottom: 40px;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

.feature {
    padding: 24px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    -webkit-tap-highlight-color: transparent;
    transition: border-color 0.15s ease, transform 0.1s ease-out;
}

.feature:hover { border-color: var(--accent); }
.feature:active { transform: scale(0.98); transition: transform 0.1s ease-out; }

.feature-icon { font-size: 2rem; margin-bottom: 12px; }

.feature h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 8px;
    letter-spacing: -0.01em;
}

.feature p { color: var(--muted); font-size: 0.9rem; line-height: 1.5; }

.feature code {
    background: var(--bg-muted);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.85em;
    color: var(--accent);
}

/* ─── FAQ ─── */
.faq-section { padding: 64px 0; }

.faq-list { max-width: 680px; margin: 0 auto; }

.faq-item {
    border-bottom: 1px solid var(--border);
    padding: 16px 0;
}

.faq-item summary {
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    list-style: none;
    position: relative;
    padding-right: 24px;
}

.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
    content: '+';
    position: absolute;
    right: 0;
    font-size: 1.2rem;
    color: var(--muted);
    transition: transform 0.2s ease;
}
.faq-item[open] summary::after { transform: rotate(45deg); }

.faq-item p {
    margin-top: 12px;
    color: var(--muted);
    line-height: 1.6;
}

/* ─── Footer ─── */
.footer {
    border-top: 1px solid var(--border);
    padding: 24px 0;
    text-align: center;
}

.footer-text { color: var(--muted); font-size: 0.85rem; }
.footer-text a { color: var(--accent); text-decoration: none; }
.footer-text a:hover { text-decoration: underline; }

/* ─── Modal (Paywall) — Apple Design: Materials + Scale-in ─── */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(8px) saturate(180%);
    -webkit-backdrop-filter: blur(8px) saturate(180%);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.open {
    display: flex;
    opacity: 0;
    animation: modalOverlayIn 0.25s ease forwards;
}

.modal-content {
    background: var(--bg);
    border-radius: var(--radius-lg);
    padding: 32px;
    max-width: 440px;
    width: calc(100% - 48px);
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg), 0 16px 48px rgba(0,0,0,0.12);
    transform: scale(0.95);
    opacity: 0;
    animation: modalContentIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) 0.05s forwards;
    will-change: transform, opacity;
    position: relative;
}

@keyframes modalOverlayIn { to { opacity: 1; } }
@keyframes modalContentIn { to { transform: scale(1); opacity: 1; } }

.payment-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--muted);
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    -webkit-tap-highlight-color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, transform 0.1s ease-out;
}

.payment-close:hover { background: var(--bg-muted); }
.payment-close:active { transform: scale(0.9); transition: transform 0.1s ease-out; }

.paywall-body { text-align: center; }

.paywall-icon { font-size: 2.5rem; margin-bottom: 16px; }

.paywall-title {
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-bottom: 8px;
}

.paywall-subtitle { color: var(--muted); font-size: 0.95rem; margin-bottom: 24px; }

.price-card {
    background: var(--accent-soft);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
}

.price-amount {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--accent);
}

.price-label { font-weight: 600; color: var(--fg); margin-top: 4px; }
.price-note { font-size: 0.85rem; color: var(--muted); margin-top: 4px; }

.payment-network {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--fg-soft);
    margin-bottom: 16px;
}

.payment-qr {
    display: flex;
    justify-content: center;
    margin-bottom: 16px;
}

.payment-qr img { border-radius: var(--radius-sm); border: 1px solid var(--border); }

.payment-label {
    display: block;
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 6px;
    text-align: left;
}

.address-row {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.address-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font: 0.8rem var(--font-mono);
    background: var(--bg-soft);
    color: var(--fg-soft);
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-copy-address {
    padding: 10px 16px;
    background: var(--bg-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font: inherit;
    font-weight: 500;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    white-space: nowrap;
    transition: background 0.15s ease, transform 0.1s ease-out;
}

.btn-copy-address:hover { background: var(--border); }
.btn-copy-address:active { transform: scale(0.95); transition: transform 0.1s ease-out; }

.payment-txid-group { margin-bottom: 16px; }

.txid-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font: 0.85rem var(--font-mono);
    margin-bottom: 12px;
    transition: border-color 0.15s ease;
}

.txid-input:focus { border-color: var(--accent); outline: none; }

.btn-verify { width: 100%; }

.payment-status {
    margin-top: 12px;
    font-size: 0.9rem;
    font-weight: 500;
    min-height: 24px;
}

.payment-status.success { color: var(--success); }
.payment-status.error { color: var(--danger); }
.payment-status.loading { color: var(--muted); }

.payment-wait {
    margin-top: 12px;
    font-size: 0.8rem;
    color: var(--muted);
}

/* ─── Toast Notifications ─── */
.toast-container {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    background: var(--fg);
    color: #fff;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.25s ease, toastOut 0.25s ease 2.5s forwards;
    pointer-events: auto;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

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

/* ─── Mobile Responsive ─── */
@media (max-width: 640px) {
    .header-badges { display: none; }
    .hero { padding: 32px 16px 16px; }
    .features-grid { grid-template-columns: 1fr; }
    .related-grid { grid-template-columns: 1fr; }
    .settings-grid { grid-template-columns: 1fr; }
    .convert-action { flex-direction: column; align-items: stretch; }
    .btn-convert { width: 100%; }
    .output-header { flex-direction: column; align-items: flex-start; }
    .output-actions { width: 100%; }
    .output-actions .btn-secondary { flex: 1; }
}

/* ─── Reduced Motion (Apple Design: Accessibility) ─── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .modal { animation: none; opacity: 1; }
    .modal-content { animation: none; transform: none; opacity: 1; }
    .file-item { animation: none; }
    .toast { animation: none; }
}

/* ─── Reduced Transparency (Apple Design: Accessibility) ─── */
@media (prefers-reduced-transparency: reduce) {
    .modal { background: rgba(0,0,0,0.8); backdrop-filter: none; -webkit-backdrop-filter: none; }
}