/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #00FFFF;
    --secondary-color: #0080FF;
    --accent-color: #4444ff;
    --background-gradient: linear-gradient(135deg, #0a0a0a, #1a1a2e, #16213e);
    --card-background: rgba(0, 0, 0, 0.7);
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --border-color: #333;
    --hover-glow: rgba(0, 255, 255, 0.3);
}

/* Color scheme variations */
[data-theme="purple"] {
    --primary-color: #9d4edd;
    --secondary-color: #7209b7;
    --accent-color: #560bad;
    --background-gradient: linear-gradient(135deg, #0a0a0a, #2d1b69, #240046);
    --hover-glow: rgba(157, 78, 221, 0.3);
}

[data-theme="green"] {
    --primary-color: #00ff41;
    --secondary-color: #00cc33;
    --accent-color: #008f11;
    --background-gradient: linear-gradient(135deg, #0a0a0a, #0d2818, #001100);
    --hover-glow: rgba(0, 255, 65, 0.3);
}

[data-theme="orange"] {
    --primary-color: #ff6b35;
    --secondary-color: #f7931e;
    --accent-color: #ff8500;
    --background-gradient: linear-gradient(135deg, #0a0a0a, #2d1810, #1a0f00);
    --hover-glow: rgba(255, 107, 53, 0.3);
}

[data-theme="blue"] {
    --primary-color: #0077be;
    --secondary-color: #005a9c;
    --accent-color: #003d6b;
    --background-gradient: linear-gradient(135deg, #0a0a0a, #0f1419, #001122);
    --hover-glow: rgba(0, 119, 190, 0.3);
}

[data-theme="red"] {
    --primary-color: #dc2626;
    --secondary-color: #b91c1c;
    --accent-color: #991b1b;
    --background-gradient: linear-gradient(135deg, #0a0a0a, #2d0a0a, #1a0000);
    --hover-glow: rgba(220, 38, 38, 0.3);
}

body {
    font-family: 'Arial', sans-serif;
    background: var(--background-gradient);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    transition: all 0.3s ease;
}

/* App Layout */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.header {
    background: var(--card-background);
    padding: 1rem 2rem;
    border-bottom: 2px solid var(--primary-color);
    backdrop-filter: blur(10px);
}

.header h1 {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    text-shadow: 0 0 10px var(--hover-glow);
}

.header p {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.main-content {
    flex: 1;
    display: grid;
    grid-template-columns: 350px 1fr 300px;
    gap: 1rem;
    padding: 1rem;
    min-height: calc(100vh - 120px);
}

/* Sidebar Styles */
.sidebar {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    backdrop-filter: blur(10px);
    overflow-y: auto;
    height: 82vh;
    width: 300px; 
    min-width: 200px;
    max-width: 500px;
    float: left;
    scrollbar-width: none; 
}

.sidebar::-webkit-scrollbar:vertical {
    width: 0px;
    background: transparent; 
}

.resize-handle {
    width: 1px;
    background: #888;
    cursor: ew-resize;
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
}

.section {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #333;
}

.section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.section h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1.2rem;
    text-shadow: 0 0 5px var(--hover-glow);
}

.btn-section {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

/* Matrix Input */
.matrix-input {
    margin-bottom: 1rem;
}

.matrix-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.matrix-cell {
    flex: 1;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.matrix-cell:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 10px var(--hover-glow);
    background: rgba(255, 255, 255, 0.15);
}

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

.control-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.slider {
    width: 100%;
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
    transition: all 0.3s ease;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    cursor: pointer;
    border-radius: 50%;
    box-shadow: 0 0 10px var(--hover-glow);
}

.slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    cursor: pointer;
    border-radius: 50%;
    border: none;
    box-shadow: 0 0 10px var(--hover-glow);
}

.select {
    width: 100%;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 10px var(--hover-glow);
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    color: #000;
    box-shadow: 0 4px 15px var(--hover-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--hover-glow);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-1px);
}

.btn-tertiary {
    margin: 5px;
    background: transparent;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
}

.btn-tertiary:hover {
    background: var(--hover-glow);
    box-shadow: 0 0 10px var(--hover-glow);
    transform: translateY(-1px);
}

.preset-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.preset-btn {
    padding: 0.5rem;
    font-size: 0.8rem;
}

/* Coordinates Display */
.bloch-coords {
    display: flex;
    gap: 1rem;
    margin-top: 0.5rem;
}

.coord-display {
    background: rgba(255, 255, 255, 0.05);
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

/* Visualization Area */
.visualization {
    position: relative;
    height: 70vh;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
}

#threejs-container {
    flex: 1;
    min-height: 500px;
    border-radius: 12px;
    overflow: hidden;
}

.instructions {
    padding: 1rem;
    text-align: center;
    background: rgba(0, 0, 0, 0.7);
    color: var(--text-secondary);
    font-size: 0.9rem;
    border-top: 1px solid var(--border-color);
    border-radius: 0 0 12px 12px;
}

 /* Touch Effect */
.touch-effect {
    position: absolute;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--primary-color) 0%, transparent 70%);
    pointer-events: none;
    opacity: 0;
    transform: scale(0);
    z-index: 10;
}

/* Properties Panel */
.properties-panel {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    backdrop-filter: blur(10px);
    height: 82vh;
    overflow-y: auto;
    overflow-x:hidden;
}

.properties-panel::-webkit-scrollbar:vertical {
    width: 0px;
    background: transparent; 
}

.properties-panel h3 {
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    font-size: 1.2rem;
    text-shadow: 0 0 5px var(--hover-glow);
}

.property-group {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.property-group:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.property-group h4 {
    color: var(--secondary-color);
    margin-bottom: 0.75rem;
    font-size: 1rem;
}

.property-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    padding: 0.25rem 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.property-item span {
    color: var(--text-primary);
    font-weight: 600;
    font-family: 'Courier New', monospace;
}

/* Matrix Display */
.matrix-display {
    background: rgba(255, 255, 255, 0.05);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.matrix-display .matrix-row {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 0.5rem;
}

.matrix-display .matrix-row:last-child {
    margin-bottom: 0;
}

.matrix-display span {
    font-family: 'Courier New', monospace;
    color: var(--primary-color);
    font-size: 0.9rem;
    min-width: 80px;
    text-align: center;
}

/* Error Messages */
.error-message {
    color: #ff6b6b;
    font-size: 0.8rem;
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: rgba(255, 107, 107, 0.1);
    border: 1px solid rgba(255, 107, 107, 0.3);
    border-radius: 4px;
    display: none;
}

.error-message.show {
    display: block;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 300px 1fr 250px;
    }
}

@media (max-width: 768px) {
    .main-content {
        grid-template-columns: 1fr;
        gap: 0.5rem;
        padding: 0.5rem;
    }
    
    .header {
        padding: 0.75rem 1rem;
    }
    
    .header h1 {
        font-size: 1.5rem;
    }
    
    .sidebar, .properties-panel {
        order: 2;
    }
    
    .visualization {
        order: 1;
    }
    
    #threejs-container {
        min-height: 400px;
    }
    
    .preset-buttons {
        grid-template-columns: 1fr 1fr 1fr;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    display: none;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(45deg, var(--secondary-color), var(--primary-color));
}

/* Animation Classes */
.fade-in {
    animation: fadeIn 0.5s ease-in-out;
}

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

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

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}


.properties-panel {
    background: var(--card-background);
    padding: 15px;
    border-radius: 12px;
    width: 280px;
    color: #fff;
    font-family: 'Segoe UI', sans-serif;
    font-size: 14px;
    border: 1px solid var(--border-color);
}

.properties-panel h3 {
    text-align: center;
    font-size: 16px;
    margin-bottom: 12px;
    color: var(--primary-color);
}

.property-group {
    margin-bottom: 15px;
}

.property-group h4 {
    font-size: 14px;
    margin-bottom: 6px;
    color: var(--secondary-color);
}

.property-item {
    padding: 5px 8px;
    border-radius: 6px;
    margin-bottom: 5px;
    background: rgba(255, 255, 255, 0.05);
    cursor: pointer;
    position: relative;
}

/* Tooltip style */
.property-item::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 120%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    font-size: 12px;
    padding: 6px 8px;
    border-radius: 6px;
    white-space: normal;
    width: max-content;
    max-width: 220px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    text-align: center;
}

.property-item:hover::after {
    opacity: 1;
}

.matrix-display {
    background: rgba(255, 255, 255, 0.08);
    padding: 8px;
    border-radius: 6px;
    display: inline-block;
}

.matrix-row {
    display: flex;
    justify-content: space-between;
}



.main-content {
    display: flex;
    height: 100vh;
}

.sidebar {
    user-select: none;
    width: 300px;
    min-width: 200px;
    max-width: 500px;
    background: #1e1e1e;
    color: white;
    position: relative;
}

.resize-handle {
    width: 10px;
    margin: 0px;
    padding: 0px;
    background: transparent;
    cursor: ew-resize;
    position:relative;
    right: -10;
    top: 0;
    height: 82vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.resize-handle .elm {
    width: 3px;
    margin: 0px;
    padding: 0px;
    background: #555;
    cursor: ew-resize;
    position:relative;
    right: -10;
    top: 0;
    height: 82vh;
}

.resize-handle:hover .elm {
    background: #aaa;
}

.visualization {
    flex: 1;
    background: #000;
    display: flex;
    flex-direction: column;
}

/* Toast Notification */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--card-background);
    color: var(--text-primary);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    border: 1px solid var(--primary-color);
    box-shadow: 0 4px 15px var(--hover-glow);
    transform: translateX(400px);
    transition: transform 0.3s ease;
    z-index: 1000;
    backdrop-filter: blur(10px);
}

.toast.show {
    transform: translateX(0);
}

.toast.success {
    border-color: #10b981;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.toast.error {
    border-color: #ef4444;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
}

/* Button pulse effect for interactions */
.btn.clicked {
    animation: buttonPulse 0.3s ease;
}

@keyframes buttonPulse {
    0% { transform: scale(1); }
    50% { transform: scale(0.95); }
    100% { transform: scale(1); }
}