/**
 * News Widget Styles
 *
 * @package KB_Local_Business_Schema
 *
 * Grid-System:
 * - Spaltenanzahl wird von Elementor responsive controls gesteuert
 * - Standard: 3 Spalten (Desktop), 2 (Tablet), 1 (Mobile)
 * - Container Queries als Notfall-Schutz bei sehr schmalen Containern
 */

/* ==========================================================================
   WRAPPER - Container für das News-Widget
   ========================================================================== */
.kb-news-wrapper {
    display: block;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Ensure wrapper fills Elementor widget container */
.elementor-widget-kb-news .elementor-widget-container {
    width: 100%;
    max-width: 100%;
}

.elementor-widget-kb-news .kb-news-wrapper {
    width: 100%;
    max-width: 100%;
}

/* ==========================================================================
   GRID LAYOUT - Responsives CSS Grid

   Spaltenanzahl wird von Elementor responsive controls gesteuert.
   Standard: 3 Spalten Desktop, 2 Tablet, 1 Mobile
   ========================================================================== */
.kb-news-grid {
    display: grid;
    gap: var(--kb-news-gap, 20px);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    /* Standard: 3 Spalten - wird von Elementor überschrieben */
    grid-template-columns: repeat(var(--kb-news-columns, 3), minmax(0, 1fr));
}

/* News Item - ensure proper sizing within grid */
.kb-news-grid > .kb-news-item {
    min-width: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* List Layout */
.kb-news-list .kb-news-grid {
    grid-template-columns: 1fr;
}

.kb-news-list .kb-news-item {
    display: flex;
    flex-direction: row;
    gap: 20px;
}

.kb-news-list .kb-news-image {
    flex: 0 0 250px;
    height: auto;
}

.kb-news-list .kb-news-content {
    flex: 1;
}

/* News Item */
.kb-news-item {
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

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

/* Highlight Style */
.kb-news-item.kb-news-highlight {
    border-left: 4px solid #ffb900;
}

/* Image */
.kb-news-image {
    position: relative;
    overflow: hidden;
    height: 200px;
}

.kb-news-image a {
    display: block;
    width: 100%;
    height: 100%;
}

.kb-news-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.kb-news-item:hover .kb-news-image img {
    transform: scale(1.05);
}

/* Content */
.kb-news-content {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Date */
.kb-news-date {
    font-size: 0.85em;
    color: #666;
    margin-bottom: 8px;
}

/* Title */
.kb-news-title {
    margin: 0 0 12px 0;
    font-size: 1.25em;
    line-height: 1.3;
}

.kb-news-title a {
    color: inherit;
    text-decoration: none;
    transition: color 0.3s ease;
}

.kb-news-title a:hover {
    color: var(--e-global-color-primary, #007bff);
}

/* Excerpt */
.kb-news-excerpt {
    color: #555;
    line-height: 1.6;
    margin-bottom: 15px;
    flex: 1;
}

/* Read More */
.kb-news-read-more {
    margin-top: auto;
}

/* Button */
.kb-news-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 20px;
    background: #fff;
    color: var(--e-global-color-primary, #007bff);
    text-decoration: none;
    border-radius: 4px;
    border: 1px solid var(--e-global-color-primary, #007bff);
    font-size: 0.9em;
    transition: background 0.3s ease, color 0.3s ease, transform 0.2s ease;
}

.kb-news-button:hover {
    background: var(--e-global-color-primary, #007bff);
    color: #fff;
    transform: translateY(-2px);
}

/* External Link Icon */
.kb-news-external-icon {
    display: inline-flex;
    align-items: center;
}

.kb-news-external-icon svg {
    width: 12px;
    height: 12px;
}

/* No Data Message */
.kb-news-no-data {
    text-align: center;
    padding: 40px 20px;
    background: #f5f5f5;
    border-radius: 8px;
    color: #666;
}

/* ==========================================================================
   RESPONSIVE LAYOUTS

   Die Spaltenanzahl wird primär von Elementor's responsive controls gesteuert.
   Container Queries dienen als Notfall-Schutz bei sehr schmalen Containern.
   ========================================================================== */

/* Tablet: List-Layout Anpassung */
@media (max-width: 1024px) {
    .kb-news-list .kb-news-image {
        flex: 0 0 200px;
    }
}

/* Mobile: Kompaktes Layout */
@media (max-width: 767px) {
    .kb-news-list .kb-news-item {
        flex-direction: column;
    }

    .kb-news-list .kb-news-image {
        flex: none;
        height: 200px;
    }

    .kb-news-content {
        padding: 15px;
    }
}

/* ==========================================================================
   CONTAINER QUERIES - Notfall-Schutz für schmale Container

   Diese Queries greifen NUR wenn der Container sehr schmal ist,
   um unleserlich schmale Karten zu verhindern.
   Elementor's responsive controls haben bei normalen Breiten Vorrang.
   ========================================================================== */
@supports (container-type: inline-size) {
    .kb-news-wrapper {
        container-type: inline-size;
        container-name: kb-news;
    }

    /* Unter 500px: Maximal 2 Spalten */
    @container kb-news (max-width: 499px) {
        .kb-news-grid {
            grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        }
    }

    /* Unter 350px: Immer 1 Spalte */
    @container kb-news (max-width: 349px) {
        .kb-news-grid {
            grid-template-columns: 1fr !important;
        }
    }
}

/* ==========================================================================
   SLIDER LAYOUT
   ========================================================================== */
.kb-news-slider {
    position: relative;
}

.kb-news-slider-container {
    overflow: hidden;
    width: 100%;
}

.kb-news-slider-track {
    display: flex;
    will-change: transform;
}

.kb-news-slide {
    flex-shrink: 0;
}

.kb-news-slide .kb-news-item {
    height: 100%;
}

/* Slider Navigation */
.kb-news-slider-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease, opacity 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    color: #333;
    padding: 0;
    margin: 0;
    box-sizing: border-box;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    line-height: 1;
}

.kb-news-slider-nav:hover {
    background: var(--e-global-color-primary, #007bff);
    color: #fff;
    transform: translateY(-50%) scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.kb-news-slider-nav:focus {
    outline: 2px solid var(--e-global-color-primary, #007bff);
    outline-offset: 2px;
}

.kb-news-slider-nav.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.kb-news-slider-nav svg {
    width: 24px;
    height: 24px;
    display: block;
    flex-shrink: 0;
    stroke: currentColor;
    fill: none;
    transition: stroke 0.3s ease;
}

/* Ensure SVG icon has explicit color on hover */
.kb-news-slider-nav:hover svg {
    stroke: #fff;
}

.kb-news-slider-prev {
    left: -22px;
}

.kb-news-slider-next {
    right: -22px;
}

/* Slider Pagination */
.kb-news-slider-pagination {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
    padding: 10px 0;
}

.kb-news-slider-dot {
    width: 12px;
    height: 12px;
    min-width: 12px;
    min-height: 12px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.2);
    border: none;
    outline: none;
    cursor: pointer;
    transition: background 0.3s ease, transform 0.3s ease;
    padding: 0;
    margin: 0;
    box-sizing: border-box;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.kb-news-slider-dot:hover {
    background: rgba(0, 0, 0, 0.4);
    transform: scale(1.1);
}

.kb-news-slider-dot.active {
    background: var(--e-global-color-primary, #007bff);
    transform: scale(1.2);
}

.kb-news-slider-dot:focus {
    outline: 2px solid var(--e-global-color-primary, #007bff);
    outline-offset: 2px;
}

/* Slider Responsive */
@media (max-width: 1024px) {
    .kb-news-slider-prev {
        left: 10px;
    }

    .kb-news-slider-next {
        right: 10px;
    }

    .kb-news-slider-nav {
        width: 40px;
        height: 40px;
        background: rgba(255, 255, 255, 0.9);
    }
}

@media (max-width: 767px) {
    .kb-news-slider-nav {
        width: 36px;
        height: 36px;
    }

    .kb-news-slider-nav svg {
        width: 20px;
        height: 20px;
    }

    .kb-news-slider-prev {
        left: 5px;
    }

    .kb-news-slider-next {
        right: 5px;
    }

    .kb-news-slider-pagination {
        gap: 8px;
    }

    .kb-news-slider-dot {
        width: 10px;
        height: 10px;
    }
}

/* ==========================================================================
   ELEMENTOR EDITOR FIXES
   ========================================================================== */

/* Ensure proper overflow handling in Elementor editor */
.elementor-editor-active .kb-news-slider-container,
.elementor-editor-preview .kb-news-slider-container {
    overflow: hidden !important;
}

/* Allow navigation buttons to be visible outside slider in editor */
.elementor-editor-active .kb-news-slider,
.elementor-editor-preview .kb-news-slider {
    overflow: visible;
    padding-left: 24px;
    padding-right: 24px;
    margin-left: -24px;
    margin-right: -24px;
}

/* Fix for Elementor widget container in editor - allow overflow for navigation */
.elementor-editor-active .elementor-widget-kb-news .elementor-widget-container,
.elementor-editor-preview .elementor-widget-kb-news .elementor-widget-container {
    overflow: visible;
}

/* Ensure slider track doesn't cause horizontal scroll in editor */
.elementor-editor-active .kb-news-slider-track,
.elementor-editor-preview .kb-news-slider-track {
    width: max-content;
}

/* Fix slider item sizing in editor mode */
.elementor-editor-active .kb-news-slide,
.elementor-editor-preview .kb-news-slide {
    box-sizing: border-box;
}
