/**
 * NMR Simulator Styles - Clean & Compact
 */

/* Container */
.nmr-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: #0f172a;
    color: #e2e8f0;
}

.nmr-layout {
    display: flex;
    gap: 12px;
    padding: 12px;
    height: 100%;
    overflow: hidden;
}

/* Sidebar (controls) */
.nmr-sidebar {
    width: 220px;
    min-width: 200px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    max-height: 100%;
}

/* Main area (visualizations) */
.nmr-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow: hidden;
}

.nmr-viz-row {
    display: flex;
    gap: 10px;
    flex: 0 0 auto;
}

/* Panel styling */
.nmr-panel {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 6px;
    overflow: hidden;
}

.nmr-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    background: #334155;
    font-size: 12px;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Molecule panel */
.nmr-molecule-panel {
    flex: 0 0 280px;
    display: flex;
    flex-direction: column;
}

.nmr-molecule-panel canvas {
    flex: 1;
    width: 100%;
    min-height: 160px;
    display: block;
}

/* Pulse panel */
.nmr-pulse-panel {
    flex: 1;
    min-width: 200px;
}

.nmr-pulse-container {
    padding: 8px;
    max-height: 150px;
    overflow-y: auto;
}

.nmr-pulse-empty {
    color: #64748b;
    font-size: 11px;
    text-align: center;
    padding: 20px;
}

.nmr-pulse-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nmr-pulse-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.nmr-pulse-track {
    flex: 1;
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

/* Pulse diagram */
.nmr-pulse-diagram {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nmr-pulse-channel {
    display: flex;
    align-items: center;
    gap: 6px;
}

.nmr-pulse-label {
    width: 32px;
    font-size: 9px;
    color: #818cf8;
    font-weight: 600;
    text-align: right;
    flex-shrink: 0;
}

.nmr-pulse-timeline {
    flex: 1;
    display: flex;
    align-items: center;
    height: 28px;
    position: relative;
}

.nmr-pulse-timeline::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 1px;
    background: #475569;
}

.nmr-pulse-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 1;
}

.nmr-pulse-bar {
    width: 8px;
    border-radius: 2px;
}

.nmr-pulse-90 .nmr-pulse-bar {
    height: 16px;
    background: #3b82f6;
}

.nmr-pulse-180 .nmr-pulse-bar {
    height: 22px;
    background: #8b5cf6;
}

.nmr-pulse-small .nmr-pulse-bar {
    height: 10px;
    background: #22c55e;
}

.nmr-pulse-name {
    font-size: 7px;
    color: #94a3b8;
    margin-top: 1px;
}

.nmr-pulse-delay {
    width: 12px;
    height: 1px;
    background: #475569;
}

.nmr-pulse-line {
    flex: 1;
    height: 1px;
    background: #334155;
}

.nmr-jc-evol {
    display: flex;
    gap: 4px;
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px dashed #334155;
}

.nmr-jc-gate {
    font-size: 8px;
    padding: 2px 5px;
    background: #7c3aed;
    color: white;
    border-radius: 3px;
    font-family: monospace;
}

/* Repeat indicators */
.nmr-repeat-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    background: rgba(251, 146, 60, 0.15);
    border: 1px dashed #fb923c;
    border-radius: 4px;
    margin-bottom: 6px;
}

.nmr-repeat-icon {
    font-size: 14px;
    color: #fb923c;
}

.nmr-repeat-label {
    font-size: 10px;
    color: #fb923c;
    font-weight: 600;
}

.nmr-repeat-bracket {
    font-size: 16px;
    font-weight: bold;
    color: #fb923c;
    padding: 0 4px;
    z-index: 1;
}

.nmr-repeat-start {
    margin-right: 2px;
}

.nmr-repeat-end {
    margin-left: 2px;
}

