/* Global styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background: linear-gradient(135deg, #1a237e 0%, #311b92 100%);
    color: #fff;
    min-height: 100vh;
    padding: 20px;
    overflow-x: hidden;
}

/* Start up screen */
.startup-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1a237e 0%, #311b92 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: opacity 0.5s ease;
}

.startup-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.startup-title {
    font-size: 3.5rem;
    margin-bottom: 20px;
    background: linear-gradient(to right, #00b4db, #0083b0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-align: center;
}

.startup-subtitle {
    font-size: 1.4rem;
    margin-bottom: 50px;
    opacity: 0.9;
    text-align: center;
}

.startup-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 25px;
    max-width: 800px;
    width: 90%;
    margin-bottom: 40px;
}

.startup-btn {
    padding: 25px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    color: white;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
    text-align: center;
    min-height: 180px;
}

.startup-btn:hover {
    transform: translateY(-5px);
    background: rgba(255, 255, 255, 0.15);
    border-color: #00b4db;
    box-shadow: 0 10px 25px rgba(0, 180, 219, 0.3);
}

.startup-btn .icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.startup-description {
    font-size: 0.9rem;
    opacity: 0.8;
    margin-top: 10px;
}

.skip-btn {
    padding: 15px 40px;
    background: #00b4db;
    border: none;
    border-radius: 10px;
    color: white;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.skip-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(255, 152, 0, 0.3);
}

/* Main layout */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
}

