/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --secondary-color: #22d3ee;
    --accent-color: #f59e0b;
    --background-dark: #0f172a;
    --background-medium: #1e293b;
    --background-light: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --border-radius: 12px;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.2);
    --transition: all 0.3s ease;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--background-dark) 0%, #1a1a2e 100%);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
}

/* Header Styles */
header {
    text-align: center;
    padding: 30px 20px;
    margin-bottom: 30px;
    background: linear-gradient(135deg, var(--background-medium) 0%, var(--background-light) 100%);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

header h1 {
    font-size: 2.5rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
    text-shadow: 0 0 30px rgba(99, 102, 241, 0.3);
}

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

/* Main Content Layout */
.main-content {
    display: grid;
    grid-template-columns: 300px 1fr 320px;
    gap: 20px;
    margin-bottom: 30px;
}

/* Panel Styles */
.panel {
    background: var(--background-medium);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(255, 255, 255, 0.05);
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

.panel::-webkit-scrollbar {
    width: 6px;
}

.panel::-webkit-scrollbar-track {
    background: var(--background-dark);
    border-radius: 3px;
}

.panel::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 3px;
}

.panel h2 {
    font-size: 1.3rem;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--primary-color);
    color: var(--text-primary);
}

/* Control Group Styles */
.control-group {
    margin-bottom: 25px;
    padding: 15px;
    background: var(--background-light);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.control-group h3 {
    font-size: 0.95rem;
    color: var(--secondary-color);
    margin-bottom: 12px;
    font-weight: 600;
}

/* Slider Styles */
.slider-container {
    margin-bottom: 12px;
}

.slider-container label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

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

.slider-container input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(99, 102, 241, 0.4);
    transition: var(--transition);
}

.slider-container input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.6);
}

.slider-container input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(99, 102, 241, 0.4);
}

.value-display {
    display: inline-block;
    background: var(--background-dark);
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 0.9rem;
    color: var(--secondary-color);
    font-weight: 600;
    margin-top: 8px;
    min-width: 60px;
    text-align: center;
}

/* Select Styles */
.medium-select {
    width: 100%;
    padding: 10px 12px;
    background: var(--background-dark);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
    margin-top: 8px;
    transition: var(--transition);
}

.medium-select:hover {
    border-color: var(--primary-color);
}

.medium-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

/* Checkbox Styles */
.checkbox-container {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    cursor: pointer;
}

.checkbox-container input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: 10px;
    accent-color: var(--primary-color);
    cursor: pointer;
}

.checkbox-container label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    cursor: pointer;
}

/* Color Picker Styles */
.color-picker-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.color-picker-container input[type="color"] {
    width: 50px;
    height: 35px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    background: transparent;
}

.color-picker-container input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-picker-container input[type="color"]::-webkit-color-swatch {
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
}

.color-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.wavelength-display {
    margin-top: 10px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.wavelength-display span:last-child {
    color: var(--accent-color);
    font-weight: 600;
}

/* Reset Button */
.btn-reset {
    width: 100%;
    padding: 12px 20px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 10px;
}

.btn-reset:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.btn-reset:active {
    transform: translateY(0);
}

/* Simulator Section */
.simulator-section {
    background: var(--background-medium);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
}

#simulatorCanvas {
    width: 100%;
    height: 500px;
    background: linear-gradient(180deg, 
        rgba(30, 41, 59, 0.8) 0%, 
        rgba(30, 41, 59, 0.8) 50%, 
        rgba(51, 65, 85, 0.8) 50%, 
        rgba(51, 65, 85, 0.8) 100%);
    border-radius: 8px;
    border: 2px solid rgba(255, 255, 255, 0.1);
}

/* Results Bar */
.results-bar {
    display: flex;
    justify-content: space-around;
    align-items: center;
    margin-top: 15px;
    padding: 15px;
    background: var(--background-light);
    border-radius: 8px;
    flex-wrap: wrap;
    gap: 10px;
}

.result-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 15px;
}

.result-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.result-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--secondary-color);
}

.critical-angle .result-value {
    color: var(--accent-color);
}

.tir-indicator {
    display: none;
}

.tir-indicator.active {
    display: flex;
}

