/* --- Allgemeine Stile & Animationen --- */
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; background-color: #f4f4f9; color: #333; display: flex; justify-content: center; align-items: flex-start; min-height: 100vh; margin: 0; padding: 20px 0; }
.container { background: white; padding: 2rem; border-radius: 12px; box-shadow: 0 4px 20px rgba(0,0,0,0.08); text-align: center; max-width: 1200px; width: 90%; animation: fadeIn 0.6s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
h1 { color: #222; margin-bottom: 0.5rem; }
p { color: #666; line-height: 1.6; }

/* --- Upload-Bereich --- */
#upload-section { margin-top: 1.5rem; }
.drop-zone { border: 2px dashed #ccc; border-radius: 8px; padding: 20px 40px; cursor: pointer; transition: background-color 0.3s, border-color 0.3s; max-width: 400px; margin: 0 auto; text-align: center; }
.drop-zone:hover, .drop-zone.dragover { background-color: #f0f8ff; border-color: #007bff; }
.drop-zone .upload-icon { width: 40px; height: 40px; margin-bottom: 10px; opacity: 0.5; }
#submit-btn { background-color: #007bff; color: white; border: none; padding: 12px 25px; border-radius: 6px; cursor: pointer; font-size: 16px; font-weight: 500; margin-top: 20px; transition: background-color 0.2s; }
#submit-btn:hover:not(:disabled) { background-color: #0056b3; }
#submit-btn:disabled { background-color: #a0cfff; cursor: not-allowed; }
.hidden { display: none !important; }

/* --- Ladeanzeige --- */
#loader { margin-top: 30px; font-size: 1.1em; color: #555; }
.spinner { border: 4px solid rgba(0, 0, 0, 0.1); width: 36px; height: 36px; border-radius: 50%; border-left-color: #007bff; animation: spin 1s ease infinite; margin: 0 auto 15px; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* --- Ergebnis-Bereich (Zweispalten-Layout) --- */
#result-section { margin-top: 2rem; text-align: left; animation: fadeIn 0.5s ease-out 0.2s both; }
@media (min-width: 992px) {
    #result-section { display: flex; gap: 40px; align-items: flex-start; }
    #comparison-area, #customization-area { flex: 1; }
}
#comparison-area h2, #customization-area h2 { text-align: center; margin-bottom: 1rem; font-size: 1.2rem; color: #333; }

/* Toolbar */
.preview-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; padding: 0.5rem; background: #f7f7f7; border-radius: 6px; }
.toolbar-group { display: flex; align-items: center; gap: 10px; }
.toolbar-group button { background: #e9ecef; border: 1px solid #ced4da; border-radius: 4px; padding: 5px 10px; cursor: pointer; font-size: 14px; }
.toolbar-group button:hover { background: #dee2e6; }
#zoom-level { font-size: 14px; font-weight: bold; min-width: 45px; text-align: center; }

/* --- Before/After Slider (STABILISIERT) --- */
.slider-container {
    position: relative;
    display: inline-block; /* Wichtig für korrekte Größenberechnung */
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    cursor: col-resize;
    width: 100%; /* Responsiv */
}
.slider-container img, .after-image-container {
    display: block; /* Entfernt Lücken unter Bildern */
    max-width: 100%;
    height: auto;
}
.after-image-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 50%;
    height: 100%;
    overflow: hidden;
}
.slider-handle {
    position: absolute;
    top: 0;
    left: 50%;
    width: 4px;
    height: 100%;
    background: white;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
    transform: translateX(-50%);
    user-select: none; /* Verhindert Textauswahl beim Ziehen */
}
.slider-handle::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 30px;
    height: 30px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

/* --- Anpassungs-Bereich --- */
.preview-container { text-align: center; margin-bottom: 1.5rem; position: relative; overflow: hidden; border-radius: 8px; }
#final-preview-canvas { max-width: 100%; height: auto; border: 1px solid #ddd; border-radius: 8px; cursor: grab; display: block; margin: 0 auto; }
#final-preview-canvas:active { cursor: grabbing; }

.options-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 1.5rem; }
.option-group { display: flex; flex-direction: column; gap: 8px; }
.option-group.full-width { grid-column: 1 / -1; }
.option-group label { font-weight: 500; color: #555; }
.option-group select, .option-group input[type="color"] { padding: 8px 12px; border: 1px solid #ccc; border-radius: 4px; font-size: 14px; }
#bg-color-picker { width: 100%; height: 38px; cursor: pointer; }

/* Effekt-Controls */
.effect-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.effect-controls input[type="range"] { flex-grow: 1; }
.effect-controls span { min-width: 25px; text-align: center; font-size: 12px; color: #666; }

/* Action Buttons */
.action-buttons { display: flex; gap: 15px; justify-content: center; }
.action-buttons button, .action-buttons a { display: inline-flex; align-items: center; justify-content: center; gap: 8px; flex: 1; padding: 12px 20px; border-radius: 6px; font-size: 16px; font-weight: 500; text-decoration: none; cursor: pointer; transition: all 0.2s; border: none; }
.download-button { background-color: #28a745; color: white; }
.download-button:hover { background-color: #218838; }
.copy-button { background-color: #6c757d; color: white; }
.copy-button:hover { background-color: #5a6268; }
.copy-button.copied { background-color: #007bff; }
.action-buttons svg { width: 20px; height: 20px; }

/* Modal */
.modal { position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.5); display: flex; justify-content: center; align-items: center; animation: fadeIn 0.3s; }
.modal-content { background-color: #fefefe; padding: 2rem; border-radius: 8px; width: 90%; max-width: 500px; position: relative; animation: slideIn 0.3s; }
@keyframes slideIn { from { transform: translateY(-50px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.close-btn { color: #aaa; position: absolute; top: 10px; right: 20px; font-size: 28px; font-weight: bold; cursor: pointer; }
.close-btn:hover { color: #000; }
.modal h2 { margin-top: 0; }
.modal ul { list-style-type: none; padding: 0; }
.modal li { margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; }
.modal kbd { background-color: #f1f1f1; border: 1px solid #ccc; border-radius: 4px; padding: 3px 6px; font-family: monospace; }

/* Historie */
#history-section { margin-top: 2rem; animation: fadeIn 0.5s ease-out; }
#history-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 15px; }
.history-item { border: 1px solid #ddd; border-radius: 8px; overflow: hidden; cursor: pointer; transition: transform 0.2s, box-shadow 0.2s; }
.history-item:hover { transform: scale(1.05); box-shadow: 0 4px 10px rgba(0,0,0,0.1); }
.history-item img { width: 100%; height: 120px; object-fit: cover; display: block; }