/* Control flow blocks in pulse sequence (REPEAT/END) */
.nmr-pulse-cf {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 24px;
    padding: 2px 4px;
    border-radius: 4px;
    margin: 0 3px;
    font-size: 10px;
    position: relative;
    z-index: 2;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.nmr-pulse-repeat {
    background: linear-gradient(135deg, #a855f7 0%, #7c3aed 100%);
    border: 1px solid #c084fc;
}

.nmr-pulse-end {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    border: 1px solid #f87171;
}

.nmr-cf-symbol {
    font-size: 12px;
    font-weight: bold;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    line-height: 1;
}

.nmr-cf-label {
    font-size: 8px;
    color: rgba(255, 255, 255, 0.9);
    line-height: 1;
    margin-top: 1px;
}

/* Peak info popup */
.nmr-peak-popup {
    position: fixed;
    z-index: 10001;
    background: #1e293b;
    border: 1px solid #475569;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    min-width: 220px;
    max-width: 300px;
    font-size: 12px;
    animation: nmr-popup-fade-in 0.15s ease-out;
}

@keyframes nmr-popup-fade-in {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

.nmr-popup-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: #334155;
    border-radius: 8px 8px 0 0;
    border-bottom: 1px solid #475569;
}

.nmr-popup-nucleus {
    font-size: 16px;
    font-weight: 700;
    color: #fbbf24;
}

.nmr-popup-element {
    font-size: 11px;
    padding: 2px 6px;
    background: #6366f1;
    color: white;
    border-radius: 4px;
    font-weight: 600;
}

.nmr-popup-close {
    margin-left: auto;
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 14px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
}

.nmr-popup-close:hover {
    background: #475569;
    color: #f1f5f9;
}

.nmr-popup-body {
    padding: 10px 12px;
}

.nmr-popup-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    border-bottom: 1px solid #334155;
}

.nmr-popup-row:last-child {
    border-bottom: none;
}

.nmr-popup-label {
    color: #94a3b8;
    font-size: 11px;
}

.nmr-popup-value {
    color: #e2e8f0;
    font-weight: 600;
    font-family: 'Consolas', 'Monaco', monospace;
}

.nmr-popup-env {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #334155;
}

.nmr-popup-env .nmr-popup-label {
    display: block;
    margin-bottom: 4px;
}

.nmr-popup-desc {
    display: block;
    color: #cbd5e1;
    font-size: 11px;
    line-height: 1.4;
    font-style: italic;
}

/* Spectrum panel */
.nmr-spectrum-panel {
    flex: 1;
    min-height: 200px;
    display: flex;
    flex-direction: column;
}

.nmr-spectrum-container {
    flex: 1;
    display: flex;
    padding: 8px;
    padding-top: 0;
}

.nmr-spectrum-panel canvas {
    width: 100%;
    height: 100%;
    min-height: 180px;
    display: block;
    cursor: grab;
    border-radius: 4px;
}

.nmr-spectrum-panel canvas:active {
    cursor: grabbing;
}

.nmr-spectrum-tools {
    display: flex;
    gap: 4px;
}

.nmr-select-sm {
    padding: 2px 6px;
    font-size: 11px;
    background: #1e293b;
    color: #e2e8f0;
    border: 1px solid #475569;
    border-radius: 3px;
    cursor: pointer;
}

.nmr-btn-sm {
    padding: 2px 8px;
    font-size: 11px;
    background: #1e293b;
    color: #e2e8f0;
    border: 1px solid #475569;
    border-radius: 3px;
    cursor: pointer;
}

.nmr-btn-sm:hover {
    background: #334155;
}

/* Sidebar inputs */
.nmr-select {
    width: calc(100% - 16px);
    padding: 6px 8px;
    font-size: 12px;
    background: #0f172a;
    color: #e2e8f0;
    border: 1px solid #475569;
    border-radius: 4px;
    margin: 6px 8px;
    flex-shrink: 0;
}

#nmr-sample-panel {
    max-height: 280px;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
}

#nmr-sample-panel .nmr-panel-header {
    flex-shrink: 0;
}

