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

body {
    font-family: 'Roboto', 'Segoe UI', 'Arial', sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f0f2f5;
    transition: all 0.3s ease;
}

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

header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px 0;
    background: linear-gradient(135deg, #3498db, #2c3e50);
    color: white;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

h1 {
    margin-bottom: 10px;
    color: white;
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: 1px;
}

h2 {
    margin-bottom: 15px;
    color: #2c3e50;
    font-weight: 600;
    position: relative;
    padding-bottom: 8px;
}

h2::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 50px;
    height: 3px;
    background-color: #3498db;
    border-radius: 3px;
}

/* Button Styles */
.btn {
    padding: 10px 18px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
}

.btn:active {
    transform: translateY(2px);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.btn-primary {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #2980b9, #1f6aa6);
    box-shadow: 0 4px 8px rgba(52, 152, 219, 0.3);
}

.btn-success {
    background: linear-gradient(135deg, #2ecc71, #27ae60);
    color: white;
}

.btn-success:hover {
    background: linear-gradient(135deg, #27ae60, #219a52);
    box-shadow: 0 4px 8px rgba(46, 204, 113, 0.3);
}

.btn-danger {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
}

.btn-danger:hover {
    background: linear-gradient(135deg, #c0392b, #a33025);
    box-shadow: 0 4px 8px rgba(231, 76, 60, 0.3);
}

/* Layout - Optimized for vertical flow */
main {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.main-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

@media (min-width: 992px) {
    main {
        height: calc(100vh - 180px); /* Account for header and footer */
        min-height: 500px;
        overflow-y: auto;
    }
}

/* Wagon Selection - Optimized and more compact, directly under train composition */
.wagon-selection {
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.05);
    padding: 15px;
    margin-bottom: 15px;
    transition: all 0.3s ease;
    border-left: 4px solid #3498db;
}

.wagon-selection:hover {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.wagon-types {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 15px;
}

.wagon-type {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    transition: all 0.3s ease;
    background-color: #ffffff;
    position: relative;
    cursor: grab;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.wagon-type:hover {
    border-color: #3498db;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(52, 152, 219, 0.2);
}

.wagon-type:active {
    cursor: grabbing;
}

.wagon-type span {
    margin-top: 12px;
    font-size: 13px;
    font-weight: 500;
    text-align: center;
    margin-bottom: 10px;
    color: #555;
}

.add-wagon-btn {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.add-wagon-btn:hover {
    background: linear-gradient(135deg, #2980b9, #1f6aa6);
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(52, 152, 219, 0.3);
}

.add-wagon-btn:active {
    transform: scale(0.95);
}

/* Wagon Icons - Smaller, more compact symbols */
.wagon-icon {
    width: 80px;
    height: 40px;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #f9f9f9;
    border: 2px solid #555;
    border-radius: 4px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Locomotive (hexagonal shape) - Smaller */
.locomotive {
    width: 65px;
    height: 40px;
    background-color: #f9f9f9;
    position: relative;
    border: 2px solid #555;
    clip-path: polygon(15% 0%, 85% 0%, 100% 50%, 85% 100%, 15% 100%, 0% 50%);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Wagon with passage (horizontal line) - Enhanced */
.seating, .couchette, .sleeping {
    background-color: #f9f9f9;
    position: relative;
}

.seating::before, .couchette::before, .sleeping::before {
    content: "";
    position: absolute;
    width: 70%;
    height: 3px;
    background-color: #555;
    top: 50%;
    left: 15%;
    border-radius: 2px;
}

/* Wagon without passage - Enhanced base styles */
.seating-no-passage, .couchette-no-passage, .sleeping-no-passage {
    background-color: #f9f9f9;
    position: relative;
}

.seating-no-passage::before, .couchette-no-passage::before, .sleeping-no-passage::before {
    content: "";
    position: absolute;
    width: 70%;
    height: 3px;
    background-color: #555;
    top: 50%;
    left: 15%;
    border-radius: 2px;
}

/* Default style for wagon without passage (L-shaped with block on right) - Enhanced */
.seating-no-passage::after, .couchette-no-passage::after, .sleeping-no-passage::after {
    content: "";
    position: absolute;
    width: 3px;
    height: 60%;
    background-color: #555;
    top: 20%;
    right: 15%;
    border-radius: 2px;
}

/* Special style for wagon without passage behind locomotive (L-shaped with block on left) - Enhanced */
.seating-no-passage.after-locomotive::after,
.couchette-no-passage.after-locomotive::after,
.sleeping-no-passage.after-locomotive::after {
    left: 15%;
    right: auto;
}

/* Different colors for different wagon types - Enhanced with gradients */
.seating, .seating-no-passage {
    border-color: #3498db;
    background: linear-gradient(to bottom, #f5f9fc, #e6f2fa);
}

.couchette, .couchette-no-passage {
    border-color: #e67e22;
    background: linear-gradient(to bottom, #fdf6f0, #fae9d9);
}

.sleeping, .sleeping-no-passage {
    border-color: #9b59b6;
    background: linear-gradient(to bottom, #f9f0fa, #f0e0f6);
}

/* Drag handle indicator */
.wagon-type::before {
    content: "⋮⋮";
    position: absolute;
    top: 5px;
    left: 5px;
    font-size: 14px;
    color: #aaa;
    cursor: grab;
}

.wagon-type:hover::before {
    color: #3498db;
}

/* Train Composition */
.train-composition {
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.05);
    padding: 20px;
    transition: all 0.3s ease;
    border-left: 4px solid #3498db; /* Consistent blue accent */
    margin-bottom: 20px;
}

.train-composition:hover {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.train-composition h2 {
    color: #2c3e50;
    font-size: 1.5rem;
}

.train-composition h2::after {
    background-color: #3498db;
    width: 70px;
}

.composition-container {
    min-height: 150px;
    border: 2px dashed #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    background-color: #f9f9f9;
    transition: all 0.3s ease;
    cursor: pointer; /* Indicate it's clickable */
    position: relative;
}

.composition-container::after {
    content: 'Klicken Sie auf eine leere Stelle, um die Auswahl aufzuheben';
    position: absolute;
    bottom: -25px;
    right: 10px;
    font-size: 12px;
    color: #7f8c8d;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.composition-container:hover::after {
    opacity: 1;
}

.composition-container.drag-over {
    border-color: #3498db;
    background-color: rgba(52, 152, 219, 0.05);
    box-shadow: inset 0 0 15px rgba(52, 152, 219, 0.1);
}

.train {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 10px 0;
    min-height: 90px;
    align-items: center;
    scrollbar-width: thin;
    scrollbar-color: #bbb #f0f0f0;
}

.train::-webkit-scrollbar {
    height: 8px;
}

.train::-webkit-scrollbar-track {
    background: #f0f0f0;
    border-radius: 4px;
}

.train::-webkit-scrollbar-thumb {
    background-color: #bbb;
    border-radius: 4px;
}

.train::-webkit-scrollbar-thumb:hover {
    background-color: #999;
}

.placeholder {
    width: 100%;
    text-align: center;
    color: #999;
    padding: 30px;
    font-style: italic;
    background-color: rgba(0, 0, 0, 0.02);
    border-radius: 8px;
}

.wagon {
    margin-right: 15px;
    position: relative;
    cursor: grab;
    transition: all 0.3s ease;
    transform-origin: center bottom;
}

.wagon:active {
    cursor: grabbing;
}

.wagon:hover {
    transform: translateY(-5px);
}

.wagon.selected {
    transform: translateY(-5px) scale(1.05);
}

.wagon.selected .wagon-icon {
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.3), 0 5px 15px rgba(0, 0, 0, 0.2);
}

.wagon-number {
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #2c3e50, #34495e);
    color: white;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    z-index: 1;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: all 0.2s ease;
}

.wagon-number:hover {
    background: linear-gradient(135deg, #34495e, #2c3e50);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
    transform: translateX(-50%) scale(1.05);
}

.wagon-number:hover::after {
    content: '✏️';
    font-size: 10px;
    margin-left: 4px;
    opacity: 0.8;
}

.wagon-number-input {
    background: white;
    color: #2c3e50;
    border: 2px solid #3498db;
    border-radius: 8px;
    padding: 2px 4px;
    font-size: 12px;
    font-weight: 600;
    width: 40px;
    text-align: center;
    outline: none;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.3);
}

@keyframes numberUpdatedAnimation {
    0% { transform: translateX(-50%) scale(1); }
    50% { transform: translateX(-50%) scale(1.2); background: linear-gradient(135deg, #27ae60, #2ecc71); }
    100% { transform: translateX(-50%) scale(1); }
}

.number-updated {
    animation: numberUpdatedAnimation 0.5s ease;
}

.wagon-features {
    position: absolute;
    bottom: -15px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 8px;
}

.feature-icon {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.feature-icon:hover {
    transform: scale(1.2);
}

.feature-icon.AbteilWL {
    background: linear-gradient(135deg, #9b59b6, #8e44ad);
}

.feature-icon.AbteilCC {
    background: linear-gradient(135deg, #e67e22, #d35400);
}

.feature-icon.AbteilBistro {
    background: linear-gradient(135deg, #3498db, #2980b9);
}

/* Delete button for wagons */
.delete-wagon {
    position: absolute;
    top: -12px;
    right: -12px;
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 2;
    font-size: 12px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.delete-wagon:hover {
    transform: scale(1.1);
    background: linear-gradient(135deg, #c0392b, #a33025);
    box-shadow: 0 3px 8px rgba(231, 76, 60, 0.3);
}

/* Type selector for wagons - Improved dropdown style */
.wagon-type-selector {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    display: none;
    background-color: white;
    border-radius: 6px;
    padding: 5px;
    z-index: 3;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
    animation: fadeIn 0.2s ease;
    margin-top: 5px;
    width: auto;
    white-space: nowrap;
}

.wagon-type-selector:before {
    content: '';
    position: absolute;
    top: -5px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 6px solid white;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateX(-50%) translateY(-5px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.wagon.selected .wagon-type-selector {
    display: flex;
    justify-content: center;
    gap: 5px;
}

.type-option {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    color: white;
    transition: all 0.2s ease;
}

.type-option:hover {
    transform: scale(1.05);
    filter: brightness(1.1);
}

.type-option.seating {
    background: linear-gradient(135deg, #3498db, #2980b9);
}

.type-option.couchette {
    background: linear-gradient(135deg, #e67e22, #d35400);
}

.type-option.sleeping {
    background: linear-gradient(135deg, #9b59b6, #8e44ad);
}

.type-option.selected {
    box-shadow: 0 0 0 2px rgba(44, 62, 80, 0.5);
}

/* Drag handle for wagons */
.wagon::before {
    content: "⋮⋮";
    position: absolute;
    top: 50%;
    left: -15px;
    transform: translateY(-50%);
    font-size: 14px;
    color: #aaa;
    cursor: grab;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.wagon:hover::before {
    opacity: 1;
    color: #3498db;
}

/* Configuration Popup */
.config-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s cubic-bezier(0.215, 0.61, 0.355, 1);
}

.config-popup.show {
    display: flex;
    opacity: 1;
}

.config-popup-content {
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.215, 0.61, 0.355, 1);
    animation: popupSlideUp 0.3s forwards cubic-bezier(0.215, 0.61, 0.355, 1);
}

@keyframes popupSlideUp {
    from {
        transform: translateY(20px);
        opacity: 0.8;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.config-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
}

.config-popup-header h2 {
    margin: 0;
    color: #2c3e50;
    font-size: 1.5rem;
}

.config-popup-header h2::after {
    display: none;
}

.close-popup {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: #7f8c8d;
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.close-popup:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: #e74c3c;
}

.configuration-form {
    padding: 15px;
    border-radius: 8px;
    background-color: #f9f9f9;
    border: 2px solid #e0e0e0;
    transition: all 0.4s cubic-bezier(0.215, 0.61, 0.355, 1); /* Smooth easing */
    animation: softFadeIn 0.5s forwards cubic-bezier(0.215, 0.61, 0.355, 1);
}

@keyframes softFadeIn {
    0% {
        opacity: 0;
        transform: translateY(10px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.configuration-form:hover {
    border-color: #3498db;
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.1);
}

.configuration-form p {
    color: #7f8c8d;
    font-style: italic;
    text-align: center;
    padding: 15px;
    background-color: rgba(52, 152, 219, 0.05);
    border-radius: 6px;
    margin-bottom: 15px;
}

.form-group {
    margin-bottom: 15px;
    position: relative;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: #2c3e50;
    font-size: 0.9rem;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 8px 10px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    background-color: white;
}

.form-group input:focus,
.form-group select:focus {
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
    outline: none;
}

.config-row {
    display: flex;
    gap: 10px;
}

.config-col {
    flex: 1;
}

.number-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.number-row input {
    flex: 1;
}

.checkbox-group {
    display: flex;
    align-items: center;
    cursor: pointer;
    white-space: nowrap;
}

.checkbox-group input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin-right: 6px;
    cursor: pointer;
    accent-color: #3498db;
}

.checkbox-group label {
    margin-bottom: 0;
    cursor: pointer;
    font-size: 0.85rem;
}

.features-checkboxes {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    padding: 10px;
    background-color: white;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.features-checkboxes div {
    display: flex;
    align-items: center;
}

.features-checkboxes input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin-right: 6px;
    cursor: pointer;
    accent-color: #3498db;
}

.features-checkboxes label {
    font-size: 0.85rem;
}

.form-actions {
    margin-top: 25px;
    display: flex;
    justify-content: flex-end;
}

.composition-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
    align-items: center;
}

.left-actions {
    display: flex;
    gap: 15px;
    align-items: center;
}

/* Presets Button */
#presets-button {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    box-shadow: 0 6px 15px rgba(46, 204, 113, 0.3);
    transition: all 0.3s ease;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    position: relative;
    overflow: hidden;
    z-index: 1;
}

#presets-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, rgba(255,255,255,0.2), transparent);
    transition: all 0.6s ease;
    z-index: -1;
}

#presets-button:hover::before {
    left: 100%;
}

#presets-button:hover {
    background: linear-gradient(135deg, #2ecc71, #27ae60);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(46, 204, 113, 0.4);
}

#presets-button:active {
    transform: translateY(1px);
    box-shadow: 0 3px 8px rgba(46, 204, 113, 0.3);
}

/* Presets Popup */
.presets-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s cubic-bezier(0.215, 0.61, 0.355, 1);
    backdrop-filter: blur(3px);
}

.presets-popup.show {
    display: flex;
    opacity: 1;
}

.presets-popup-content {
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.215, 0.61, 0.355, 1);
    animation: popupSlideUp 0.3s forwards cubic-bezier(0.215, 0.61, 0.355, 1);
}

.presets-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
}

.presets-popup-header h2 {
    margin: 0;
    color: #2c3e50;
    font-size: 1.5rem;
}

.presets-popup-header h2::after {
    display: none;
}

.close-presets-popup {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: #7f8c8d;
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.close-presets-popup:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: #e74c3c;
}

.presets-container {
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 12px;
    background-color: #f9f9f9;
}

.presets-list {
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 12px;
    scrollbar-width: thin;
    scrollbar-color: #bbb #f0f0f0;
}

.presets-list::-webkit-scrollbar {
    width: 8px;
}

.presets-list::-webkit-scrollbar-track {
    background: #f0f0f0;
    border-radius: 4px;
}

.presets-list::-webkit-scrollbar-thumb {
    background-color: #bbb;
    border-radius: 4px;
}

.presets-list::-webkit-scrollbar-thumb:hover {
    background-color: #999;
}

.preset-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid #e0e0e0;
    transition: all 0.3s ease;
    background-color: white;
    border-radius: 6px;
    margin-bottom: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.preset-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1);
}

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

.preset-name {
    font-weight: 600;
    color: #2c3e50;
}

.preset-actions {
    display: flex;
    gap: 10px;
}

.preset-actions button {
    background: none;
    border: none;
    cursor: pointer;
    color: #7f8c8d;
    transition: all 0.3s ease;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.preset-actions button:hover {
    color: #2c3e50;
    background-color: rgba(0, 0, 0, 0.05);
}

.preset-actions .load-preset:hover {
    color: #3498db;
    background-color: rgba(52, 152, 219, 0.1);
}

.preset-actions .rename-preset:hover {
    color: #f39c12;
    background-color: rgba(243, 156, 18, 0.1);
}

.preset-actions .delete-preset:hover {
    color: #e74c3c;
    background-color: rgba(231, 76, 60, 0.1);
}

.presets-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 15px;
}

/* Footer */
footer {
    margin-top: 50px;
    text-align: center;
    color: #7f8c8d;
    font-size: 14px;
    padding: 20px 0;
    border-top: 1px solid #e0e0e0;
    background: linear-gradient(to bottom, #f9f9f9, #f0f2f5);
    border-radius: 0 0 10px 10px;
}

/* Drag and Drop Styles */
.sortable-ghost {
    opacity: 0.4;
    transform: scale(1.05);
}

.sortable-chosen {
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    z-index: 10;
}

.sortable-drag {
    opacity: 0.9;
    transform: rotate(1deg);
    cursor: grabbing;
}

/* Animation for newly added or moved wagons */
@keyframes waggleAnimation {
    0% { transform: translateY(0); }
    25% { transform: translateY(-10px) rotate(-2deg); }
    50% { transform: translateY(-5px) rotate(2deg); }
    75% { transform: translateY(-8px) rotate(-1deg); }
    100% { transform: translateY(0) rotate(0); }
}

.just-added, .just-moved {
    animation: waggleAnimation 0.5s ease;
}

/* Dragging styles */
.wagon-type.dragging {
    opacity: 0.6;
    transform: scale(0.95);
}

.train.dragging {
    background-color: rgba(52, 152, 219, 0.05);
}

.composition-container.drag-over {
    border-color: #3498db;
    background-color: rgba(52, 152, 219, 0.1);
    box-shadow: inset 0 0 20px rgba(52, 152, 219, 0.2);
    transition: all 0.2s ease;
}

/* Error message for invalid placement */
.error-message {
    color: #e74c3c;
    font-size: 14px;
    margin-top: 15px;
    text-align: center;
    padding: 12px;
    background-color: #fadbd8;
    border-radius: 8px;
    display: none;
    box-shadow: 0 3px 10px rgba(231, 76, 60, 0.1);
    border-left: 4px solid #e74c3c;
    animation: fadeIn 0.3s ease;
}

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

/* Custom Alert Popup */
.alert-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s cubic-bezier(0.215, 0.61, 0.355, 1);
    backdrop-filter: blur(3px);
}

.alert-popup.show {
    display: flex;
    opacity: 1;
}

.alert-popup-content {
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 500px;
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.215, 0.61, 0.355, 1);
    animation: popupSlideUp 0.3s forwards cubic-bezier(0.215, 0.61, 0.355, 1);
    overflow: hidden;
}

.alert-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
}

.alert-popup-header h2 {
    margin: 0;
    color: white;
    font-size: 1.5rem;
}

.alert-popup-header h2::after {
    display: none;
}

.close-alert-popup {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.close-alert-popup:hover {
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
}

.alert-popup-body {
    padding: 25px;
    display: flex;
    align-items: center;
    gap: 20px;
}

.alert-icon {
    font-size: 2.5rem;
    color: #e74c3c;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    flex-shrink: 0;
}

.alert-popup-body p {
    margin: 0;
    font-size: 1.1rem;
    color: #2c3e50;
    line-height: 1.5;
}

.alert-popup-footer {
    padding: 15px 25px;
    display: flex;
    justify-content: flex-end;
    gap: 15px;
    border-top: 1px solid #e0e0e0;
    background-color: #f9f9f9;
}

.alert-popup.warning .alert-popup-header {
    background: linear-gradient(135deg, #f39c12, #e67e22);
}

.alert-popup.warning .alert-icon {
    color: #f39c12;
}

.alert-popup.critical .alert-popup-header {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
}

.alert-popup.critical .alert-icon {
    color: #e74c3c;
}

.alert-popup.info .alert-popup-header {
    background: linear-gradient(135deg, #3498db, #2980b9);
}

.alert-popup.info .alert-icon {
    color: #3498db;
}

/* Bistro Selection Popup Styles */
.bistro-selection {
    width: 100%;
}

.bistro-selection p {
    margin-bottom: 15px;
    text-align: center;
    font-weight: 500;
}

.bistro-wagons {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.bistro-wagon-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    background-color: white;
}

.bistro-wagon-option:hover {
    border-color: #3498db;
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(52, 152, 219, 0.2);
}

.bistro-wagon-option .wagon-icon {
    margin-bottom: 10px;
}

.bistro-wagon-option span {
    font-size: 0.9rem;
    font-weight: 500;
    color: #2c3e50;
    text-align: center;
}

.bistro-no-option {
    text-align: center;
    margin-top: 10px;
    padding-top: 15px;
    border-top: 1px solid #e0e0e0;
}

.bistro-no-option button {
    margin-left: 5px;
}

/* Modal for preset naming */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    display: none;
    backdrop-filter: blur(3px);
    transition: all 0.3s ease;
}

.modal-overlay.show {
    display: flex;
    animation: fadeIn 0.3s ease;
}

.modal {
    background-color: white;
    border-radius: 12px;
    padding: 25px;
    width: 450px;
    max-width: 90%;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
    transform: translateY(20px);
    animation: slideUp 0.3s ease forwards;
}

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

.modal-header {
    margin-bottom: 20px;
    border-bottom: 2px solid #f0f2f5;
    padding-bottom: 15px;
}

.modal-header h3 {
    margin: 0;
    color: #2c3e50;
    font-size: 1.5rem;
    font-weight: 600;
}

.modal-body {
    margin-bottom: 25px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 15px;
    border-top: 2px solid #f0f2f5;
    padding-top: 15px;
}