/* Spectra Realizer - Stylesheet */

.realizer-workspace {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 1.5rem;
    max-width: 1560px;
    margin: 0 auto;
    padding: 1.5rem 2rem 3rem;
    min-height: calc(100vh - 70px);
}

@media (max-width: 1080px) {
    .realizer-workspace {
        grid-template-columns: 1fr;
        padding: 1rem;
    }
}

/* Sidebar Controls */
.realizer-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.realizer-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: var(--shadow-card);
    transition: border-color 0.2s ease;
}

.realizer-card:hover {
    border-color: var(--border-strong);
}

.card-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.85rem;
}

.card-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-helper {
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.45;
    margin-top: 0.4rem;
}

/* Form Controls */
.form-group {
    margin-bottom: 1rem;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.styled-select, .styled-input, .styled-textarea {
    width: 100%;
    background: var(--input-bg);
    color: var(--text-primary);
    border: 1px solid var(--input-border);
    border-radius: 8px;
    padding: 0.65rem 0.85rem;
    font-size: 0.9rem;
    font-family: inherit;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.styled-textarea {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    resize: vertical;
    min-height: 80px;
    line-height: 1.5;
}

.styled-select:focus, .styled-input:focus, .styled-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}

/* Target Class Pills Grid */
.class-selector-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.class-option-label {
    display: flex;
    flex-direction: column;
    padding: 0.65rem 0.75rem;
    background: var(--input-bg);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.class-option-label:hover {
    border-color: var(--accent);
    background: var(--bg-surface-secondary);
}

.class-option-label input[type="radio"] {
    display: none;
}

.class-option-label.active,
.class-option-label:has(input[type="radio"]:checked) {
    border-color: var(--accent);
    background: rgba(59, 130, 246, 0.12);
}

.class-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.class-formula {
    font-size: 0.72rem;
    color: var(--text-secondary);
    font-family: 'Consolas', monospace;
    margin-top: 0.2rem;
}

/* Row for Settings */
.label-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}

.label-row .form-label {
    margin-bottom: 0;
}

.param-badge {
    font-size: 0.68rem;
    font-weight: 700;
    padding: 0.12rem 0.45rem;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.12);
    color: var(--accent);
    letter-spacing: 0.02em;
    border: 1px solid rgba(37, 99, 235, 0.25);
}

.settings-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.styled-input-num {
    width: 100%;
    padding: 0.55rem 0.75rem;
    background: var(--input-bg);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.88rem;
    font-weight: 600;
    font-family: 'Consolas', monospace;
    transition: all 0.2s ease;
    outline: none;
}

.styled-input-num:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

/* Search Effort Profile Chips */
.search-presets-group {
    margin-bottom: 0.85rem;
}

.profile-chips {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.4rem;
    margin-top: 0.4rem;
}

.chip-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    padding: 0.5rem 0.25rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.76rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.chip-btn:hover {
    border-color: var(--accent);
    color: var(--text-primary);
    background: var(--bg-surface-elevated);
    transform: translateY(-1px);
}

.chip-btn.active {
    border-color: var(--accent);
    background: rgba(37, 99, 235, 0.12);
    color: var(--accent);
    font-weight: 700;
    box-shadow: 0 0 0 1px var(--accent);
}

.chip-sub {
    font-size: 0.66rem;
    font-weight: 500;
    opacity: 0.85;
    font-family: 'Consolas', monospace;
}

/* Action Card Group & Buttons */
.action-card-group {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.action-buttons-row {
    display: flex;
    gap: 0.6rem;
    align-items: stretch;
    width: 100%;
}

.btn-primary-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex: 1;
    padding: 0.8rem 1.25rem;
    background: var(--accent);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-primary-action:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.4);
}

.btn-primary-action.loading {
    opacity: 0.85;
    pointer-events: none;
}

.btn-stop-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.8rem 1.15rem;
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #ef4444;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-stop-action:hover {
    background: #ef4444;
    color: #ffffff;
    border-color: #ef4444;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn-stop-action.hidden {
    display: none !important;
}

/* Live Solver Progress Box */
.solver-progress-box {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 0.75rem 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    box-shadow: var(--shadow-card);
    animation: fadeIn 0.2s ease;
}

.solver-progress-box.hidden {
    display: none !important;
}

.progress-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-primary);
}

.progress-pct {
    font-family: 'Consolas', monospace;
    font-weight: 700;
    color: var(--accent);
}

.progress-bar-track {
    width: 100%;
    height: 6px;
    background: var(--border-subtle);
    border-radius: 999px;
    overflow: hidden;
    position: relative;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent) 0%, #38bdf8 100%);
    border-radius: 999px;
    transition: width 0.15s ease;
}

.progress-sub-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.72rem;
    color: var(--text-muted);
    font-family: 'Consolas', monospace;
}

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

.btn-secondary-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem 0.85rem;
    background: var(--btn-inactive-bg);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary-action:hover {
    background: var(--btn-inactive-hover);
    color: var(--text-primary);
    border-color: var(--border-strong);
}

/* Main Workspace Stages */
.realizer-main {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Status Banner */
.status-banner {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.2rem 1.4rem;
    border-radius: 12px;
    border: 1px solid;
    background: var(--bg-surface);
    box-shadow: var(--shadow-card);
    position: relative;
    overflow: hidden;
}

.status-banner.success {
    border-color: rgba(16, 185, 129, 0.4);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.08) 0%, var(--bg-surface) 100%);
}

