/* Child Pages Overview Plugin Styles */

.child-pages-overview {
    margin: 20px 0;
}

/* Kategorie-Modus (Hauptseite mit Kategorien) */
.child-pages-overview.category-mode .cpo-category-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    align-items: start;
    grid-auto-rows: min-content;
}

/* Masonry wird durch JavaScript überschrieben bei Desktop */
.child-pages-overview.category-mode[data-columns="2"] .cpo-category-grid {
    grid-template-columns: 1fr 1fr;
}

.child-pages-overview.category-mode[data-columns="3"] .cpo-category-grid {
    grid-template-columns: 1fr 1fr 1fr;
}

.child-pages-overview.category-mode[data-columns="4"] .cpo-category-grid {
    grid-template-columns: 1fr 1fr 1fr 1fr;
}

.child-pages-overview.category-mode .cpo-category-section {
    margin-bottom: 0;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    background: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: box-shadow 0.3s ease;
    break-inside: avoid;
    height: fit-content;
    box-sizing: border-box;
}

.child-pages-overview.category-mode .cpo-category-section:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.cpo-category-title {
    font-size: 1.5em;
    margin-bottom: 20px;
    font-weight: bold;
    color: #333;
}

.cpo-category-link {
    color: #333;
    text-decoration: underline;
    transition: color 0.3s ease;
}

.cpo-category-link:hover {
    color: #007cba;
    text-decoration: underline;
}

/* Content-Modus (Kategorieseiten nur mit Inhalten) */
.child-pages-overview.content-mode {
    margin: 10px 0;
}

.child-pages-overview.content-mode .cpo-content-list {
    border-top: 2px solid #007cba;
    padding-top: 10px;
}

.cpo-content-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* 2-spaltige Darstellung NUR für Content-Modus (Kategorieseiten) */
.child-pages-overview.content-mode .cpo-content-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
}

/* Inhalte in Kategorien bleiben vertikal gestapelt */
.child-pages-overview.category-mode .cpo-content-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Flexible Spaltenanzahl basierend auf data-columns Attribut */
.child-pages-overview.content-mode[data-columns="1"] .cpo-content-list {
    grid-template-columns: 1fr;
}

.child-pages-overview.content-mode[data-columns="2"] .cpo-content-list {
    grid-template-columns: 1fr 1fr;
}

.child-pages-overview.content-mode[data-columns="3"] .cpo-content-list {
    grid-template-columns: 1fr 1fr 1fr;
}

.child-pages-overview.content-mode[data-columns="4"] .cpo-content-list {
    grid-template-columns: 1fr 1fr 1fr 1fr;
}

.cpo-content-item {
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    transition: all 0.3s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    min-height: 120px; /* Mindesthöhe für einheitliches Layout */
}

.cpo-content-item:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transform: translateY(-2px);
    border-color: #007cba;
}

.cpo-content-link {
    display: flex;
    align-items: flex-start;
    text-decoration: none;
    color: inherit;
    padding: 15px;
    transition: background-color 0.3s ease;
    min-height: 120px;
    box-sizing: border-box;
}

.cpo-content-link:hover {
    background-color: #f8f9fa;
    color: #007cba;
}

.cpo-content-image {
    margin-right: 20px;
    flex-shrink: 0;
    align-self: flex-start;
}

.child-pages-overview .cpo-content-image img {
    width: 80px !important;
    height: 80px !important;
    object-fit: cover;
    border-radius: 6px;
    border: 2px solid #f0f0f0;
    display: block !important;
    margin: 0 !important;
}

.child-pages-overview .cpo-no-image {
    width: 80px !important;
    height: 80px !important;
    background: #f0f0f0;
    border-radius: 6px;
    display: flex !important;
    align-items: center;
    justify-content: center;
    font-size: 2em;
    color: #999;
    flex-shrink: 0;
    margin: 0 !important;
}

.cpo-content-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 90px; /* Mindesthöhe entsprechend des Bildes + Padding */
    width: 0; /* Hack für flexible Breite bei langem Text */
}

.child-pages-overview .cpo-content-title {
    font-weight: 500 !important;
    font-size: 1.1em !important;
    line-height: 1.3 !important;
    margin: 0 0 10px 0 !important;
    word-wrap: break-word;
    overflow-wrap: break-word;
    padding: 0 !important;
}

.child-pages-overview .cpo-trainer-info {
    font-size: 0.9em !important;
    color: #666 !important;
    font-style: italic !important;
    margin-top: auto !important;
    padding: 5px 0 0 0 !important;
}

.cpo-trainer-link {
    color: #007cba;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease;
}

.cpo-trainer-link:hover {
    color: #005177;
    text-decoration: underline;
}

/* Spezielle Styles für Content-Modus */
.child-pages-overview.content-mode .cpo-content-title {
    font-size: 1.2em;
    color: #333;
}

.child-pages-overview.content-mode .cpo-content-item:hover .cpo-content-title {
    color: #007cba;
}

.child-pages-overview.content-mode .cpo-trainer-info {
    font-size: 0.95em;
}

.cpo-empty-category {
    color: #666;
    font-style: italic;
    margin: 10px 0;
}

/* Responsive Design */
@media (max-width: 768px) {
    /* Auf Tablets: alle Grids wieder einspaltig */
    .child-pages-overview.category-mode .cpo-category-grid,
    .child-pages-overview.category-mode[data-columns="2"] .cpo-category-grid,
    .child-pages-overview.category-mode[data-columns="3"] .cpo-category-grid,
    .child-pages-overview.category-mode[data-columns="4"] .cpo-category-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .child-pages-overview.content-mode .cpo-content-list,
    .child-pages-overview.content-mode[data-columns="2"] .cpo-content-list,
    .child-pages-overview.content-mode[data-columns="3"] .cpo-content-list,
    .child-pages-overview.content-mode[data-columns="4"] .cpo-content-list {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .cpo-content-link {
        padding: 12px;
    }
    
    .cpo-content-image img,
    .cpo-no-image {
        width: 60px;
        height: 60px;
    }
    
    .cpo-image-cell {
        width: 60px;
    }
    
    .cpo-content-cell {
        padding-left: 12px;
    }
    
    .cpo-content-title {
        font-size: 1em;
    }
    
    .cpo-trainer-info {
        font-size: 0.85em;
    }
    
    .cpo-category-title {
        font-size: 1.3em;
    }
}

@media (max-width: 480px) {
    /* Auf sehr kleinen Bildschirmen: Table zu vertikalem Layout */
    .cpo-content-table,
    .cpo-content-table tr,
    .cpo-content-table td {
        display: block;
        width: 100%;
    }
    
    .cpo-image-cell,
    .cpo-content-cell {
        padding: 0;
        text-align: center;
    }
    
    .cpo-content-cell {
        margin-top: 10px;
    }
    
    .cpo-content-image {
        display: flex;
        justify-content: center;
    }
}