/* modals.css – Modals, Formulare, Detail, Rating (aus style.css ausgelagert, unveraendert) */

/* Modals */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 20px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.close {
    position: absolute;
    right: 20px;
    top: 20px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: #aaa;
    transition: color 0.3s ease;
}

.close:hover {
    color: #333;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

/* Form Styles */
form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

input, select, textarea {
    padding: 12px 15px;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    font-size: 16px;
    outline: none;
    transition: border-color 0.3s ease;
}

input:focus, select:focus, textarea:focus {
    border-color: #667eea;
}

.zutat-input {
    margin-bottom: 5px;
}

.form-buttons {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* Rezept-Formular: breites Modal mit Karten-Sektionen */
#rezept-modal .modal-content {
    max-width: 1220px;
}

#rezept-modal .modal-content h2 {
    color: #333;
    margin-bottom: 5px;
}

#rezept-form .form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1.1fr;
    gap: 16px;
    align-items: start;
}

#rezept-form .area-allgemein {
    grid-column: 1 / 3;
}

#rezept-form .area-zutaten {
    grid-column: 3;
    grid-row: 1 / 3;
    align-self: stretch;
}

#rezept-form .area-zutaten #zutaten-container {
    max-height: 430px;
    overflow-y: auto;
}

#rezept-form .form-section {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 14px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
}

#rezept-form .form-section > h3 {
    font-size: 1rem;
    color: #667eea;
    margin: 0;
    padding: 0;
    border: none;
}

#rezept-form .form-section > h3 span {
    font-weight: 400;
    color: #adb5bd;
    font-size: 0.85rem;
}

#rezept-form .field-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: #6c757d;
    margin-bottom: -9px;
}

#rezept-form .form-row {
    display: flex;
    gap: 12px;
}

#rezept-form .form-col {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#rezept-form .form-col-small {
    flex: 0 0 110px;
}

#rezept-form .form-col-kategorie {
    flex: 0 1 230px;
}

#rezept-form .dauer-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

#rezept-form .dauer-row input {
    width: 100%;
    min-width: 0;
}

#rezept-form .dauer-unit {
    font-size: 0.8rem;
    color: #6c757d;
    white-space: nowrap;
}

#rezept-modal .hidden-file {
    display: none;
}

#rezept-modal .image-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 32px 16px;
    border: 2px dashed #cfd4dc;
    border-radius: 12px;
    background: #fff;
    text-align: center;
    min-height: 220px;
}

#rezept-modal .image-empty.hidden {
    display: none;
}

#rezept-modal .image-empty i {
    font-size: 36px;
    color: #adb5bd;
}

#rezept-modal .image-empty small {
    color: #adb5bd;
    font-size: 0.8rem;
}

#rezept-modal .image-preview-area {
    align-items: center;
}

#rezept-modal .image-preview-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

#rezept-modal .image-preview-actions .hidden {
    display: none;
}

#rezept-form .area-anleitung {
    align-self: stretch;
}

#rezept-anleitung {
    flex: 1;
    min-height: 120px;
    resize: vertical;
}

#add-zutat {
    align-self: flex-start;
}

/* Rezept Detail - Verbesserte Darstellung */
#detail-modal .modal-content {
    max-width: 700px;
    padding: 40px;
}

/* Rezept Detail 3-Spalten-Layout (groß, fixiert) */
#detail-modal .modal-content {
    max-width: 1220px;
    height: min(90vh, 940px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#rezept-detail {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.rd-grid {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 300px 1fr 330px;
    gap: 24px;
}

.rd-meta,
.rd-zutaten,
.rd-side {
    min-height: 0;
    max-height: 100%;
}

.rd-meta {
    overflow-y: auto;
    scrollbar-width: thin;
}

.rd-zutaten {
    display: flex;
    flex-direction: column;
}

.rd-zutaten #detail-zutaten-liste {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-right: 6px;
}

.rd-meta {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
}

.rd-image {
    width: 100%;
    height: 230px;
    object-fit: cover;
    border-radius: 14px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.rd-image-empty {
    width: 100%;
    height: 230px;
    border-radius: 14px;
    background: #8a8f98;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 42px;
}

.rd-meta .rezept-titel {
    text-align: left;
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 0;
    font-size: 1.7rem;
}

.rd-meta-row {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #495057;
    font-weight: 500;
}

.rd-meta-row i {
    color: #667eea;
    width: 20px;
    text-align: center;
}

.rd-divider {
    border: none;
    border-top: 1px solid #e9ecef;
    margin: 6px 0;
}

.rd-portionen label {
    font-size: 0.95rem;
    color: #495057;
}

.rd-portionen input[type="range"] {
    width: 100%;
    margin-top: 8px;
    accent-color: #667eea;
    cursor: pointer;
}

.rd-avg {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: #333;
}

.rd-stars {
    color: #e6a800;
    font-size: 1.3rem;
    letter-spacing: 2px;
}

.rd-top-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 6px;
}