.status-banner.warning {
    border-color: rgba(245, 158, 11, 0.4);
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.08) 0%, var(--bg-surface) 100%);
}

.status-banner.danger {
    border-color: rgba(239, 68, 68, 0.4);
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.08) 0%, var(--bg-surface) 100%);
}

.status-icon {
    font-size: 1.75rem;
    line-height: 1;
    margin-top: 0.1rem;
}

.status-content {
    flex: 1;
}

.status-title-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.35rem;
    flex-wrap: wrap;
}

.status-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.status-desc {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.65rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.badge.success {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.35);
}

.badge.warning {
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.35);
}

.badge.danger {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.35);
}

/* Primary Dual Stage: Matrix + Visualizer */
.dual-stage-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 1280px) {
    .dual-stage-grid {
        grid-template-columns: 1fr;
    }
}

/* Matrix Card */
.matrix-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
}

.matrix-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.precision-group {
    display: inline-flex;
    align-items: center;
    background: var(--bg-surface-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    padding: 2px;
}

.prec-btn {
    background: none;
    border: none;
    padding: 0.25rem 0.55rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.prec-btn.active {
    background: var(--accent);
    color: #ffffff;
}

.copy-toolbar {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.copy-btn {
    background: var(--bg-surface-secondary);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.copy-btn:hover {
    color: var(--text-primary);
    border-color: var(--border-strong);
    background: var(--btn-inactive-hover);
}

.matrix-viewport {
    overflow-x: auto;
    padding: 0.5rem 0;
    max-height: 420px;
}

.matrix-table {
    border-collapse: collapse;
    margin: 0 auto;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.85rem;
}

.matrix-table th {
    color: var(--text-muted);
    font-size: 0.72rem;
    padding: 0.35rem 0.6rem;
    text-align: center;
    font-weight: 500;
}

.matrix-table td {
    padding: 0.45rem 0.75rem;
    text-align: right;
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    transition: background 0.15s ease;
}

.matrix-table td:hover {
    outline: 2px solid var(--accent);
    position: relative;
    z-index: 2;
}

/* Complex Plane Visualizer Card */
.visualizer-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
}

.canvas-wrapper {
    position: relative;
    width: 100%;
    height: 420px;
    min-height: 380px;
    max-height: 460px;
    background: var(--canvas-bg);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-subtle);
}

.canvas-wrapper canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    display: block;
    cursor: crosshair;
}

.canvas-toolbar {
    position: absolute;
    bottom: 12px;
    right: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    padding: 3px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.canvas-tool-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 4px 8px;
    font-size: 0.85rem;
    font-weight: 700;
    border-radius: 4px;
    cursor: pointer;
}

.canvas-tool-btn:hover {
    background: var(--bg-surface-secondary);
    color: var(--text-primary);
}

.canvas-legend {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 0.75rem;
    font-size: 0.78rem;
    color: var(--text-secondary);
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.legend-swatch {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.legend-swatch.target {
    border: 2px solid #3b82f6;
    background: transparent;
}

.legend-swatch.candidate {
    background: #10b981;
}

.legend-swatch.unit-circle {
    border: 1px dashed #38bdf8;
    background: transparent;
}

.legend-swatch.karpelevich {
    background: rgba(244, 114, 182, 0.4);
    border-radius: 2px;
}

/* Secondary Stage: Diagnostics & Verification */
.diagnostics-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 1100px) {
    .diagnostics-grid {
        grid-template-columns: 1fr;
    }
}

.diag-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: var(--shadow-card);
}

.diag-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    margin-top: 0.75rem;
}

.diag-item {
    padding: 0.75rem 0.9rem;
    border-radius: 8px;
    border: 1px solid var(--border-subtle);
    background: var(--bg-surface-secondary);
}

.diag-item.pass {
    border-left: 3px solid #10b981;
}

.diag-item.fail {
    border-left: 3px solid #ef4444;
}

.diag-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.25rem;
}

.diag-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
}

.diag-pill {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.15rem 0.45rem;
    border-radius: 12px;
}

.diag-pill.pass-pill {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
}

.diag-pill.fail-pill {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.diag-detail {
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.45;
    margin: 0;
}

/* Verification Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
    margin-top: 0.75rem;
}

.data-table th {
    text-align: left;
    padding: 0.5rem 0.75rem;
    border-bottom: 2px solid var(--border-subtle);
    color: var(--text-secondary);
    font-weight: 600;
}

.data-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.data-table td.good {
    color: #10b981;
    font-weight: 600;
}

.data-table td.warn {
    color: #f59e0b;
    font-weight: 600;
}

.data-table td.bad {
    color: #ef4444;
    font-weight: 600;
}

.tag-pass {
    color: #10b981;
    font-weight: 700;
    font-size: 0.75rem;
}

.tag-fail {
    color: #ef4444;
    font-weight: 700;
    font-size: 0.75rem;
}

.tag-warn {
    color: #f59e0b;
    font-weight: 700;
    font-size: 0.75rem;
}

/* Toast Notifications */
.realizer-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #1e293b;
    color: #ffffff;
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.4);
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid #334155;
    opacity: 0;
    transform: translateY(12px);
    transition: all 0.25s ease;
    z-index: 9999;
    pointer-events: none;
}

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