/* ===================================
   CHWEB Flexible Blocks CSS
   Erweiterte Styles für das neue flexible Shortcode-System
   =================================== */

/* Container für flexible Blocks */
.chweb-flexible-blocks {
    margin: 2rem 0;
    padding: 0;
}

/* Titel für Block-Gruppen */
.chweb-blocks-title {
    text-align: center;
    margin-bottom: 2rem;
    font-size: 2rem;
    font-weight: 600;
    color: #333;
}

/* Container für flexible Blocks */
.chweb-blocks-container {
    display: grid;
    gap: 1.5rem;
    width: 100%;
    align-items: start;
}

/* CSS Grid Masonry Support */
@supports (grid-template-rows: masonry) {
    .chweb-blocks-container {
        grid-template-rows: masonry;
    }
}

/* CHWEB Blocks sind IMMER sichtbar - spezifische Selektoren */
.chweb-flexible-blocks .chweb-block,
.chweb-blocks-container .chweb-block {
    opacity: 1 !important;
    visibility: visible !important;
    transition: none !important; /* Verhindere alle Transitions die Flackern verursachen */
    min-height: 200px !important; /* Verhindere Kollaps während Initialisierung */
    height: auto !important;
}

/* Spalten-Layout mit Masonry-Unterstützung */
.chweb-columns-1 { 
    grid-template-columns: 1fr; 
}
.chweb-columns-2 { 
    grid-template-columns: repeat(2, 1fr);
}
.chweb-columns-3 { 
    grid-template-columns: repeat(3, 1fr);
}
.chweb-columns-4 { 
    grid-template-columns: repeat(4, 1fr);
}
.chweb-columns-6 { 
    grid-template-columns: repeat(6, 1fr);
}

/* Fallback für Browser ohne Masonry-Unterstützung */
@supports not (grid-template-rows: masonry) {
    .chweb-blocks-container:not(.js-masonry-active) {
        display: flex;
        flex-wrap: wrap;
        align-items: flex-start;
    }
    
    .chweb-blocks-container:not(.js-masonry-active) .chweb-block {
        margin-bottom: 1.5rem;
        opacity: 1 !important;
        visibility: visible !important;
        position: relative;
    }
    
    .chweb-blocks-container:not(.js-masonry-active).chweb-columns-1 .chweb-block { width: 100%; }
    .chweb-blocks-container:not(.js-masonry-active).chweb-columns-2 .chweb-block { width: calc(50% - 0.75rem); }
    .chweb-blocks-container:not(.js-masonry-active).chweb-columns-3 .chweb-block { width: calc(33.333% - 1rem); }
    .chweb-blocks-container:not(.js-masonry-active).chweb-columns-4 .chweb-block { width: calc(25% - 1.125rem); }
    .chweb-blocks-container:not(.js-masonry-active).chweb-columns-6 .chweb-block { width: calc(16.666% - 1.25rem); }
}

/* JavaScript Masonry aktiv */
.chweb-blocks-container.js-masonry-active {
    position: relative;
    width: 100%;
}

.chweb-blocks-container.js-masonry-active .chweb-block {
    position: absolute;
    transition: none !important; /* Entferne alle Transitions */
    opacity: 1 !important;
    visibility: visible !important;
}

/* Responsive Anpassungen */
@media (max-width: 1200px) {
    .chweb-columns-6 { grid-template-columns: repeat(4, 1fr); }
    
    @supports not (grid-template-rows: masonry) {
        .chweb-blocks-container:not(.js-masonry-active).chweb-columns-6 .chweb-block { 
            width: calc(25% - 1.125rem); 
            opacity: 1 !important;
            visibility: visible !important;
        }
    }
}

@media (max-width: 992px) {
    .chweb-columns-4,
    .chweb-columns-6 { grid-template-columns: repeat(3, 1fr); }
    
    @supports not (grid-template-rows: masonry) {
        .chweb-blocks-container:not(.js-masonry-active).chweb-columns-4 .chweb-block,
        .chweb-blocks-container:not(.js-masonry-active).chweb-columns-6 .chweb-block { 
            width: calc(33.333% - 1rem); 
            opacity: 1 !important;
            visibility: visible !important;
        }
    }
}