h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    background: linear-gradient(to right, #00b4db, #0083b0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Navigation section*/
.nav-buttons {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin: 30px 0;
    flex-wrap: wrap;
}

.nav-btn {
    padding: 15px 30px;
    background: linear-gradient(to right, #00b4db, #0083b0);
    border: none;
    border-radius: 10px;
    color: white;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(0, 180, 219, 0.3);
}

.nav-btn.save {
    background: linear-gradient(to right, #4CAF50, #2E7D32);
}

.nav-btn.save:hover {
    box-shadow: 0 10px 20px rgba(76, 175, 80, 0.3);
}

/* Motor effect section */
.main-content {
    display: flex;
    gap: 30px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.simulation-container {
    flex: 1;
    min-width: 400px;
    height: 500px;
    background-color: rgba(0, 0, 0, 0.4);
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    position: relative;
}

.simulation-controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    padding: 15px;
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 0 0 15px 15px;
    position: absolute;
    bottom: 0;
    width: 100%;
    z-index: 10;
}

.sim-btn {
    padding: 10px 20px;
    background: linear-gradient(to right, #00b4db, #0083b0);
    border: none;
    border-radius: 8px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sim-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 180, 219, 0.4);
}

.sim-btn.reset {
    background: linear-gradient(to right, #ff416c, #ff4b2b);
}

.sim-btn.reset:hover {
    box-shadow: 0 5px 15px rgba(255, 65, 108, 0.4);
}

.controls-and-calculator {
    flex: 1;
    min-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.controls {
    background-color: rgba(255, 255, 255, 0.08);
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.control-group h2 {
    margin-bottom: 20px;
    color: #00b4db;
    font-size: 1.5rem;
    text-align: left;
}

.slider-container {
    margin-bottom: 25px;
}

.slider-container label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #e0e0e0;
}

input[type="range"] {
    width: 100%;
    height: 10px;
    -webkit-appearance: none;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #00b4db;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(0, 180, 219, 0.8);
}

.value-display {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-weight: 600;
    color: #00b4db;
}

/* Calculator section */
.calculator-section {
    margin: 40px 0;
    display: none;
}

.calculator-container {
    background-color: rgba(255, 255, 255, 0.08);
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    width: 100%;
}

.calculator-container h2 {
    color: #00b4db;
    margin-bottom: 20px;
    font-size: 1.5rem;
    text-align: center;
}

.advanced-calculator {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    width: 100%;
}

.calc-field {
    display: flex;
    flex-direction: column;
}

.calc-field label {
    font-weight: 600;
    margin-bottom: 8px;
    color: #e0e0e0;
    font-size: 0.9rem;
}

.calc-field input {
    padding: 15px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    background-color: rgba(0, 0, 0, 0.3);
    color: white;
    font-size: 1.1rem;
    height: 55px;
}

.calc-field input:focus {
    outline: none;
    border-color: #00b4db;
    box-shadow: 0 0 0 2px rgba(0, 180, 219, 0.3);
}

.calc-units {
    font-size: 0.8rem;
    color: #aaa;
    margin-top: 5px;
}

.unit-select {
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    background-color: rgba(0, 0, 0, 0.3);
    color: white;
    margin-top: 8px;
    width: 100%;
    cursor: pointer;
}

.unit-select:hover {
    border-color: #00b4db;
}

.unit-select option {
    background-color: #1a237e;
    color: white;
}

.calc-buttons {
    grid-column: span 2;
    display: flex;
    gap: 20px;
    margin-top: 20px;
    justify-content: flex-end;
}

.calc-btn {
    flex: 0 0 auto;
    padding: 18px 40px;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1.1rem;
    height: 60px;
}

.calc-btn.reset {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.calc-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.result-display {
    grid-column: span 2;
    background-color: rgba(0, 0, 0, 0.2);
    padding: 20px;
    border-radius: 10px;
    margin-top: 20px;
}

#forceValue {
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 15px;
    color: #00b4db;
    text-align: center;
}

#calculationSteps {
    font-size: 0.9rem;
    color: #e0e0e0;
    line-height: 1.6;
}

#calculationSteps strong {
    color: #00b4db;
}

/* Split ring commutator section */
.commutator-section {
    margin: 40px 0;
    display: none;
}

.commutator-container {
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
    margin-bottom: 30px;
}

.commutator-3d {
    flex: 1;
    min-width: 400px;
    height: 500px;
    background-color: rgba(0, 0, 0, 0.4);
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    position: relative;
}

.commutator-controls-panel {
    flex: 1;
    min-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.commutator-sliders {
    background-color: rgba(255, 255, 255, 0.08);
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.commutator-sliders h3 {
    color: #00b4db;
    margin-bottom: 20px;
    font-size: 1.5rem;
}

.commutator-slider-container {
    margin-bottom: 20px;
}

.commutator-slider-container label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #e0e0e0;
}

.commutator-slider-container input[type="range"] {
    width: 100%;
    height: 10px;
    -webkit-appearance: none;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    outline: none;
}

.commutator-slider-container input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #00b4db;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(0, 180, 219, 0.8);
}

.commutator-value-display {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-weight: 600;
    color: #00b4db;
}

.commutator-controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    padding: 15px;
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 0 0 15px 15px;
    position: absolute;
    bottom: 0;
    width: 100%;
    z-index: 10;
    flex-wrap: wrap;
}

.commutator-btn {
    padding: 10px 20px;
    background: #00b4db;
    border: none;
    border-radius: 8px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.commutator-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 180, 219, 0.4);
}

.commutator-btn.stop {
    background: linear-gradient(to right, #ff4800, #e73010);
}

.commutator-btn.stop:hover {
    box-shadow: 0 5px 15px rgba(255, 72, 0, 0.4);
}

.commutator-btn.reset {
    background: linear-gradient(to right, #ff416c, #ff4b2b);
}

.commutator-btn.reset:hover {
    box-shadow: 0 5px 15px rgba(255, 65, 108, 0.4);
}

/* Save/Load section */
.save-load-container {
    background-color: rgba(255, 255, 255, 0.08);
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    margin-top: 30px;
}

.save-load-container h3 {
    color: #00b4db;
    margin-bottom: 20px;
    font-size: 1.5rem;
}

.save-load-controls {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.save-load-btn {
    padding: 12px 25px;
    background: linear-gradient(to right, #4CAF50, #2E7D32);
    border: none;
    border-radius: 8px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    flex: 1;
    min-width: 150px;
}

.save-load-btn.load {
    background: linear-gradient(to right, #2196F3, #0D47A1);
}

.save-load-btn.delete {
    background: linear-gradient(to right, #ff416c, #ff4b2b);
}

.save-load-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.saved-configs {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 15px;
}

.saved-config {
    background: rgba(0, 0, 0, 0.2);
    padding: 15px;
    border-radius: 10px;
    border-left: 4px solid #4CAF50;
}

.saved-config-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.saved-config-name {
    font-weight: 600;
    color: #00b4db;
    font-size: 1.1rem;
}

.saved-config-date {
    font-size: 0.8rem;
    opacity: 0.7;
}

.saved-config-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.config-action-btn {
    padding: 8px 15px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    flex: 1;
}

.config-action-btn.load {
    background: #2196F3;
    color: white;
}

.config-action-btn.load:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(33, 150, 243, 0.4);
}

.config-action-btn.export {
    background: #4CAF50;
    color: white;
}

.config-action-btn.export:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(76, 175, 80, 0.4);
}

.config-action-btn.delete {
    background: #ff416c;
    color: white;
}

.config-action-btn.delete:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 65, 108, 0.4);
}

/* Save Modal */
.save-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.save-modal.active {
    opacity: 1;
    pointer-events: all;
}

.save-modal-content {
    background: linear-gradient(135deg, #1a237e 0%, #311b92 100%);
    padding: 30px;
    border-radius: 15px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.save-modal h3 {
    color: #00b4db;
    margin-bottom: 20px;
    font-size: 1.8rem;
}

.save-modal-input {
    width: 100%;
    padding: 15px;
    margin-bottom: 20px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: white;
    font-size: 1.1rem;
}

.save-modal-input:focus {
    outline: none;
    border-color: #00b4db;
}

.save-modal-buttons {
    display: flex;
    gap: 15px;
}

.save-modal-btn {
    flex: 1;
    padding: 15px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.save-modal-btn.save {
    background: linear-gradient(to right, #4CAF50, #2E7D32);
    color: white;
}

.save-modal-btn.save:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(76, 175, 80, 0.4);
}

.save-modal-btn.cancel {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.save-modal-btn.cancel:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 255, 255, 0.2);
}

/* Theory section */
.theory {
    background-color: rgba(255, 255, 255, 0.08);
    padding: 30px;
    border-radius: 15px;
    margin-top: 20px;
    display: none;
}

.theory h2 {
    color: #00b4db;
    margin-bottom: 25px;
    font-size: 1.8rem;
    text-align: center;
}

.theory-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
}

.theory-card {
    background-color: rgba(0, 0, 0, 0.2);
    padding: 25px;
    border-radius: 12px;
    border-left: 4px solid #00b4db;
}

.theory-card h3 {
    color: #00b4db;
    margin-bottom: 15px;
    font-size: 1.3rem;
}

.theory-card p {
    margin-bottom: 10px;
    line-height: 1.6;
    color: #e0e0e0;
}

.formula {
    text-align: center;
    font-size: 1.5rem;
    margin: 15px 0;
    padding: 10px;
    background-color: rgba(0, 180, 219, 0.1);
    border-radius: 8px;
}

/* Utilities section */
.scroll-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    background: linear-gradient(to right, #00b4db, #0083b0);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 5px 15px rgba(0, 180, 219, 0.4);
    z-index: 100;
}

.scroll-to-top:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 180, 219, 0.6);
}

/* Animations */
@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

/* Responsive design */
@media (max-width: 1100px) {
    .main-content {
        flex-direction: column;
    }
    
    .simulation-container,
    .controls-and-calculator {
        min-width: 100%;
    }
    
    .commutator-3d,
    .commutator-controls-panel {
        min-width: 100%;
    }
    
    .startup-buttons {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .advanced-calculator {
        grid-template-columns: 1fr;
    }
    
    .calc-buttons {
        grid-column: span 1;
    }
    
    .result-display {
        grid-column: span 1;
    }
    
    .theory-content {
        grid-template-columns: 1fr;
    }
    
    .commutator-controls {
        flex-direction: column;
        gap: 10px;
    }
    
    .commutator-btn {
        width: 100%;
        justify-content: center;
    }
    
    .nav-buttons {
        flex-direction: column;
    }
    
    .nav-btn {
        width: 100%;
        justify-content: center;
    }
    
    .save-load-controls {
        flex-direction: column;
    }
    
    .save-load-btn {
        width: 100%;
    }
    
    .simulation-controls {
        flex-direction: column;
        gap: 10px;
    }
    
    .sim-btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .startup-title {
        font-size: 2.5rem;
    }
    
    .startup-btn {
        padding: 20px;
        min-height: 150px;
    }
    
    .scroll-to-top {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
        bottom: 20px;
        right: 20px;
    }
}