.rd-top-item {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.rd-top-stars {
    color: #e6a800;
    letter-spacing: 1px;
}

.rd-top-text {
    color: #6c757d;
    font-style: italic;
    word-break: break-word;
}

.rd-empty {
    color: #6c757d;
    font-size: 0.95rem;
}

.rd-zutaten h3,
.rd-side h3 {
    color: #667eea;
    margin: 0 0 12px;
    font-size: 1.2rem;
}

.rd-side {
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: 100%;
}

.rd-side .anleitung {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.rd-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 16px;
}

.rd-actions > .btn-primary {
    width: 100%;
}

.rd-actions-row {
    display: flex;
    gap: 10px;
}

.rd-actions-row button {
    flex: 1 1 0;
    min-width: 0;
}

.rezept-titel {
    color: #667eea;
    font-size: 2.2rem;
    margin-bottom: 15px;
    text-align: center;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 15px;
}

.rezept-meta-detail {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.rezept-meta-detail .kategorie,
.rezept-meta-detail .dauer {
    font-size: 14px;
    padding: 6px 15px;
    border-radius: 20px;
    font-weight: 600;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.rezept-meta-detail .kategorie {
    background: #667eea;
    color: white;
}

.rezept-meta-detail .dauer {
    background: #28a745;
    color: white;
}

#rezept-detail h3 {
    color: #667eea;
    margin-top: 30px;
    margin-bottom: 15px;
    font-size: 1.5rem;
    position: relative;
    padding-left: 20px;
}

#rezept-detail h3::before {
    content: '•';
    position: absolute;
    left: 0;
    color: #764ba2;
    font-size: 1.8rem;
    line-height: 1;
}

#detail-zutaten-liste {
    list-style: none;
    padding-left: 0;
    margin-bottom: 20px;
}

#detail-zutaten-liste li {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    padding: 10px 15px;
    margin-bottom: 8px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
}

#detail-zutaten-liste li::before {
    content: '✔';
    color: #28a745;
    font-weight: bold;
}

.anleitung {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    padding: 20px;
    border-radius: 15px;
    line-height: 1.8;
    font-size: 1.1rem;
    color: #555;
    white-space: pre-wrap;
}

.detail-actions {
    display: flex;
    justify-content: flex-end;
    gap: 15px;
    margin-top: 40px;
    border-top: 1px solid #e9ecef;
    padding-top: 20px;
}

/* Portionen Input im Detail Modal */
.portionen-input-container {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.portionen-input-container input[type="number"] {
    width: 80px;
    text-align: center;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 1.1rem;
}

.portionen-label {
    font-size: 1.1rem;
    color: #555;
}

.loading {
    text-align: center;
    color: #667eea;
    font-style: italic;
    margin: 10px 0;
}

.hidden {
    display: none;
}

/* Kalender Auswahlmodus */
.kalender-view.auswahl-modus .kalender-tag:not(.leer) {
    border: 2px solid #667eea;
    box-shadow: 0 0 10px rgba(102, 126, 234, 0.5);
}

.kalender-tag.auswaehlbar {
    cursor: pointer;
    transition: all 0.2s ease;
}

.kalender-tag.auswaehlbar:hover {
    background-color: #e6f0ff;
    transform: scale(1.02);
    z-index: 1;
}

/* Custom Alert/Confirm Modals */
.custom-modal-content {
    text-align: center;
    padding: 30px;
    max-width: 400px;
}

.custom-modal-content p {
    font-size: 1.2rem;
    margin-bottom: 25px;
    color: #333;
}

.custom-modal-content .btn-primary,
.custom-modal-content .btn-secondary {
    width: auto;
    margin: 0 10px;
}

.confirm-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
}

/* Kalender Tag Rezepte Modal */
#kalender-tag-rezepte-modal .modal-content {
    max-width: 500px;
}

#kalender-tag-rezepte-title {
    text-align: center;
    color: #667eea;
    margin-bottom: 25px;
    font-size: 1.8rem;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 15px;
}

