:root {
    --primary-color: #6366f1;
    --secondary-color: #8b5cf6;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --background: #0f172a;
    --surface: #1e293b;
    --surface-light: #334155;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #475569;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--background);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

.quantum-computing-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 30px;
    padding: 30px 20px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(99, 102, 241, 0.3);
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    font-weight: 700;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Tabs Navigation */
.tabs-nav {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.tab-btn {
    padding: 12px 24px;
    background: var(--surface);
    color: var(--text);
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.tab-btn:hover {
    background: var(--surface-light);
    border-color: var(--primary-color);
}

.tab-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* Tab Content */
.tab-content {
    background: var(--surface);
    border-radius: 12px;
    padding: 20px;
    min-height: 600px;
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* Visualization Layout */
.visualization-layout {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 20px;
    margin-bottom: 20px;
}

@media (max-width: 1024px) {
    .visualization-layout {
        grid-template-columns: 1fr;
    }
}

/* Canvas Containers */
.bloch-display,
.superposition-display,
.measurement-display,
.entanglement-display,
.circuit-display,
.algorithms-display {
    background: var(--surface);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--border);
}

.bloch-display h3,
.superposition-display h3,
.measurement-display h3,
.entanglement-display h3,
.circuit-display h3,
.algorithms-display h3 {
    margin-bottom: 15px;
    color: var(--primary-color);
    font-size: 1.3rem;
}

canvas {
    width: 100%;
    border-radius: 8px;
    background: var(--background);
    display: block;
}

#blochCanvas,
#superpositionCanvas,
#measurementCanvas,
#entanglementCanvas {
    height: 400px;
}

#circuitCanvas,
#algorithmsCanvas {
    height: 300px;
}

/* Info Displays */
.bloch-info,
.superposition-info,
.entanglement-info {
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 15px;
    background: var(--surface-light);
    border-radius: 6px;
    font-size: 0.95rem;
}

.measurement-stats {
    margin-top: 15px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
}

.stat-item {
    padding: 12px 15px;
    background: var(--surface-light);
    border-radius: 6px;
    font-size: 0.9rem;
    text-align: center;
}

/* Controls Panel */
.controls-panel {
    background: var(--surface);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--border);
    height: fit-content;
}

.controls-panel h3 {
    margin-bottom: 20px;
    color: var(--primary-color);
    font-size: 1.2rem;
}

.control-group {
    margin-bottom: 20px;
}

.control-group h4 {
    margin-bottom: 10px;
    color: var(--text);
    font-size: 1rem;
    font-weight: 600;
}

.control-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