@media (max-width: 768px) {
    .chweb-columns-3,
    .chweb-columns-4,
    .chweb-columns-6 { grid-template-columns: repeat(2, 1fr); }
    
    @supports not (grid-template-rows: masonry) {
        .chweb-blocks-container:not(.js-masonry-active).chweb-columns-3 .chweb-block,
        .chweb-blocks-container:not(.js-masonry-active).chweb-columns-4 .chweb-block,
        .chweb-blocks-container:not(.js-masonry-active).chweb-columns-6 .chweb-block { 
            width: calc(50% - 0.75rem); 
            opacity: 1 !important;
            visibility: visible !important;
        }
    }
}

@media (max-width: 576px) {
    .chweb-columns-2,
    .chweb-columns-3,
    .chweb-columns-4,
    .chweb-columns-6 { grid-template-columns: 1fr; }
    
    @supports not (grid-template-rows: masonry) {
        .chweb-blocks-container:not(.js-masonry-active).chweb-columns-2 .chweb-block,
        .chweb-blocks-container:not(.js-masonry-active).chweb-columns-3 .chweb-block,
        .chweb-blocks-container:not(.js-masonry-active).chweb-columns-4 .chweb-block,
        .chweb-blocks-container:not(.js-masonry-active).chweb-columns-6 .chweb-block { 
            width: 100%; 
            opacity: 1 !important;
            visibility: visible !important;
        }
    }
}

/* Abstände */
.chweb-spacing-tight .chweb-blocks-container { gap: 0.75rem; }
.chweb-spacing-normal .chweb-blocks-container { gap: 1.5rem; }
.chweb-spacing-wide .chweb-blocks-container { gap: 2rem; }
.chweb-spacing-extra_wide .chweb-blocks-container { gap: 2.5rem; }

/* Block Basis-Styles */
.chweb-block {
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    transition: all 0.3s ease;
    min-height: 200px; /* Verhindere Miniaturisierung */
    height: auto; /* Flexibel aber nicht zu klein */
    display: flex;
    flex-direction: column;
}

.chweb-block-content {
    padding: 1.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.chweb-block-title {
    margin: 0 0 1rem 0;
    font-weight: 600;
    line-height: 1.3;
}

.chweb-block-text {
    flex: 1;
    margin-bottom: 1rem;
    line-height: 1.6;
}

.chweb-block-text p:last-child {
    margin-bottom: 0;
}

.chweb-block-button {
    margin-top: auto;
    padding-top: 1rem;
}

.chweb-block-button .btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background: #007bff;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    transition: background-color 0.3s ease;
    font-weight: 500;
}

.chweb-block-button .btn:hover {
    background: #0056b3;
    text-decoration: none;
    color: white;
}

/* Block Bilder */
.chweb-block-image {
    width: 100%;
    overflow: hidden;
}

.chweb-block-image img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.chweb-block:hover .chweb-block-image img {
    transform: scale(1.05);
}

/* Bild-Positionen */
.chweb-image-left {
    flex-direction: row;
}

.chweb-image-left .chweb-block-image {
    width: 40%;
    flex-shrink: 0;
}

.chweb-image-left .chweb-block-content {
    width: 60%;
}

.chweb-image-right {
    flex-direction: row-reverse;
}

.chweb-image-right .chweb-block-image {
    width: 40%;
    flex-shrink: 0;
}

.chweb-image-right .chweb-block-content {
    width: 60%;
}

.chweb-image-background {
    position: relative;
    color: white;
}

.chweb-block-bg {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-size: cover;
    background-position: center;
    z-index: 1;
}

.chweb-image-background .chweb-block-content {
    position: relative;
    z-index: 2;
    background: rgba(0,0,0,0.6);
}

/* Icons */
.chweb-block-icon {
    text-align: center;
    margin-bottom: 1rem;
}

.chweb-block-icon i {
    font-size: 2.5rem;
    color: #007bff;
}

/* ===================================
   BLOCK STYLES
   =================================== */