#kalender-tag-rezepte-liste {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.kalender-tag-rezept-item {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    padding: 15px;
    border-radius: 10px;
    display: flex;
    flex-direction: column; /* Changed to column for better stacking of info and actions */
    gap: 10px;
}

.kalender-tag-rezept-item h4 {
    color: #333;
    font-size: 1.2rem;
    margin: 0;
}

.kalender-tag-rezept-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end; /* Align buttons to the right */
    flex-wrap: wrap; /* Allow buttons to wrap */
}

/* Rating Modal */
#rating-modal .modal-content {
    max-width: 450px;
    text-align: center;
}

#rating-modal-title {
    color: #667eea;
    margin-bottom: 15px;
}

#rating-rezept-name, #rating-datum {
    font-size: 1.1rem;
    margin-bottom: 5px;
    color: #555;
}

.rating-stars {
    font-size: 2.5rem;
    color: #ccc;
    cursor: pointer;
    margin: 20px 0;
}

.rating-stars .star {
    transition: color 0.2s ease;
}

.rating-stars .star.selected {
    color: #ffc107;
}

.rating-person-select {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 15px; /* Weniger Abstand wegen Kommentarfeld */
}

.rating-person-select label {
    font-weight: bold;
    color: #555;
}

.rating-person-select select {
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #ddd;
    background-color: #f9f9f9;
}

#rating-comment {
    width: 100%;
    margin-bottom: 20px;
    resize: vertical; /* Ermöglicht vertikales Resizing */
}

/* Meal Ratings Detail (always visible in kalender-tag-rezepte-modal) */
.meal-ratings-detail {
    font-size: 0.95rem;
    color: #333;
    background: #e9ecef;
    padding: 10px;
    border-radius: 8px;
    margin-top: 5px;
    text-align: left;
}

.meal-ratings-detail h4 {
    color: #667eea;
    margin-bottom: 5px;
    font-size: 1rem;
}

.meal-ratings-detail p {
    margin: 0;
    padding: 2px 0;
}

/* Ratings in Rezept Detail Modal */
.rezept-ratings-list {
    background: #e9ecef;
    padding: 15px;
    border-radius: 10px;
    margin-top: 15px;
}

.rezept-ratings-list p {
    margin-bottom: 5px;
    font-size: 1rem;
}

.rezept-ratings-list p:last-child {
    margin-bottom: 0;
}

/* Bild-Upload Zentrierung */
.image-upload-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.image-preview-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

#rezept-image-preview {
    max-width: 100%;
    max-height: 280px;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    object-fit: cover;
}

#delete-rezept-image-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s ease;
}

#delete-rezept-image-btn:hover {
    background: #c82333;
}

/* Tablet/iPad (bis 1024px): Grids zweispaltig statt dreispaltig */
@media (max-width: 1024px) {
    #rezept-modal .modal-content {
        max-width: 96vw;
    }

    #rezept-form .form-grid {
        grid-template-columns: 1fr 1fr;
    }

    #rezept-form .area-allgemein,
    #rezept-form .area-zutaten {
        grid-column: 1 / 3;
    }

    #detail-modal .modal-content {
        max-width: 96vw;
    }

    .rd-grid {
        grid-template-columns: 1fr 1fr;
    }

    .rd-meta {
        grid-column: 1 / 3;
    }
}

/* iPhone (bis 600px): Detail-Ansicht einspaltig, normaler Modal-Scroll, kein Bearbeiten */
@media (max-width: 600px) {
    #detail-modal .modal-content {
        max-width: 96vw;
        height: auto;
        max-height: 92vh;
        overflow-y: auto;
        padding: 20px;
    }

    .rd-grid {
        grid-template-columns: 1fr;
    }

    #rezept-detail {
        display: block;
    }

    .rd-grid {
        display: block;
    }

    .rd-grid > * + * {
        margin-top: 20px;
    }

    .rd-meta,
    .rd-zutaten,
    .rd-side {
        max-height: none;
        overflow: visible;
    }

    .rd-meta {
        grid-column: auto;
    }

    .rd-image,
    .rd-image-empty {
        height: 180px;
    }

    .rd-zutaten #detail-zutaten-liste {
        overflow: visible;
    }

    .rd-side .anleitung {
        overflow: visible;
        flex: none;
    }

    .rd-grid .rd-btn-bearbeiten {
        display: none;
    }
}