input[type="range"] {
    width: 100%;
    height: 6px;
    background: var(--surface-light);
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

/* Buttons */
.button-group {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.control-button {
    flex: 1;
    min-width: 120px;
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.control-button.start {
    background: var(--success-color);
    color: white;
}

.control-button.pause {
    background: var(--warning-color);
    color: white;
}

.control-button.reset {
    background: var(--surface-light);
    color: var(--text);
}

.control-button.apply {
    background: var(--primary-color);
    color: white;
}

.control-button.measure {
    background: var(--secondary-color);
    color: white;
}

.control-button.single {
    background: var(--warning-color);
    color: white;
}

.control-button.run {
    background: var(--success-color);
    color: white;
}

.control-button.step {
    background: var(--primary-color);
    color: white;
}

.control-button.add {
    background: var(--success-color);
    color: white;
}

.control-button.clear {
    background: var(--danger-color);
    color: white;
}

.control-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.control-button:active {
    transform: translateY(0);
}

.state-btn,
.gate-btn,
.bell-btn,
.circuit-gate-btn,
.algorithm-btn,
.preset-btn {
    padding: 8px 16px;
    margin: 4px;
    background: var(--surface-light);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.state-btn:hover,
.gate-btn:hover,
.bell-btn:hover,
.circuit-gate-btn:hover,
.algorithm-btn:hover,
.preset-btn:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.state-btn.active,
.gate-btn.active,
.bell-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* Formula Section */
.formula-section {
    margin-top: 20px;
    padding: 15px;
    background: var(--surface-light);
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
}

.formula-section h4 {
    margin-bottom: 10px;
    color: var(--text);
}

.formula {
    font-family: 'Courier New', monospace;
    font-size: 1.1rem;
    color: var(--primary-color);
    text-align: center;
    padding: 10px;
}

/* Explanation Section */
.explanation-section {
    margin-top: 20px;
    padding: 15px;
    background: var(--surface-light);
    border-radius: 8px;
}

.explanation-section h4 {
    margin-bottom: 10px;
    color: var(--text);
}

.explanation-section p {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.6;
}

/* Circuit Output */
.circuit-output {
    margin-top: 15px;
    padding: 15px;
    background: var(--surface-light);
    border-radius: 8px;
}

.circuit-output h4 {
    margin-bottom: 10px;
    color: var(--text);
}

#circuitOutputDisplay {
    font-family: 'Courier New', monospace;
    font-size: 1.2rem;
    color: var(--primary-color);
    text-align: center;
    padding: 15px;
}

/* Circuit List */
.circuit-list {
    margin-top: 20px;
}

.circuit-list h4 {
    margin-bottom: 10px;
    color: var(--text);
}

#circuitGatesList {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 40px;
    padding: 10px;
    background: var(--surface-light);
    border-radius: 6px;
}

.circuit-gate-tag {
    padding: 6px 12px;
    background: var(--primary-color);
    color: white;
    border-radius: 4px;
    font-size: 0.9rem;
}

/* Measurement Results */
.measurement-results {
    margin-top: 20px;
    padding: 15px;
    background: var(--surface-light);
    border-radius: 8px;
}

.measurement-results h4 {
    margin-bottom: 10px;
    color: var(--text);
}

.result-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

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

/* Algorithm Info */
.algorithm-info {
    margin-top: 15px;
}

.algorithm-info h4 {
    margin-bottom: 10px;
    color: var(--text);
}

.algorithm-comparison {
    margin-top: 15px;
    padding: 15px;
    background: var(--surface-light);
    border-radius: 8px;
}

.complexity-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
}

/* Algorithm Steps */
.algorithm-steps {
    margin-top: 20px;
}

.algorithm-steps h4 {
    margin-bottom: 10px;
    color: var(--text);
}

#stepsDisplay {
    padding: 15px;
    background: var(--surface-light);
    border-radius: 6px;
    min-height: 100px;
    font-size: 0.9rem;
}

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

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

.step-item.active {
    color: var(--primary-color);
    font-weight: 600;
}

/* Main Explanation Section */
.explanation {
    margin-top: 40px;
    padding: 30px;
    background: var(--surface);
    border-radius: 12px;
    border: 1px solid var(--border);
}

.explanation h2 {
    color: var(--primary-color);
    margin-bottom: 20px;
    font-size: 1.8rem;
}

.explanation h3 {
    color: var(--secondary-color);
    margin-top: 25px;
    margin-bottom: 15px;
    font-size: 1.4rem;
}

.explanation p {
    color: var(--text-muted);
    line-height: 1.8;
    margin-bottom: 15px;
}

.explanation strong {
    color: var(--text);
}

/* Responsive Design */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.8rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .tabs-nav {
        flex-direction: column;
    }

    .tab-btn {
        width: 100%;
    }

    .button-group {
        flex-direction: column;
    }

    .control-button {
        width: 100%;
    }

    .measurement-stats {
        grid-template-columns: 1fr;
    }
}

/* Animations */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.pulse {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes glow {
    0%, 100% {
        box-shadow: 0 0 5px var(--primary-color);
    }
    50% {
        box-shadow: 0 0 20px var(--primary-color);
    }
}

.glow {
    animation: glow 2s ease-in-out infinite;
}