.tir-badge {
    background: linear-gradient(135deg, var(--danger-color), #dc2626);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Info Panel - Formulas */
.formula-card, .info-card {
    background: var(--background-light);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    border-left: 3px solid var(--primary-color);
}

.formula-card h3, .info-card h3 {
    font-size: 0.95rem;
    color: var(--secondary-color);
    margin-bottom: 10px;
}

.formula {
    font-size: 1.3rem;
    font-family: 'Cambria Math', 'Times New Roman', serif;
    color: var(--text-primary);
    text-align: center;
    padding: 12px;
    background: var(--background-dark);
    border-radius: 6px;
    margin-bottom: 10px;
    letter-spacing: 1px;
}

.formula-explanation {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.info-card ul {
    list-style: none;
    padding-left: 0;
}

.info-card li {
    padding: 6px 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.info-card li:last-child {
    border-bottom: none;
}

.info-card li strong {
    color: var(--accent-color);
}

/* Velocity Card */
.velocity-card p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.velocity-card p strong {
    color: var(--text-primary);
}

.velocity-display {
    margin-top: 12px;
    padding: 10px;
    background: var(--background-dark);
    border-radius: 6px;
}

.velocity-item {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 0.85rem;
}

.velocity-item span:first-child {
    color: var(--text-muted);
}

.velocity-item span:last-child {
    color: var(--success-color);
    font-weight: 600;
}

/* Fun Facts Section */
.fun-facts-section {
    background: var(--background-medium);
    border-radius: var(--border-radius);
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(255, 255, 255, 0.05);
    overflow: hidden;
}

.fun-facts-section h2 {
    text-align: center;
    font-size: 1.5rem;
    margin-bottom: 25px;
    color: var(--accent-color);
}

.facts-carousel {
    position: relative;
    height: 280px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.fact-card {
    position: absolute;
    width: calc(100% - 40px);
    max-width: 600px;
    background: linear-gradient(135deg, var(--background-light), var(--background-dark));
    border-radius: var(--border-radius);
    padding: 30px;
    text-align: center;
    opacity: 0;
    transform: translateX(100px) scale(0.9);
    transition: all 0.5s ease;
    pointer-events: none;
    border: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 1;
}

.fact-card.active {
    opacity: 1;
    transform: translateX(0) scale(1);
    pointer-events: auto;
    z-index: 10;
}

.fact-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

.fact-card h3 {
    font-size: 1.3rem;
    color: var(--secondary-color);
    margin-bottom: 15px;
}

.fact-card p {
    font-size: 1rem;
    color: var(--text-secondary);
    line-height: 1.7;
}

.carousel-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-top: 30px;
    position: relative;
    z-index: 20;
}

.carousel-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--background-light);
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
}

.carousel-btn:hover {
    background: var(--primary-color);
    color: white;
}

.carousel-dots {
    display: flex;
    gap: 8px;
}

.carousel-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--background-light);
    cursor: pointer;
    transition: var(--transition);
}

.carousel-dot.active {
    background: var(--primary-color);
    transform: scale(1.2);
}

/* Technical Section */
.technical-section {
    background: var(--background-medium);
    border-radius: var(--border-radius);
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.technical-section h2 {
    text-align: center;
    font-size: 1.5rem;
    margin-bottom: 25px;
    color: var(--primary-color);
}

.technical-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.tech-card {
    background: var(--background-light);
    border-radius: 8px;
    padding: 20px;
    border-top: 3px solid var(--secondary-color);
    transition: var(--transition);
}

.tech-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.tech-card h3 {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.tech-card p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 10px;
}

.tech-card ul {
    list-style: none;
    padding-left: 0;
}

.tech-card li {
    padding: 5px 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
    position: relative;
    padding-left: 20px;
}

.tech-card li::before {
    content: "→";
    position: absolute;
    left: 0;
    color: var(--secondary-color);
}

.formula-inline {
    display: inline-block;
    background: var(--background-dark);
    padding: 8px 16px;
    border-radius: 4px;
    font-family: 'Cambria Math', 'Times New Roman', serif;
    font-size: 1.1rem;
    color: var(--accent-color);
    margin-top: 10px;
}

/* Footer */
footer {
    text-align: center;
    padding: 25px;
    background: var(--background-medium);
    border-radius: var(--border-radius);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

footer p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.footer-note {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 5px;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .panel {
        max-height: none;
    }
    
    .controls-panel {
        order: 1;
    }
    
    .simulator-section {
        order: 0;
    }
    
    .info-panel {
        order: 2;
    }
}

@media (max-width: 768px) {
    header h1 {
        font-size: 1.8rem;
    }
    
    .subtitle {
        font-size: 0.95rem;
    }
    
    .container {
        padding: 10px;
    }
    
    #simulatorCanvas {
        height: 350px;
    }
    
    .results-bar {
        flex-direction: column;
    }
    
    .fact-card {
        padding: 20px;
    }
    
    .technical-grid {
        grid-template-columns: 1fr;
    }
}

/* Animation for rays */
@keyframes rayGlow {
    0%, 100% {
        filter: drop-shadow(0 0 3px currentColor);
    }
    50% {
        filter: drop-shadow(0 0 8px currentColor);
    }
}

/* Tooltip styles */
.tooltip {
    position: relative;
    cursor: help;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--background-dark);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    z-index: 100;
}

.tooltip:hover::after {
    opacity: 1;
    visibility: visible;
}
