/* --- RESET & BASICS --- */
:root {
    --primary: #4f46e5;       /* Indigo 600 */
    --primary-hover: #4338ca; /* Indigo 700 */
    --bg-page: #f8fafc;       /* Slate 50 */
    --bg-panel: #ffffff;
    --border: #e2e8f0;        /* Slate 200 */
    --text-main: #1e293b;     /* Slate 800 */
    --text-muted: #64748b;    /* Slate 500 */
}

body {
    margin: 0;
    font-family: ui-sans-serif, system-ui, sans-serif;
    background-color: var(--bg-page);
    color: var(--text-main);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* --- LAYOUT --- */
.grid-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}
@media (min-width: 1024px) {
    .grid-layout { grid-template-columns: 350px 1fr; }
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}
.title-group { display: flex; align-items: center; gap: 0.75rem; }
.title-group h1 {
    font-size: 1.5rem;
    font-weight: 800;
    margin: 0;
    background: linear-gradient(to right, #4f46e5, #9333ea);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.icon-brand { color: var(--primary); }

/* --- PANELS --- */
.panel {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}
.panel-header h2 { font-size: 1.125rem; margin: 0; }
.badge {
    font-size: 0.75rem;
    background: #f1f5f9;
    padding: 2px 8px;
    border-radius: 4px;
    color: var(--text-muted);
    font-family: monospace;
}

/* --- MAPPING LIST --- */
.mapping-list {
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 1rem;
    padding-top: 10px;
}
.mapping-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}
.input-group { position: relative; flex: 1; }
.input-group input {
    width: 100%;
    box-sizing: border-box;
    /* Changed: Equal padding on Left and Right (2rem) keeps text dead center */
    padding: 0.5rem 2rem; 
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-family: monospace;
    text-align: center;
}
.input-group .label {
    position: absolute;
    left: 0.5rem;
    top: -6px;
    font-size: 0.65rem;
    background: var(--bg-panel);
    padding: 0 2px;
    color: var(--text-muted);
}
.input-out {
    color: var(--primary);
    font-weight: bold;
    border-color: #e0e7ff;
}

/* --- BUTTONS --- */
button { cursor: pointer; border: none; background: none; }
.btn-dashed {
    width: 100%;
    padding: 0.5rem;
    border: 1px dashed var(--border);
    border-radius: 0.5rem;
    color: var(--text-muted);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
}
.btn-dashed:hover { background: #f8fafc; color: var(--primary); }

.btn-primary {
    width: 100%;
    padding: 0.75rem;
    background: var(--primary);
    color: white;
    font-weight: bold;
    border-radius: 0.75rem;
    margin-top: 1rem;
    transition: background 0.2s;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.7; cursor: not-allowed; }

.btn-text { font-size: 0.75rem; color: var(--text-muted); display: flex; gap: 4px; }
.btn-text:hover { color: var(--primary); }

.btn-small {
    font-size: 0.75rem;
    padding: 4px 12px;
    background: #eef2ff;
    color: var(--primary);
    border-radius: 6px;
}

/* --- RESULTS AREA --- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 300px;
    color: #94a3b8;
}
.icon-circle {
    width: 64px; height: 64px; background: #f1f5f9;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 1rem;
}

.card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1rem;
    margin-bottom: 1rem;
}
.card h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 0 0 0.5rem 0;
}

.raw-text {
    font-family: monospace;
    color: var(--text-main);
    line-height: 1.6;
}
.token { font-weight: bold; color: var(--primary); }

/* --- GRID OUTPUT --- */
.grid-output {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 0.5rem;
    max-height: 200px;
    overflow-y: auto;
}
.grid-item {
    background: #f8fafc;
    border: 1px solid #f1f5f9;
    border-radius: 4px;
    padding: 0.5rem;
    text-align: center;
    font-size: 0.75rem;
    font-weight: bold;
    color: var(--primary);
    animation: zoomIn 0.3s backwards;
}

/* --- CHART --- */
.chart-container {
    height: 150px;
    display: flex;
    align-items: flex-end;
    justify-content: space-around;
    padding-bottom: 1.5rem; /* Space for labels */
}
.chart-col {
    position: relative;
    width: 100%;
    height: 100%;
    margin: 0 4px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}
.bar-fill {
    width: 60%;
    background: #c7d2fe;
    border-radius: 4px 4px 0 0;
    transition: height 0.5s ease;
}
.bar-fill:hover { background: var(--primary); }
.bar-label {
    position: absolute;
    bottom: -20px;
    font-size: 10px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}
.bar-tooltip {
    position: absolute;
    top: -25px; /* simplified pos */
    background: #1e293b;
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}
.chart-col:hover .bar-tooltip { opacity: 1; }

/* --- FOOTER --- */
footer {
    margin-top: 3rem;
    text-align: center;
    border-top: 1px solid var(--border);
    padding-top: 1.5rem;
    color: var(--text-muted);
}

footer p {
    margin: 0.25rem 0;
    font-size: 0.875rem;
}

footer .legal {
    font-size: 0.75rem;
    opacity: 0.7;
}

footer strong {
    color: var(--primary);
}

@keyframes zoomIn {
    from { transform: scale(0.5); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}