.nmr-sample-info {
    padding: 0 8px 4px 8px;
    flex-shrink: 0;
}

.nmr-formula {
    font-size: 13px;
    font-weight: 600;
    color: #f1f5f9;
    font-family: 'Segoe UI', system-ui, sans-serif;
}

.nmr-desc {
    font-size: 10px;
    color: #64748b;
    line-height: 1.3;
    margin-top: 2px;
}

.nmr-nuclei-list {
    padding: 4px 8px 8px 8px;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.nmr-nuclei-header {
    font-size: 10px;
    color: #818cf8;
    margin-bottom: 4px;
}

.nmr-nuclei-table {
    width: 100%;
    font-size: 10px;
    border-collapse: collapse;
}

.nmr-nuclei-table th,
.nmr-nuclei-table td {
    padding: 2px 4px;
    text-align: left;
    border-bottom: 1px solid #334155;
}

.nmr-nuclei-table th {
    color: #64748b;
    font-weight: 500;
}

.nmr-nuclei-table td:first-child {
    color: #818cf8;
}

.nmr-jc-section {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid #334155;
}

.nmr-jc-header {
    font-size: 9px;
    color: #818cf8;
    margin-bottom: 3px;
}

.nmr-jc-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.nmr-jc-item {
    font-size: 9px;
    color: #94a3b8;
    background: #0f172a;
    padding: 2px 5px;
    border-radius: 3px;
    font-family: monospace;
}

#nmr-field-panel,
#nmr-relax-panel,
#nmr-pulse-shape-panel {
    flex-shrink: 0;
}

/* Field controls */
.nmr-field-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
}

.nmr-field-row label {
    font-size: 11px;
    color: #94a3b8;
    width: 24px;
    flex-shrink: 0;
}

.nmr-field-row input[type="range"] {
    flex: 1;
    min-width: 50px;
    height: 4px;
    -webkit-appearance: none;
    background: #334155;
    border-radius: 2px;
    cursor: pointer;
}

.nmr-field-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    background: #6366f1;
    border-radius: 50%;
    cursor: pointer;
}

.nmr-field-row input[type="number"] {
    width: 50px;
    padding: 3px 4px;
    font-size: 11px;
    background: #0f172a;
    color: #e2e8f0;
    border: 1px solid #475569;
    border-radius: 3px;
    text-align: right;
}

.nmr-unit {
    font-size: 10px;
    color: #64748b;
    width: 18px;
}

.nmr-select-inline {
    flex: 1;
    padding: 3px 6px;
    font-size: 10px;
    background: #0f172a;
    color: #e2e8f0;
    border: 1px solid #475569;
    border-radius: 3px;
    cursor: pointer;
}

/* Badge */
.nmr-badge {
    display: inline-block;
    padding: 1px 5px;
    font-size: 10px;
    font-weight: 600;
    background: #334155;
    color: #a5b4fc;
    border-radius: 3px;
    font-family: monospace;
}

/* Resources tab */
.nmr-resources {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 12px;
    padding: 12px;
    overflow-y: auto;
}

.nmr-res-section {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 6px;
    padding: 12px;
}

.nmr-res-section h4 {
    font-size: 12px;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid #334155;
}

.nmr-equations {
    font-family: 'Segoe UI', system-ui, sans-serif;
}

.nmr-eq-block {
    padding: 6px 0;
    font-size: 12px;
    color: #cbd5e1;
    border-bottom: 1px solid #334155;
}

.nmr-eq-block:last-child {
    border-bottom: none;
}

.nmr-gamma-table {
    width: 100%;
    font-size: 12px;
}

.nmr-gamma-table td {
    padding: 4px 6px;
}

.nmr-gamma-table td:last-child {
    text-align: right;
    color: #818cf8;
    font-family: monospace;
}

/* Density matrix */
.nmr-density-scroll {
    overflow-x: auto;
    max-height: 200px;
}

.nmr-density-table {
    border-collapse: collapse;
    font-size: 10px;
}

