/**
 * Planner v4 - Layout Styles
 * 
 * Layout-Struktur (gemäß HTML-Tabelle im Design-Dokument):
 * - Info-Kasten (planner__info): Links oben, nimmt oberes Drittel der Höhe ein, halbe Breite
 * - Suche (planner__search): Rechts oben, kleines Input-Feld
 * - Kalender (planner__calendar): Rechts, nimmt gesamte Höhe ein (beginnt bei Suche)
 * - Stapel (planner__stack): Links unten, 60px breit
 * - Kartenansicht (planner__map): Mitte unten, neben Stapel
 */

/* Hauptcontainer für den Planner - CSS Grid Layout */
.planner-v4 {
    display: grid;
    grid-template-columns: 1fr 1fr; /* Zwei Spalten: Links (Info/Stapel/Karte), Rechts (Suche/Kalender) */
    grid-template-rows: auto 1fr; /* Zwei Zeilen: Oben (Info/Suche), Unten (Stapel/Karte) */
    gap: 1rem;
    width: 100%;
    height: 100%;
    min-height: calc(100vh - 400px); /* Mindesthöhe abzüglich Header/Footer */
}

/* Obere Zeile: Info-Kasten links, Suche rechts */
.planner-v4__top-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    grid-column: 1 / -1; /* Spannt beide Spalten */
    grid-row: 1; /* Erste Zeile */
    min-height: 20vh; /* Etwa ein Drittel der Viewport-Höhe */
}

/* Info-Kasten - links oben */
.planner__info {
    background: var(--surface-color);
    border-radius: var(--border-radius, 8px);
    padding: 1rem;
    box-shadow: var(--shadow-sm, 0 1px 3px rgba(0, 0, 0, 0.1));
    overflow-y: auto;
    grid-column: 1; /* Erste Spalte */
}

/* Info-Content */
.planner__info-content {
    display: flex;
    flex-direction: row;
    gap: 1rem;
    align-items: flex-start;
}

.planner__info-content h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-body, #333);
}

/* Header mit Titel und Bearbeiten-Button */
.planner__info-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.planner__info-header h3 {
    margin: 0;
    flex: 1;
}

.planner__info-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.button--small {
    padding: 0.25rem 0.75rem;
    font-size: 0.85rem;
}

