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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    padding: 40px;
}

h1 {
    color: #333;
    margin-bottom: 10px;
    text-align: center;
    font-size: 2.5em;
}

h2 {
    color: #667eea;
    margin-bottom: 30px;
    text-align: center;
    font-size: 1.8em;
}

p {
    color: #666;
    margin-bottom: 20px;
    text-align: center;
    line-height: 1.6;
}

.motor-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin: 30px 0;
}

.motor-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    border-radius: 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 150px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.motor-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.motor-card h3 {
    font-size: 1.5em;
    margin-bottom: 10px;
}

.motor-card p {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.9em;
    margin: 0;
}

form {
    margin-top: 30px;
}

fieldset {
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 30px;
    background-color: #f9f9f9;
}

legend {
    color: #667eea;
    font-weight: bold;
    font-size: 1.1em;
    padding: 0 10px;
}

fieldset p {
    text-align: left;
    margin-bottom: 15px;
}

.checkbox-group,
.radio-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

label {
    display: flex;
    align-items: center;
    color: #333;
    cursor: pointer;
    font-size: 1em;
}

input[type="checkbox"],
input[type="radio"] {
    margin-right: 10px;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-family: inherit;
    font-size: 1em;
    resize: vertical;
    transition: border-color 0.3s;
}

textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 5px rgba(102, 126, 234, 0.3);
}

button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 40px;
    border: none;
    border-radius: 8px;
    font-size: 1.1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    display: block;
    margin: 30px auto 0;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

button:active {
    transform: translateY(0);
}

.success-message {
    background-color: #d4edda;
    color: #155724;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 20px;
    border: 1px solid #c3e6cb;
}

.error-message {
    background-color: #f8d7da;
    color: #721c24;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 20px;
    border: 1px solid #f5c6cb;
}

@media (max-width: 768px) {
    .container {
        padding: 20px;
    }

    h1 {
        font-size: 2em;
    }

    h2 {
        font-size: 1.5em;
    }

    .motor-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 15px;
    }

    .motor-card {
        padding: 20px;
        min-height: 120px;
    }

    .checkbox-group,
    .radio-group {
        grid-template-columns: 1fr;
    }
}

/* === Back to Home Button === */
.back-button {
    position: fixed;
    top: 20px;
    left: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: bold;
    font-size: 1em;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    z-index: 1000;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.back-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

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

/* === Auth Buttons (Top Right) === */
.auth-container {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 12px;
    z-index: 1000;
}

.auth-button {
    padding: 10px 20px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: bold;
    font-size: 0.95em;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    border: none;
}

.auth-button.login {
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
}

.auth-button.login:hover {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.auth-button.register {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: 2px solid transparent;
}

.auth-button.register:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

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

/* === Tools Section (Index Page) === */
.tools-section {
    margin-top: 40px;
    padding-top: 30px;
    border-top: 2px solid #eee;
}

.tools-section h2 {
    margin-bottom: 20px;
}

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

.tool-card {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    color: white;
    padding: 30px;
    border-radius: 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 180px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
}

.tool-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.tool-icon {
    font-size: 3em;
    margin-bottom: 15px;
}

.tool-card h3 {
    font-size: 1.3em;
    margin-bottom: 10px;
}

.tool-card p {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.9em;
    margin: 0;
    line-height: 1.4;
}

/* ================================================
   DYNAMIC ELEMENT STYLES (from main.js)
   ================================================ */

/* === Modal Styles === */
.modal-show {
    display: flex !important;
}

.modal-hide {
    display: none !important;
}

/* === Auth UI States === */
.auth-buttons-show {
    display: flex !important;
}

.auth-buttons-hide {
    display: none !important;
}

.user-info-show {
    display: flex !important;
}

.user-info-hide {
    display: none !important;
}

/* === Motor Card States === */
.motor-card-enabled {
    opacity: 1;
    pointer-events: auto;
    filter: none;
    cursor: pointer;
}

.motor-card-disabled {
    opacity: 0.4;
    pointer-events: none;
    filter: grayscale(100%);
    cursor: not-allowed;
}

/* === Versioned Result Fieldsets === */
.versioned-result {
    margin-top: 20px;
    border: 2px solid #4CAF50;
    padding: 15px;
    border-radius: 8px;
    background-color: #f9fff9;
}

.versioned-result legend {
    color: #4CAF50;
    font-weight: bold;
    font-size: 1.2em;
}

.versioned-result label {
    display: block;
    margin-top: 10px;
    font-weight: bold;
    color: #333;
}

.versioned-result textarea {
    width: 100%;
    margin-top: 5px;
}

/* === History Card Styles === */
.history-card {
    background: #f9f9f9;
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.history-card:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
    border-color: #667eea;
}

.history-card h4 {
    color: #667eea;
    margin-bottom: 8px;
    font-size: 1.1em;
}

.history-card p {
    color: #666;
    font-size: 0.9em;
    margin: 4px 0;
    text-align: left;
}

.history-card-buttons {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.history-card-buttons button {
    flex: 1;
    padding: 8px 16px;
    font-size: 0.9em;
    margin: 0;
}

.history-load-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.history-delete-btn {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
}

/* === Loading Overlay === */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.loading-content {
    background: white;
    padding: 40px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.loading-spinner {
    border: 6px solid #f3f3f3;
    border-top: 6px solid #667eea;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.loading-text {
    font-size: 1.2em;
    color: #333;
    font-weight: bold;
}