/* ===============================================================
   ToolDuck — JSON Size Analyser
   Styles for /json-size-analyzer/
   =============================================================== */

.jsa-app {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    margin-bottom: 2rem;
}

/* ---------------------------------------------------------------
   Header Bar
   --------------------------------------------------------------- */
.jsa-header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0.85rem 1.15rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md, 8px);
}

.jsa-unit-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.jsa-unit-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--ink-2);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.jsa-unit-tabs {
    display: inline-flex;
    background: var(--bg-muted);
    padding: 3px;
    border-radius: 6px;
    border: 1px solid var(--border);
    gap: 2px;
}

.jsa-unit-btn {
    padding: 4px 10px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--ink-2);
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.jsa-unit-btn.is-active {
    background: var(--surface);
    color: var(--primary, #1d4ed8);
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

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

/* ---------------------------------------------------------------
   Workspace Grid (Editor on Left, Stats Dashboard on Right)
   --------------------------------------------------------------- */
.jsa-workspace {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
}

@media (min-width: 950px) {
    .jsa-workspace {
        grid-template-columns: 1fr 1fr;
    }
}

/* ---------------------------------------------------------------
   Editor Column
   --------------------------------------------------------------- */
.jsa-editor-card {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md, 8px);
    overflow: hidden;
}

.jsa-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 1rem;
    background: var(--bg-muted);
    border-bottom: 1px solid var(--border);
}

.jsa-badge {
    font-size: 0.74rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--ink-2);
}

.jsa-badge--primary {
    background: rgba(29, 78, 216, 0.1);
    color: var(--primary, #1d4ed8);
    border-color: rgba(29, 78, 216, 0.2);
}

.jsa-badge--success {
    background: #dcfce7;
    color: #15803d;
    border-color: #bbf7d0;
}

.jsa-badge--danger {
    background: #fee2e2;
    color: #b91c1c;
    border-color: #fecaca;
}

html[data-theme="dark"] .jsa-badge--success {
    background: rgba(34, 197, 94, 0.15);
    color: #86efac;
}

html[data-theme="dark"] .jsa-badge--danger {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
}

.jsa-editor-body {
    position: relative;
    display: flex;
    min-height: 480px;
    max-height: 720px;
    background: var(--surface);
}

.jsa-gutter {
    flex-shrink: 0;
    width: 44px;
    padding: 0.85rem 0.5rem 0.85rem 0;
    text-align: right;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.82rem;
    line-height: 1.5;
    color: var(--ink-3, #94a3b8);
    background: var(--bg-muted);
    border-right: 1px solid var(--border);
    user-select: none;
    overflow: hidden;
    white-space: pre-wrap;
    box-sizing: border-box;
}

.jsa-textarea {
    flex: 1;
    width: 100%;
    margin: 0;
    padding: 0.85rem 1rem;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.82rem;
    line-height: 1.5;
    color: var(--ink);
    background: transparent;
    border: none;
    outline: none;
    resize: vertical;
    white-space: pre;
    overflow: auto;
    tab-size: 2;
    box-sizing: border-box;
}

/* ---------------------------------------------------------------
   Stats Dashboard
   --------------------------------------------------------------- */
.jsa-dashboard {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.jsa-section-title {
    font-size: 0.86rem;
    font-weight: 700;
    color: var(--ink-2);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0 0 0.5rem 0;
}

.jsa-metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

@media (min-width: 500px) and (max-width: 949px) {
    .jsa-metrics-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

.jsa-metric-card {
    display: flex;
    flex-direction: column;
    padding: 0.85rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm, 6px);
}

.jsa-metric-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--ink-3);
    margin-bottom: 0.25rem;
}

.jsa-metric-value {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}

.jsa-metric-value--primary {
    color: var(--primary, #1d4ed8);
}

/* Size Comparison Box */
.jsa-savings-card {
    padding: 1rem 1.15rem;
    background: var(--bg-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-md, 8px);
}

.jsa-savings-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.84rem;
}

.jsa-savings-row:last-child {
    border-bottom: none;
    font-weight: 600;
    padding-top: 0.6rem;
}

.jsa-savings-val {
    font-family: ui-monospace, SFMono-Regular, monospace;
}

/* ---------------------------------------------------------------
   Error & Toast
   --------------------------------------------------------------- */
.jsa-error-banner {
    padding: 0.75rem 1rem;
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
    border-radius: var(--radius-sm, 6px);
    font-size: 0.84rem;
    font-family: ui-monospace, SFMono-Regular, monospace;
    line-height: 1.4;
}

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

.jsa-toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--ink);
    color: var(--bg);
    padding: 0.65rem 1.15rem;
    border-radius: 999px;
    font-size: 0.84rem;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.2s ease;
    pointer-events: none;
}

.jsa-toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}