.button--danger {
    background-color: var(--danger-color, #dc3545);
    color: var(--text-body-white);
}

.button--danger:hover {
    background-color: var(--danger-color-dark, #c82333);
    transform: translateY(-1px);
}

.planner__info-content p {
    margin: 0.25rem 0;
    font-size: 0.9rem;
    color: var(--text-body-light, #666);
    line-height: 1.5;
}

/* Formular-Styles für neue Items */
.planner__info-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
}

.planner__info-form-field {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.planner__info-form-field label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-body, #333);
}

.planner__info-form-field input[type="text"],
.planner__info-form-field input[type="date"],
.planner__info-form-field input[type="datetime-local"],
.planner__info-form-field textarea,
.planner__info-form-field select {
    padding: 0.5rem;
    border: 1px solid var(--border-color, #ddd);
    border-radius: var(--border-radius, 4px);
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--text-body, #333);
    background-color: var(--surface-color, #fff);
    transition: border-color 0.2s ease;
}

.planner__info-form-field input[type="text"]:focus,
.planner__info-form-field input[type="date"]:focus,
.planner__info-form-field input[type="datetime-local"]:focus,
.planner__info-form-field textarea:focus,
.planner__info-form-field select:focus {
    outline: none;
    border-color: var(--primary-color, #007bff);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.planner__info-form-field textarea {
    resize: vertical;
    min-height: 80px;
}

.planner__info-form-field input[type="checkbox"] {
    margin-right: 0.5rem;
    cursor: pointer;
}

.planner__info-form-field label:has(input[type="checkbox"]) {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.planner__info-form-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.planner__info-form-actions .button {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--border-radius, 4px);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.planner__info-form-actions .button--primary {
    background-color: var(--primary-color, #007bff);
    color: var(--text-body-white);
}

.planner__info-form-actions .button--primary:hover {
    background-color: var(--primary-color-dark, #0056b3);
    transform: translateY(-1px);
}

.planner__info-form-actions .button--secondary {
    background-color: var(--secondary-color, #6c757d);
    color: var(--text-body-white);
}

.planner__info-form-actions .button--secondary:hover {
    background-color: var(--secondary-color-dark, #545b62);
    transform: translateY(-1px);
}

/* Text-Bereich rechts */
.planner__info-text {
    flex: 1;
    min-width: 0; /* Wichtig für Text-Overflow */
}

/* Polaroid-Stil für Artikel-Bild in Info-Box */
.planner__info-polaroid {
    background-color: var(--surface-color, #fff);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1), 0 6px 20px rgba(0, 0, 0, 0.05);
    border-radius: 2px;
    padding: 15px 15px 15px 15px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    flex-shrink: 0;
    width: 180px;
    transform: rotate(-2deg);
}

.planner__info-polaroid:hover {
    transform: translateY(-5px) rotate(0deg);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15), 0 6px 6px rgba(0, 0, 0, 0.1);
}

.planner__info-polaroid::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0) 100%);
    pointer-events: none;
    border-radius: 2px;
}

.planner__info-polaroid-inner {
    position: relative;
    overflow: hidden;
    border-radius: 1px;
    height: 200px;
    max-width: 100%;
}

.planner__info-polaroid-inner img {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
    display: block;
}

.planner__info-polaroid:hover .planner__info-polaroid-inner img {
    transform: scale(1.05);
}

/* Responsive: Auf kleinen Bildschirmen wieder untereinander */
@media (max-width: 768px) {
    .planner__info-content {
        flex-direction: column;
    }
    
    .planner__info-polaroid {
        width: 100%;
        max-width: 280px;
        margin: 0 auto;
    }
}

/* Rechte Spalte: Suche oben */
.planner-v4__right-column {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    grid-column: 2; /* Zweite Spalte */
    grid-row: 1; /* Erste Zeile */
    min-height: 0; /* Wichtig für Flexbox */
}

/* Untere Zeile: Stapel und Karte */
.planner-v4__bottom-row {
    display: grid;
    grid-template-columns: 60px 1fr; /* Stapel 60px, Karte nimmt Rest */
    gap: 1rem;
    grid-column: 1; /* Erste Spalte */
    grid-row: 2; /* Zweite Zeile */
    min-height: 0; /* Wichtig für Grid */
    max-height: 60vh;
}

/* Suche - nur ein kleines Input-Feld */
.planner__search {
    background: var(--surface-color);
    border-radius: var(--border-radius, 8px);
    padding: 0.5rem;
    box-shadow: var(--shadow-sm, 0 1px 3px rgba(0, 0, 0, 0.1));
    flex-shrink: 0; /* Verhindert, dass die Suche schrumpft */
}

.planner__search-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color, #ddd);
    border-radius: var(--border-radius-sm, 4px);
    font-size: 0.9rem;
}

.planner__search-input:focus {
    outline: none;
    border-color: var(--primary-color, #007bff);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

/* Tools-Leiste zwischen Suche und Kalender */
.planner__tools {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
    margin-top: 0.25rem;
    flex-wrap: wrap;
}

.planner__tools .button {
    white-space: nowrap;
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
}

/* Auto-Plan Modal Styles */
.planner__auto-plan-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1rem;
}

.planner__auto-plan-form .planner__info-form-field select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color, #ddd);
    border-radius: var(--border-radius, 4px);
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--text-body, #333);
    background-color: var(--surface-color, #fff);
}

.planner__auto-plan-info {
    font-size: 0.85rem;
    color: var(--text-body-light, #666);
    margin: 0;
    padding: 0.75rem;
    background-color: var(--bg-secondary, #f9f9f9);
    border-radius: var(--border-radius-sm, 4px);
    border-left: 3px solid var(--primary-color, #007bff);
}

/* KI-Plan Modal Styles - nutzen gleiche Basis wie auto-plan */
.planner__ai-plan-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1rem;
}

.planner__ai-plan-form .planner__info-form-field textarea {
    width: 100%;
    min-height: 80px;
    resize: vertical;
}

/* Loading-State für KI-Plan */
.planner__ai-plan-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    gap: 1rem;
}

.planner__ai-plan-loading .spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--bg-secondary, #f3f3f3);
    border-top: 4px solid var(--primary-color, #007bff);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.planner__ai-plan-loading p {
    margin: 0;
    color: var(--text-body-light, #666);
    font-size: 0.9rem;
}

/* Ergebnis-Anzeige für KI-Plan */
.planner__ai-plan-result {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
    background-color: var(--bg-secondary, #f9f9f9);
    border-radius: var(--border-radius-sm, 4px);
    border-left: 3px solid var(--success-color, #28a745);
}

.planner__ai-plan-summary {
    font-size: 0.9rem;
    color: var(--text-body, #333);
    line-height: 1.5;
    white-space: pre-wrap;
}

/* Fehler-Anzeige für KI-Plan */
.planner__ai-plan-error {
    padding: 1rem;
    background-color: var(--danger-color-light, #f8d7da);
    border-radius: var(--border-radius-sm, 4px);
    border-left: 3px solid var(--danger-color, #dc3545);
}

.planner__ai-plan-error p {
    margin: 0;
    color: var(--danger-color-dark, #721c24);
    font-size: 0.9rem;
}

/* Stapel - schmale linke Spalte (60px), unten links */
.planner__stack {
    width: 60px;
    min-width: 60px;
    background: var(--surface-color);
    border-radius: var(--border-radius, 8px);
    padding: 0.5rem;
    box-shadow: var(--shadow-sm, 0 1px 3px rgba(0, 0, 0, 0.1));
    overflow-x: scroll;
    display:flex;
    flex-direction: column;
    gap: 0.5rem;
    grid-column: 1; /* Erste Spalte in bottom-row */
}

/* Stack-Item (Artikel im Stapel) */
.planner__stack-item {
    width: 100%;
    aspect-ratio: 1;
    border-radius: var(--border-radius-sm, 4px);
    overflow: visible; /* Sichtbar, damit Tooltip nicht abgeschnitten wird */
    cursor: pointer;
    position: relative;
    background: var(--color-primary-light, #f0f0f0);
    transition: transform 0.2s, box-shadow 0.2s;
}

.planner__stack-item:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-md, 0 4px 6px rgba(0, 0, 0, 0.1));
    z-index: 10;
}

/* Bild innerhalb des Stack-Items */
.planner__stack-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--border-radius-sm, 4px);
    display: block;
}

.planner__stack-item--selected {
    border: 2px solid var(--primary-color, #007bff);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.2);
}

/* Hervorhebung für ausgewählte Kalender-Items */
.planner__calendar-item--selected {
    border: 2px solid var(--primary-color, #007bff) !important;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.2) !important;
    z-index: 10 !important;
    position: relative !important;
}

/* Tooltip für Stack-Items - erscheint rechts vom Bild ohne Verzögerung */
.planner__stack-item-tooltip {
    position: absolute;
    right: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%);
    background-color: var(--background-color-dark);
    color: var(--text-body-white);
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    z-index: 10080;
    transform: translateX(10px) translateY(-50%);
    /* Keine Verzögerung - sofort sichtbar */
}

/* Tooltip-Pfeil links */
.planner__stack-item-tooltip::before {
    content: '';
    position: absolute;
    right: 100%;
    top: 50%;
    transform: translateY(-50%) translateX(10px);
    border-width: 5px;
    border-style: solid;
    border-color: transparent rgba(0, 0, 0, 0.85) transparent transparent;
}

/* Tooltip sichtbar beim Hover */
.planner__stack-item:hover .planner__stack-item-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateX(0) translateY(-50%);
    transition: opacity 0s, visibility 0s;
}

/* Kartenansicht - unten, neben dem Stapel */
.planner__map {
    flex: 1;
    min-width: 260px;
    min-height: 300px;
    background: var(--surface-color);
    border-radius: var(--border-radius, 8px);
    padding: 0rem;
    box-shadow: var(--shadow-sm, 0 1px 3px rgba(0, 0, 0, 0.1));
    position: relative;
    overflow: hidden;
    grid-column: 2; /* Zweite Spalte in bottom-row */
}

.planner__map-container {
    width: 100%;
    height: 100%;
    min-height: 400px;
}

/* Kalender - rechts, nimmt gesamte Höhe ein (beginnt bei Suche) */
.planner__calendar {
    min-width: 570px;
    max-width: 570px;
    background: var(--surface-color);
    margin-top: 65px;
    border-radius: var(--border-radius, 8px);
    padding: 0.0rem;
    box-shadow: var(--shadow-sm, 0 1px 3px rgba(0, 0, 0, 0.1));
    overflow-x: auto;
    overflow-y: auto;
    grid-column: 2; /* Zweite Spalte im Haupt-Grid */
    grid-row: 1 / -1; /* Spannt beide Zeilen */
    display: flex;
    flex-direction: column;
    min-height: 0; /* Wichtig für Flexbox */
    max-height:  72vh;
}

/* Kalender-Tabelle */
.planner__calendar-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 560px;
    max-width: 560px;
}

.planner__calendar-header {
    position: sticky;
    top: 0;
    background: var(--surface-color);
    z-index: 5;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.planner__calendar-header th {
    padding: 0.2rem;
    text-align: center;
    font-weight: 600;
    border-bottom: 2px solid var(--border-color, #ddd);
    background: var(--surface-color);
    font-size: 0.75rem;
}

/* Spalten-Breiten - Unterkunft, Transport und Notizen sind 50% kleiner */
.planner__calendar-header th {
    /* Standardbreite für alle Spalten */
    width: calc((560px - 1.5rem) / 5);
    min-width: calc((560px - 1.5rem) / 5);
    max-width: calc((560px - 1.5rem) / 5);
}

/* Spalten 1 und 2 (Datum/Uhrzeit, Artikel) - breiter, um Platz für schmale Spalten zu schaffen */
.planner__calendar-header th:nth-child(2) {
    width: calc(((560px - 1.5rem) - 3 * (560px - 1.5rem) / 5 * 0.5) / 2);
    min-width: calc(((560px - 1.5rem) - 3 * (560px - 1.5rem) / 5 * 0.5) / 2);
    max-width: calc(((560px - 1.5rem) - 3 * (560px - 1.5rem) / 5 * 0.5) / 2);
}

/* Spalten 3, 4, 5 (Unterkunft, Transport, Notizen) - 50% kleiner */
.planner__calendar-header th:nth-child(1),
.planner__calendar-header th:nth-child(3),
.planner__calendar-header th:nth-child(4),
.planner__calendar-header th:nth-child(5) {
    width: calc((560px - 1.5rem) / 5 * 0.5);
    min-width: calc((560px - 1.5rem) / 5 * 0.5);
    max-width: calc((560px - 1.5rem) / 5 * 0.5);
}

/* Kalender-Zeilen (Slots) */
.planner__calendar-row {
    border-bottom: 1px solid var(--border-color, #eee);
    height: 30px; /* Referenzhöhe; exakte Maße setzt alignDurationBands() per DOM */
    min-height: 30px;
    overflow: hidden;
}

/* Zeilen mit Dauer-Band: Bändchen darf in Folge-Slots sichtbar sein */
.planner__calendar-row--spans-duration,
.planner__calendar-row--resize-span {
    overflow: visible;
}

.planner__calendar-row:hover {
    background-color: var(--color-primary-lighter, #f8f9fa);
}

.planner__calendar-cell {
    padding: 0.375rem;
    vertical-align: top;
    /* Standardbreite für alle Zellen */
    width: calc((560px - 1.5rem) / 5);
    position: relative; /* Wichtig für absolute Positionierung von Items */
    border: 1px solid var(--border-color, red);
}

/* Zellen 1 und 2 (Datum/Uhrzeit, Artikel) - breiter */
.planner__calendar-cell:nth-child(2) {
    width: calc(((560px - 1.5rem) - 3 * (560px - 1.5rem) / 5 * 0.5) / 2);
}

/* Zellen 3, 4, 5 (Unterkunft, Transport, Notizen) - 50% kleiner */
.planner__calendar-cell:nth-child(1),
.planner__calendar-cell:nth-child(3),
.planner__calendar-cell:nth-child(4),
.planner__calendar-cell:nth-child(5) {
    width: calc((560px - 1.5rem) / 5 * 0.5);
}

/* Zellen mit rowspan müssen die volle Höhe nutzen */
.planner__calendar-cell[rowspan] {
    height: 100%;
    border: 1px solid var(--border-color, blue);
}

/* Zellen mit rowspan: Stelle sicher, dass Items die volle Höhe nutzen können */
.planner__calendar-cell[rowspan] > .planner__calendar-item {
    height: 100%;
    min-height: 100%;
}

.planner__calendar-cell--time {
    font-size: 0.8rem;
    color: var(--text-body-light, #666);
    white-space: nowrap;
}

/* Slot-Labels (morgens, vormittags, etc.) */
.planner__slot-label {
    font-size: 0.75rem;
    color: var(--text-body-light, #999);
    margin-top: 0.25rem;
}

/* Kalender-Elemente (Items) */
.planner__calendar-item {
    background: var(--color-primary-light, red);
    border-radius: var(--border-radius-sm, 4px);
    padding: 0.375rem;
    margin-bottom: 0.25rem;
    cursor: move;
    position: relative;
    min-height: 30px;
    display: flex;
    align-items: center;
    gap: 0.375rem;
    transition: box-shadow 0.2s;
}

/* Items, die über mehrere Slots gehen, haben keine margin-bottom */
.planner__calendar-item--spans-slots {
    margin-bottom: 0;
    height: 100%;
    min-height: 100%;
    /* Nutzt die volle Höhe der Tabellenzelle, die durch rowspan bestimmt wird */
}

.planner__calendar-item:hover {
    box-shadow: var(--shadow-md, 0 4px 6px rgba(0, 0, 0, 0.1));
}

.planner__calendar-item img {
    width: 32px;
    height: 32px;
    object-fit: cover;
    border-radius: var(--border-radius-sm, 4px);
    flex-shrink: 0;
}

.planner__calendar-item-title {
    font-size: var(--font-size-xxs);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Mehrere Artikel pro Slot */
.planner__calendar-slot-multi {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: flex-start;
    position: relative; /* Wichtig für absolute Positionierung der Bändchen */
    overflow: visible; /* Bändchen darf über Container hinausgehen */
}


/* Titel wird bei Multi-Slot-Polaroids angezeigt, nur bei Icon-only Items ausgeblendet */
.planner__calendar-item--multi:not(.planner__calendar-item--polaroid) .planner__calendar-item-title {
    display: none;
}

/* Multi-Slot Polaroids - überlappend */
.planner__calendar-item--multi-polaroid {
    margin-right: -30px; /* Standard-Überlappung für 2 Artikel */
    z-index: 1;
    position: relative;
}

/* Größere Überlappung bei 3 Artikeln */
.planner__calendar-slot-multi:has(.planner__calendar-item--multi-polaroid:nth-child(3)) .planner__calendar-item--multi-polaroid {
    margin-right: -50px;
}

.planner__calendar-item--multi-polaroid:last-child {
    margin-right: 0; /* Letztes Element hat keinen negativen Margin */
}

/* Individuelle Rotationen für Multi-Slot Polaroids */
.planner__calendar-item--multi-polaroid:nth-child(1) {
    z-index: 1;
}

.planner__calendar-item--multi-polaroid:nth-child(1) .planner__calendar-polaroid {
    transform: rotate(-2deg);
}

.planner__calendar-item--multi-polaroid:nth-child(2) {
    z-index: 2;
}

.planner__calendar-item--multi-polaroid:nth-child(2) .planner__calendar-polaroid {
    transform: rotate(1deg);
}

.planner__calendar-item--multi-polaroid:nth-child(3) {
    z-index: 3;
}

.planner__calendar-item--multi-polaroid:nth-child(3) .planner__calendar-polaroid {
    transform: rotate(-1deg);
}

.planner__calendar-item--multi-polaroid:hover {
    z-index: 10; /* Beim Hover nach vorne */
}

/* Multi-Slot Polaroids: Gleiches Padding wie einzelne Polaroids, mit Titel */
.planner__calendar-item--multi-polaroid .planner__calendar-polaroid {
    padding: 8px 8px 8px 8px; /* Gleiches Padding wie einzelne Polaroids */
    width: 100%;
    min-width: 100px;
}

.planner__calendar-item--multi-polaroid .planner__calendar-polaroid-inner {
    margin-bottom: 2px; /* Abstand unter dem Bild für Titel */
}


/* Polaroid-Look für Artikel im Kalender */
.planner__calendar-item--polaroid {
    background: transparent;
    padding: 0;   
    max-width: 100px;
    display: block;
}

.planner__calendar-polaroid {
    background-color: var(--surface-color, #fff);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1), 0 4px 12px rgba(0, 0, 0, 0.05);
    border-radius: 2px;
    padding: 8px 8px 4px 8px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    transform: rotate(-1deg);
}

.planner__calendar-item--polaroid:hover .planner__calendar-polaroid {
    transform: translateY(-2px) rotate(0deg);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 6px 20px rgba(0, 0, 0, 0.1);
}

.planner__calendar-polaroid::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0) 100%);
    pointer-events: none;
    border-radius: 2px;
}

.planner__calendar-polaroid-inner {
    position: relative;
    overflow: hidden;
    border-radius: 1px;
    width: 100%;
    aspect-ratio: 1;
    margin-bottom: 0px;
}

.planner__calendar-polaroid-inner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
    display: block;
    border-radius: 0;
}



.planner__calendar-item--polaroid  {
    padding: 0 2px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    white-space: normal;
    color: var(--text-body, #333);
}

/* Icon-only Items (Unterkunft, Transport, Notizen) */
.planner__calendar-item--icon-only {
    background: var(--color-primary-light, #e3f2fd);
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 45px;
}

/* Items, die über mehrere Slots gehen (durationSlots > 1) */
.planner__calendar-item--spans-slots {
    height: 100%;
    min-height: 100%;
    /* Höhe basierend auf durationSlots: Jeder Slot ist ca. 30px hoch */
    /* Die tatsächliche Höhe wird durch rowspan der Zelle bestimmt */
}

/* Icon-only Items, die über mehrere Slots gehen */
.planner__calendar-item--icon-only.planner__calendar-item--spans-slots {
    height: 100%;
    min-height: 100%;
    /* Stellt sicher, dass icon-only Items die volle Höhe der Zelle einnehmen */
}

.planner__calendar-item-icon {
    font-size: 1.5rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Icon-Element in Items, die über mehrere Slots gehen, nutzt die volle Höhe */
.planner__calendar-item--spans-slots .planner__calendar-item-icon {
    height: 100%;
    width: 100%;
}

.planner__calendar-item--icon-only:hover {
    background: var(--color-primary, #007bff);
}

/* Multi-Slot Icons */
.planner__calendar-item--multi .planner__calendar-item-icon {
    font-size: var(--font-size-md);
    width: 100%;
    aspect-ratio: 1;
    background: var(--color-primary-light, #e3f2fd);
    border-radius: var(--border-radius-sm, 4px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.planner__calendar-item--multi.planner__calendar-item--icon-only {
    padding: 0;
    background: transparent;
}

/* Resize-Handle für Kalender-Elemente (Dauer per Slot-Raster) */
.planner__calendar-item-resizer {
    position: absolute;
    left: 0;
    right: 0;
    height: 8px;
    cursor: ns-resize;
    background: transparent;
    z-index: 20;
    pointer-events: auto;
}

.planner__calendar-item-resizer--top {
    top: 0;
    transform: translateY(-50%);
}

.planner__calendar-item-resizer--bottom {
    bottom: 0;
    transform: translateY(50%);
}

/* Unterer Griff am Ende des Dauer-Bands (wird per JS positioniert) */
.planner__calendar-item-resizer--duration-end {
    left: 50%;
    right: auto;
    width: 28px;
    height: 10px;
    bottom: auto;
    transform: translate(-50%, -50%);
}

.planner__calendar-item-resizer:hover {
    background: var(--primary-color, #2563eb);
    opacity: 0.55;
    box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.35);
}

.planner__calendar-item--resizing .planner__calendar-item-resizer {
    background: var(--primary-color, #2563eb);
    opacity: 0.85;
    height: 10px;
    box-shadow: 0 0 8px rgba(37, 99, 235, 0.55);
}

.planner__calendar-item--resizing {
    cursor: ns-resize;
    user-select: none;
    outline: 2px solid rgba(37, 99, 235, 0.75);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15);
    z-index: 15;
}

/* Resize-Vorschau: Host-Zelle (erster Slot) + Overlay nur in dieser Spalte */
.planner__calendar-cell--resize-range-host {
    overflow: visible !important;
    z-index: 4;
}

.planner__calendar-cell--resize-range-host.planner__calendar-cell--resize-range {
    box-shadow: inset 0 0 0 3px rgba(37, 99, 235, 0.75) !important;
    background-color: rgba(37, 99, 235, 0.12) !important;
}

.planner__resize-range-overlay {
    position: absolute;
    left: 3px;
    right: 3px;
    pointer-events: none;
    z-index: 3;
    border-radius: 4px;
    background: rgba(37, 99, 235, 0.28);
    border: 2px solid rgba(37, 99, 235, 0.85);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.6) inset, 0 2px 10px rgba(37, 99, 235, 0.25);
}

.planner__calendar-cell--resize-range {
    background-color: rgba(37, 99, 235, 0.28) !important;
    box-shadow: inset 0 0 0 2px rgba(37, 99, 235, 0.85) !important;
}

/* Während Resize: Plus-Buttons in anderen Spalten nicht ablenken */
.planner__calendar--resizing .planner__calendar-row--resize-span .planner__calendar-slot-add {
    opacity: 0 !important;
    pointer-events: none;
}

.planner__calendar-duration-band--preview .planner__calendar-item-duration-band {
    width: 5px;
    background-color: #2563eb;
    opacity: 1;
    box-shadow: 0 0 8px rgba(37, 99, 235, 0.65);
    animation: planner-resize-band-pulse 0.9s ease-in-out infinite alternate;
}

.planner__calendar-duration-band--preview .planner__calendar-item-duration-band-end {
    width: 12px;
    height: 12px;
    border-width: 3px;
    border-color: #2563eb;
    background-color: #fff;
    box-shadow: 0 0 6px rgba(37, 99, 235, 0.5);
}

@keyframes planner-resize-band-pulse {
    from { opacity: 0.85; }
    to { opacity: 1; }
}

/* Floating-Label während Resize */
.planner__resize-label {
    position: fixed;
    z-index: 100002;
    transform: translateX(-50%);
    pointer-events: none;
    padding: 0.35rem 0.65rem;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1.2;
    color: #fff;
    background: #2563eb;
    border-radius: 6px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
    white-space: nowrap;
}

.planner__resize-label[hidden] {
    display: none;
}

.planner__calendar--resizing {
    user-select: none;
    cursor: ns-resize;
}

/* Plus-Icon für leere Slots */
.planner__calendar-slot-add {
    width: 100%;
    height: 100%;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-body-light, #999);
    font-size: 1.5rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s, background-color 0.2s;
}

.planner__calendar-cell:hover .planner__calendar-slot-add {
    opacity: 1;
    background-color: var(--color-primary-lighter, #f8f9fa);
}

.planner__calendar-slot-add:hover {
    background-color: var(--color-primary-light, #e3f2fd);
    color: var(--primary-color, #007bff);
}

/* Responsive Design */
@media (max-width: 1200px) {
    .planner-v4 {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
    }
    
    .planner-v4__top-row {
        grid-template-columns: 1fr;
        grid-column: 1;
    }
    
    .planner__info {
        grid-column: 1;
    }
    
    .planner-v4__right-column {
        grid-column: 1;
        grid-row: 2;
    }
    
    .planner__calendar {
        grid-column: 1;
        grid-row: 2;
    }
    
    .planner-v4__bottom-row {
        grid-column: 1;
        grid-row: 3;
        grid-template-columns: 60px 1fr;
    }
    
    .planner__stack {
        grid-column: 1;
    }
    
    .planner__map {
        grid-column: 2;
    }
}

/* Details-Container Toggle (bereits vorhanden, aber für Planner v4 angepasst) */
.planner__details-container {
    background-color: var(--surface-color);
}
.planner__details-container.collapsed {
    max-height: 0;
    overflow: hidden;
    margin-bottom: 0;
    padding: 0;
    transition: max-height 0.3s ease-out, margin-bottom 0.3s ease-out, padding 0.3s ease-out;
}

.planner__details-container:not(.collapsed) {
    transition: max-height 0.3s ease-in, margin-bottom 0.3s ease-in, padding 0.3s ease-in;
}

.planner__details-toggle-btn {
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: var(--border-radius, 8px);
    padding: 0.5rem 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    margin-bottom: 0.75rem;
    width: 100%;
    color: var(--text-body, #333);
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    position: relative;
}

.planner__details-toggle-btn:hover {
    border-color: var(--border-color-dark, #d0d0d0);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

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

/* Collapsed State - subtiler Unterschied */
.planner__details-toggle-btn.collapsed {
    background: var(--background-color);
    border-color: var(--border-color, #e0e0e0);
}

.planner__details-toggle-btn.collapsed:hover {
    background-color: var(--background-color-medium);
}

/* Icon-Styling */
.planner__details-toggle-icon {
    font-size: 0.9rem;
    transition: transform 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    line-height: 1;
}

.planner__details-toggle-btn.collapsed .planner__details-toggle-icon {
    transform: rotate(180deg);
}

/* Text-Styling */
.planner__details-toggle-text {
    font-weight: 500;
    letter-spacing: 0.2px;
}

/* Responsive: Kleinere Schrift auf mobilen Geräten */
@media (max-width: 768px) {
    .planner__details-toggle-btn {
        padding: 0.45rem 1rem;
        font-size: 0.85rem;
    }
    
    .planner__details-toggle-icon {
        font-size: 0.85rem;
        width: 16px;
        height: 16px;
    }
}

/* Platzhalter für leere Bereiche */
.planner__empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: var(--text-body-light, #999);
    text-align: center;
    height: 100%;
    min-height: 200px;
}

.planner__empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Drag & Drop – Drop-Zonen */
.planner__dropzone--valid {
    background-color: rgba(59, 136, 78, 0.32) !important;
    border: 2px solid rgba(45, 110, 60, 0.95) !important;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5), 0 0 0 2px rgba(59, 136, 78, 0.25) !important;
    outline: 2px dashed rgba(59, 136, 78, 0.55);
    outline-offset: -3px;
}

.planner__dropzone--invalid {
    background-color: rgba(180, 40, 50, 0.22) !important;
    border: 2px dashed rgba(160, 30, 40, 0.9) !important;
    box-shadow: inset 0 0 12px rgba(180, 40, 50, 0.15) !important;
    outline: 2px dashed rgba(180, 40, 50, 0.45);
    outline-offset: -3px;
}

.planner__stack.planner__dropzone--valid {
    box-shadow: inset 0 0 0 3px rgba(59, 136, 78, 0.45) !important;
}

.planner__calendar-item[draggable="true"],
.planner__stack-item[draggable="true"] {
    cursor: grab;
}

.planner__calendar-item[draggable="true"]:active,
.planner__stack-item[draggable="true"]:active {
    cursor: grabbing;
}

/* Quell-Element während des Ziehens: Platzhalter sichtbar lassen */
.planner__calendar-item--dragging,
.planner__stack-item--dragging {
    opacity: 0.35 !important;
    outline: 2px dashed var(--primary-color, #2563eb);
    outline-offset: 3px;
    filter: grayscale(0.35);
    transform: scale(0.94);
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.planner--is-dragging {
    cursor: grabbing;
}

.planner--is-dragging .planner__calendar,
.planner--is-dragging .planner__stack {
    cursor: grabbing;
}

/* Sichtbare Drag-Vorschau (setDragImage) – außerhalb des Viewports bis zum Drag-Start */
.planner__drag-preview {
    position: fixed;
    left: -9999px;
    top: 0;
    z-index: 100000;
    pointer-events: none;
}

.planner__drag-preview-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 0.75rem 0.55rem;
    background: var(--surface-color, #fff);
    border: 2px solid var(--primary-color, #2563eb);
    border-radius: 6px;
    box-shadow:
        0 12px 28px rgba(0, 0, 0, 0.28),
        0 4px 10px rgba(0, 0, 0, 0.12);
    transform: rotate(-4deg);
    min-width: 5.5rem;
    max-width: 9rem;
}

.planner__drag-preview-card--from-stack {
    transform: rotate(3deg);
}

.planner__drag-preview-card img {
    width: 4.5rem;
    height: 4.5rem;
    object-fit: cover;
    border-radius: 3px;
    display: block;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

.planner__drag-preview-icon {
    width: 4.5rem;
    height: 4.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    background: var(--color-primary-light, #e8f0fe);
    border-radius: 4px;
}

.planner__drag-preview-title {
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    max-width: 8.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-body, #222);
}

/* Suche - Markierung von passenden Ergebnissen */
.planner__search-match {
    border: 3px solid #ff0000 !important;
    box-shadow: 0 0 0 2px rgba(255, 0, 0, 0.3) !important;
    z-index: 100 !important;
    position: relative !important;
}

.planner__calendar-item.planner__search-match {
    border: 3px solid #ff0000 !important;
    box-shadow: 0 0 0 2px rgba(255, 0, 0, 0.3) !important;
    z-index: 100 !important;
    position: relative !important;
}

.planner__stack-item.planner__search-match {
    border: 3px solid #ff0000 !important;
    box-shadow: 0 0 0 2px rgba(255, 0, 0, 0.3), 0 0 10px rgba(255, 0, 0, 0.5) !important;
    z-index: 100 !important;
    position: relative !important;
    outline: 2px solid #ff0000 !important;
    outline-offset: 2px !important;
}

/* Verwaiste alte Ghost-Klone ausbleiben lassen (aktive Vorschau: .planner__drag-preview) */
.planner__drag-ghost {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

/*
 * Mehrtägige/mehrslotige Artikel (Polaroid): kompaktes Kärtchen + Dauer-Band am Slot-Raster.
 * Position/Höhe: calendar.js alignDurationBands() (Start-/End-Zeile per getBoundingClientRect).
 */
.planner__calendar-item--long-duration {
    position: relative;
    z-index: 2;
}

.planner__calendar-cell--has-long-item {
    overflow: visible;
    z-index: 1;
}

/* Wrapper in der Zelle; Linie + Endpunkt werden nach Layout absolut gesetzt */
.planner__calendar-duration-band {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1; /* unter Polaroid (z-index 2), sichtbar in Folge-Slots */
}

.planner__calendar-item-duration-band {
    position: absolute;
    left: 50%;
    top: 0;
    transform: translateX(-50%);
    width: 3px;
    background-color: var(--color-duration-band, #c62828);
    pointer-events: none;
    z-index: 10;
}

.planner__calendar-item-duration-band-end {
    position: absolute;
    left: 50%;
    top: 0;
    transform: translateX(-50%) translateY(-50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 2px solid var(--color-duration-band, #c62828);
    background-color: var(--surface-color, #fff);
    pointer-events: none;
    z-index: 11;
}