.nmr-density-table th,
.nmr-density-table td {
    padding: 3px 6px;
    border: 1px solid #334155;
    text-align: center;
    min-width: 40px;
}

.nmr-density-table th {
    background: #334155;
    color: #94a3b8;
    font-weight: 500;
    font-family: monospace;
}

/* Samples grid in resources */
.nmr-samples-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 8px;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 4px;
}

.nmr-samples-grid::-webkit-scrollbar {
    width: 6px;
}

.nmr-samples-grid::-webkit-scrollbar-track {
    background: transparent;
}

.nmr-samples-grid::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 3px;
}

.nmr-sample-card {
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 4px;
    padding: 8px;
    font-size: 11px;
}

.nmr-sample-card strong {
    color: #f1f5f9;
}

.nmr-qubits {
    float: right;
    background: #334155;
    color: #7c3aed;
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 9px;
    font-weight: 600;
    color: #818cf8;
}

.nmr-sample-nuclei {
    margin-top: 4px;
    font-family: monospace;
    color: #64748b;
    font-size: 10px;
}

.nmr-note {
    color: #64748b;
    font-size: 11px;
    font-style: italic;
}

/* Scrollbar */
.nmr-sidebar::-webkit-scrollbar,
.nmr-pulse-container::-webkit-scrollbar,
.nmr-density-scroll::-webkit-scrollbar,
.nmr-resources::-webkit-scrollbar,
.nmr-nuclei-list::-webkit-scrollbar {
    width: 6px;
}

.nmr-sidebar::-webkit-scrollbar-track,
.nmr-pulse-container::-webkit-scrollbar-track,
.nmr-density-scroll::-webkit-scrollbar-track,
.nmr-resources::-webkit-scrollbar-track,
.nmr-nuclei-list::-webkit-scrollbar-track {
    background: transparent;
}

.nmr-sidebar::-webkit-scrollbar-thumb,
.nmr-pulse-container::-webkit-scrollbar-thumb,
.nmr-density-scroll::-webkit-scrollbar-thumb,
.nmr-resources::-webkit-scrollbar-thumb,
.nmr-nuclei-list::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 3px;
}

/* Hide number input spinners */
.nmr-field-row input[type="number"]::-webkit-outer-spin-button,
.nmr-field-row input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.nmr-field-row input[type="number"] {
    -moz-appearance: textfield;
}

/* Resources wrapper */
.resources-wrapper {
    height: 100%;
}

.resources-wrapper .nmr-resources {
    height: 100%;
}

/* Fullscreen styles */
.nmr-fullscreen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 9998;
    backdrop-filter: blur(4px);
}

.nmr-fullscreen {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: 90vw !important;
    height: 85vh !important;
    max-width: 1400px !important;
    max-height: 900px !important;
    z-index: 9999 !important;
    border-radius: 12px !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5) !important;
}

.nmr-fullscreen canvas {
    height: calc(100% - 40px) !important;
    min-height: unset !important;
}

.nmr-fullscreen .nmr-spectrum-container {
    height: calc(100% - 40px);
}

.nmr-fullscreen-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    padding: 0.375rem 0.75rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--surface-light, #1e293b);
    color: var(--text-primary, #f1f5f9);
    z-index: 10000;
}

.nmr-fullscreen-close:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    background: var(--surface-lighter, #334155);
}

.nmr-fullscreen-btn {
    font-size: 14px !important;
    padding: 2px 6px !important;
}

/* Responsive */
@media (max-width: 768px) {
    .nmr-layout {
        flex-direction: column;
    }
    
    .nmr-sidebar {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .nmr-sidebar .nmr-panel {
        flex: 1 1 200px;
    }
    
    .nmr-viz-row {
        flex-direction: column;
    }
    
    .nmr-molecule-panel,
    .nmr-pulse-panel {
        flex: 1 1 auto;
    }
    
    .nmr-fullscreen {
        width: 95vw !important;
        height: 90vh !important;
    }
}