/* Modern Style */
.chweb-blocks-modern .chweb-block {
    border: 1px solid #e9ecef;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.chweb-blocks-modern .chweb-block:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

/* Classic Style */
.chweb-blocks-classic .chweb-block {
    border: 2px solid #dee2e6;
    box-shadow: none;
}

.chweb-blocks-classic .chweb-block:hover {
    border-color: #007bff;
}

/* Minimal Style */
.chweb-blocks-minimal .chweb-block {
    background: transparent;
    border: none;
    box-shadow: none;
    border-radius: 0;
}

.chweb-blocks-minimal .chweb-block-content {
    padding: 1rem 0;
}

.chweb-blocks-minimal .chweb-block:hover {
    transform: none;
}

/* Gradient Style */
.chweb-blocks-gradient .chweb-block {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
}

.chweb-blocks-gradient .chweb-block-icon i {
    color: white;
}

.chweb-blocks-gradient .chweb-block-button .btn {
    background: rgba(255,255,255,0.2);
    border: 2px solid white;
    color: white;
}

.chweb-blocks-gradient .chweb-block-button .btn:hover {
    background: white;
    color: #667eea;
}

/* Glass Style */
.chweb-blocks-glass .chweb-block {
    background: rgba(255,255,255,0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.2);
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
}

.chweb-blocks-glass .chweb-block:hover {
    background: rgba(255,255,255,0.2);
    transform: translateY(-3px);
}

/* ===================================
   RESPONSIVE ANPASSUNGEN
   =================================== */

@media (max-width: 768px) {
    .chweb-image-left,
    .chweb-image-right {
        flex-direction: column;
    }
    
    .chweb-image-left .chweb-block-image,
    .chweb-image-right .chweb-block-image,
    .chweb-image-left .chweb-block-content,
    .chweb-image-right .chweb-block-content {
        width: 100%;
    }
    
    .chweb-block-content {
        padding: 1rem;
    }
    
    .chweb-blocks-title {
        font-size: 1.5rem;
        margin-bottom: 1.5rem;
    }
}

/* ===================================
   OVERLAY STYLES (für Text Overlay Funktion)
   =================================== */

/* Background Image mit Text-Overlay */
.box-background-image {
    width: 100%;
    min-height: 300px;
    height: auto;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    position: relative;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    border-radius: 8px;
    overflow: visible;
    padding: 20px 0;
}

.box-overlay-content {
    text-align: center;
    color: white;
    padding: 40px 20px;
    background: rgba(0,0,0,0.5);
    border-radius: 8px;
    max-width: 80%;
    width: 100%;
    backdrop-filter: blur(2px);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 15px;
    height: auto;
}

.box-overlay-content .box-title {
    margin: 0 0 15px 0;
    font-size: 1.8em;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    color: white;
}

.box-overlay-content p {
    margin: 0 0 20px 0;
    font-size: 1.1em;
    line-height: 1.5;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
    color: white;
}

.box-overlay-content .chweb-block-icon {
    margin-bottom: 1rem;
}

.box-overlay-content .chweb-block-icon i {
    color: white;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

/* Overlay Button Styles */
.btn-overlay {
    background: rgba(255,255,255,0.9) !important;
    color: #333 !important;
    border: 2px solid rgba(255,255,255,0.9);
    padding: 12px 30px;
    border-radius: 6px;
    font-weight: 500;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-block;
}

.btn-overlay:hover {
    background: white !important;
    color: #333 !important;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* Responsive Overlay Anpassungen */
@media (max-width: 768px) {
    .box-background-image {
        min-height: 250px;
        height: auto;
    }

    .box-overlay-content {
        padding: 30px 15px;
        max-width: 90%;
        height: auto;
    }

    .box-overlay-content .box-title {
        font-size: 1.5em;
    }
}

@media (max-width: 480px) {
    .box-background-image {
        min-height: 200px;
        height: auto;
    }

    .box-overlay-content {
        padding: 20px 10px;
        height: auto;
    }

    .box-overlay-content .box-title {
        font-size: 1.3em;
    }
}

/* ===================================
   ANIMATIONEN
   =================================== */

/* Hover Lift Animation */
.chweb-animation-hover_lift {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.chweb-animation-hover_lift:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 30px rgba(0,0,0,0.2);
}

/* Hover Scale Animation */
.chweb-animation-hover_scale {
    transition: transform 0.3s ease;
}

.chweb-animation-hover_scale:hover {
    transform: scale(1.05);
}

/* Hover Glow Animation */
.chweb-animation-hover_glow {
    transition: box-shadow 0.3s ease;
}

.chweb-animation-hover_glow:hover {
    box-shadow: 0 0 20px rgba(0, 123, 255, 0.5);
}

/* Gradient Animation */
.chweb-animation-gradient {
    background: linear-gradient(45deg, #667eea 0%, #764ba2 100%);
    background-size: 400% 400%;
    animation: gradientShift 4s ease infinite;
    color: white;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Pulse Animation */
.chweb-animation-pulse {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

/* ===================================
   SCHATTEN-STILE
   =================================== */

.chweb-shadow-light {
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.chweb-shadow-normal {
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.chweb-shadow-strong {
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
}

.chweb-shadow-glow {
    box-shadow: 0 0 15px rgba(0, 123, 255, 0.3);
}

/* ===================================
   BUTTON-STILE
   =================================== */

/* Primary Button (Standard) */
.btn-primary {
    background: #434fbf;
    color: white;
    border: 2px solid #007bff;
}

.btn-primary:hover {
    background: #0056b3;
    border-color: #0056b3;
    color: white;
}

/* Secondary Button */
.btn-secondary {
    background: #6c757d;
    color: white;
    border: 2px solid #6c757d;
}

.btn-secondary:hover {
    background: #545b62;
    border-color: #545b62;
    color: white;
}

/* Success Button */
.btn-success {
    background: #28a745;
    color: white;
    border: 2px solid #28a745;
}

.btn-success:hover {
    background: #1e7e34;
    border-color: #1e7e34;
    color: white;
}

/* Warning Button */
.btn-warning {
    background: #ffc107;
    color: #212529;
    border: 2px solid #ffc107;
}

.btn-warning:hover {
    background: #e0a800;
    border-color: #e0a800;
    color: #212529;
}

/* Danger Button */
.btn-danger {
    background: #dc3545;
    color: white;
    border: 2px solid #dc3545;
}

.btn-danger:hover {
    background: #c82333;
    border-color: #c82333;
    color: white;
}

/* Outline Button */
.btn-outline {
    background: transparent;
    color: #007bff;
    border: 2px solid #007bff;
}

.btn-outline:hover {
    background: #007bff;
    color: white;
}

/* Ghost Button */
.btn-ghost {
    background: transparent;
    color: #333;
    border: 2px solid transparent;
    text-decoration: underline;
}

.btn-ghost:hover {
    background: rgba(0,0,0,0.05);
    text-decoration: none;
}

/* Overlay Button Varianten */
.btn-overlay.btn-secondary {
    background: rgba(108, 117, 125, 0.9) !important;
    color: white !important;
    border-color: rgba(108, 117, 125, 0.9);
}

.btn-overlay.btn-success {
    background: rgba(40, 167, 69, 0.9) !important;
    color: white !important;
    border-color: rgba(40, 167, 69, 0.9);
}

.btn-overlay.btn-warning {
    background: rgba(255, 193, 7, 0.9) !important;
    color: #212529 !important;
    border-color: rgba(255, 193, 7, 0.9);
}

.btn-overlay.btn-danger {
    background: rgba(220, 53, 69, 0.9) !important;
    color: white !important;
    border-color: rgba(220, 53, 69, 0.9);
}

.btn-overlay.btn-outline {
    background: transparent !important;
    color: white !important;
    border: 2px solid rgba(255,255,255,0.9);
}

.btn-overlay.btn-ghost {
    background: transparent !important;
    color: white !important;
    border: none;
    text-decoration: underline;
}

/* ===================================
   INTEGRATION MIT BESTEHENDEN STYLES
   =================================== */

/* Kompatibilität mit Theme-Buttons */
.chweb-block-button .btn-primary {
    background: var(--primary-color, #434fbf);
}

.chweb-block-button .btn-primary:hover {
    background: var(--primary-color-dark, #0056b3);
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .chweb-blocks-modern .chweb-block,
    .chweb-blocks-classic .chweb-block {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    .chweb-blocks-title {
        color: #e2e8f0;
    }
    
    .chweb-blocks-minimal .chweb-block {
        color: #e2e8f0;
    }
}