/**
 * Sportkasper Live Plugin Styles
 * Strukturiertes CSS für kategoriebasierte Beitragslisten mit AJAX-Polling
 * 
 * Version: 1.0.0
 * Author: Sportkasper
 */

/* ==========================================================================
   1. ROOT VARIABLES
   ========================================================================== */

:root {
    --skl-primary-color: #0073aa;
    --skl-primary-hover: #005a87;
    --skl-secondary-color: #f8f9fa;
    --skl-border-color: #e0e0e0;
    --skl-text-color: #333;
    --skl-meta-color: #666;
    --skl-error-color: #dc3545;
    --skl-success-color: #28a745;
    --skl-warning-color: #ffc107;
    --skl-border-radius: 4px;
    --skl-spacing-xs: 5px;
    --skl-spacing-sm: 10px;
    --skl-spacing-md: 15px;
    --skl-spacing-lg: 20px;
    --skl-spacing-xl: 30px;
    --skl-image-width: 200px;
    --skl-breakpoint-mobile: 768px;
}

/* ==========================================================================
   2. BASE STYLES
   ========================================================================== */

.sportkasper-live-feed {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    color: var(--skl-text-color);
    margin: var(--skl-spacing-lg) 0;
}

.sportkasper-live-feed * {
    box-sizing: border-box;
}

/* ==========================================================================
   3. LAYOUT STRUCTURE
   ========================================================================== */

/* Sortierung-Links */
.sportkasper-live-sort {
    margin-bottom: var(--skl-spacing-md);
    padding: var(--skl-spacing-sm);
    background: var(--skl-secondary-color);
    border-radius: var(--skl-border-radius);
    border: 1px solid var(--skl-border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sportkasper-live-auto-update {
    color: #992020;
    font-size: 0.8em;
    font-weight: 500;
    animation: pulseRed 2s infinite;
}

.sportkasper-live-sort-links {
    text-align: right;
}

.sportkasper-live-sort-link {
    color: #992020;
    text-decoration: none;
    font-weight: 500;
    padding: var(--skl-spacing-xs) var(--skl-spacing-sm);
    border-radius: var(--skl-border-radius);
    transition: all 0.3s ease;
}

.sportkasper-live-sort-link:hover {
    background: #992020;
    color: white;
    text-decoration: none;
}

.sportkasper-live-sort-link.active {
    background: #992020;
    color: white;
}

/* "Neuer Beitrag" Indikator */
.sportkasper-live-floating-circle {
    position: fixed !important;
    bottom: 50px !important;
    right: 50px !important;
    width: 100px;
    height: 100px;
    background-color: #992020;
    border-radius: 50%;
    z-index: 9999;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    animation: float 3s ease-in-out infinite;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sportkasper-live-floating-circle-text {
    color: #ffffff;
    font-size: 0.75em;
    font-family: "Playfair Display", serif;
    text-align: center;
    line-height: 1.2;
    padding: 5px;
    font-weight: 500;
}

.sportkasper-live-floating-circle:hover {
    background-color: #7a1a1a;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-10px);
    }
}

.sportkasper-live-new-indicator {
    background: #992020;
    color: white;
    padding: var(--skl-spacing-sm) var(--skl-spacing-md);
    border-radius: var(--skl-border-radius);
    margin-bottom: var(--skl-spacing-md);
    cursor: pointer;
    font-weight: 500;
    text-align: center;
    animation: pulse 2s infinite;
    border-left: 4px solid #992020;
}

.sportkasper-live-new-indicator:hover {
    background: #7a1a1a;
}

.sportkasper-live-new-text {
    display: inline-block;
}

/* Loading-Indikator */
.sportkasper-live-loading {
    text-align: center;
    padding: var(--skl-spacing-lg);
    background: var(--skl-secondary-color);
    border-radius: var(--skl-border-radius);
    margin-bottom: var(--skl-spacing-md);
}

.sportkasper-live-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--skl-border-color);
    border-top: 4px solid var(--skl-primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

/* ==========================================================================
   4. POST ITEMS
   ========================================================================== */

.sportkasper-live-posts {
    margin: 0;
    padding: 0;
}

.sportkasper-live-post {
    border: 1px solid #606060;
    border-radius: 0;
    margin-bottom: 10px;
    padding: 0;
    background: white;
    transition: box-shadow 0.3s ease, transform 0.3s ease;
    position: relative;
}

.sportkasper-live-post::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 10px;
    background-color: #606060;
}

.sportkasper-live-post:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.sportkasper-live-post--first {
    /* Blauer Streifen entfernt */
}

/* Post-Titel */
.sportkasper-live-post__title {
    margin: 0 0 0 0 !important;
    font-size: 1.6em;
    font-weight: 600;
    line-height: 1.3;
    transform: translateY(0);
}

.sportkasper-live-post__title a {
    color: #ffffff;
    text-decoration: none;
    transition: color 0.3s ease;
}

.sportkasper-live-post__title a:hover {
    color: #999;
    text-decoration: none;
}

/* Click-Verhalten: Nur Header-Bereich klickbar */

/* Container: Immer normaler Cursor */
.sportkasper-live-post {
    cursor: default;
}

/* Header-Bereich: Klickbar */
.sportkasper-live-post__header {
    background-color: #606060;
    cursor: pointer;
    padding: 0 var(--skl-spacing-lg);
    margin-top: 0;
    position: relative;
    border-radius: 0;
}

.sportkasper-live-post__header * {
    cursor: pointer;
}

/* Content-Bereich: Immer normaler Cursor */
.sportkasper-live-post__content {
    cursor: default;
}

.sportkasper-live-post__content * {
    cursor: default;
}

/* Post-Meta */
.sportkasper-live-post__meta {
    color: #f3f7f6;
    font-size: 0.9em;
    margin-bottom: var(--skl-spacing-sm);
    font-style: italic;
    transition: color 0.3s ease;
    transform: translateY(0);
}

.sportkasper-live-post__meta:hover {
    color: #999;
}


/* Post-Content */
.sportkasper-live-post__content {
    display: flex;
    gap: var(--skl-spacing-lg);
    align-items: flex-start;
    padding: 10px var(--skl-spacing-lg) var(--skl-spacing-lg) var(--skl-spacing-lg);
    position: relative;
    background-color: #f3f7f6;
}

.sportkasper-live-post__image {
    flex-shrink: 0;
    width: var(--skl-image-width);
    height: 200px;
    overflow: hidden;
    border-radius: var(--skl-border-radius);
}

.sportkasper-live-post__image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--skl-border-radius);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.sportkasper-live-post__text {
    flex: 1;
    min-width: 0;
    color: #707070;
}

.sportkasper-live-post__text p {
    margin-bottom: var(--skl-spacing-sm);
    color: #707070;
}

.sportkasper-live-post__text p:last-child {
    margin-bottom: 0;
}

/* "Mehr lesen" Link */
.sportkasper-live-read-more {
    color: var(--skl-primary-color);
    text-decoration: none;
    font-weight: 500;
    padding: var(--skl-spacing-xs) var(--skl-spacing-sm);
    border: 1px solid var(--skl-primary-color);
    border-radius: var(--skl-border-radius);
    display: inline-block;
    margin-top: var(--skl-spacing-sm);
    transition: all 0.3s ease;
}

.sportkasper-live-read-more:hover {
    background: var(--skl-primary-color);
    color: white;
    text-decoration: none;
}

/* Optional: Hover-Effekt für bessere UX */
.sportkasper-live-post:hover {
    background-color: rgba(0, 0, 0, 0.02);
    transition: background-color 0.2s ease;
}

/* ==========================================================================
   5. RESPONSIVE DESIGN
   ========================================================================== */

@media (max-width: 768px) {
    .sportkasper-live-post__content {
        flex-direction: column;
        gap: var(--skl-spacing-md);
    }
    
    .sportkasper-live-post__image {
        width: 100%;
        max-width: 300px;
        margin: 0 auto;
    }
    
    .sportkasper-live-post__title {
        font-size: 1.3em;
    }
    
    .sportkasper-live-post {
        padding: var(--skl-spacing-md);
    }
    
    .sportkasper-live-sort {
        flex-direction: column;
        gap: var(--skl-spacing-sm);
    }
    
    .sportkasper-live-sort-links {
        text-align: center;
    }
    
    .sportkasper-live-sort-link {
        display: inline-block;
        margin: var(--skl-spacing-xs);
    }
}

@media (max-width: 480px) {
    .sportkasper-live-post {
        padding: var(--skl-spacing-sm);
    }
    
    .sportkasper-live-post__title {
        font-size: 1.2em;
    }
    
    .sportkasper-live-post__meta {
        font-size: 0.85em;
    }
}

/* ==========================================================================
   6. LOADING STATES
   ========================================================================== */

.sportkasper-live-feed.loading .sportkasper-live-loading {
    display: block;
}

.sportkasper-live-feed.loading .sportkasper-live-posts {
    opacity: 0.6;
    pointer-events: none;
}

/* ==========================================================================
   7. ERROR STATES
   ========================================================================== */

.sportkasper-live-error {
    background: #f8d7da;
    color: var(--skl-error-color);
    padding: var(--skl-spacing-md);
    border: 1px solid #f5c6cb;
    border-radius: var(--skl-border-radius);
    margin: var(--skl-spacing-lg) 0;
    text-align: center;
    font-weight: 500;
}

/* ==========================================================================
   11. DESKTOP COLLAPSED LAYOUT
   ========================================================================== */
@media (min-width: 769px) {
    /* Collapsed: Bild links 200x200, ohne Verzerrung */
    .sportkasper-live-post:not(.sportkasper-live-post--expanded) .sportkasper-live-post__content {
        display: flex;
        flex-direction: row;
        align-items: flex-start;
        gap: var(--skl-spacing-lg);
    }

    .sportkasper-live-post:not(.sportkasper-live-post--expanded) .sportkasper-live-post__image {
        flex-shrink: 0;
        width: 200px;
        height: 200px;
        margin: 0;
    }

    .sportkasper-live-post:not(.sportkasper-live-post--expanded) .sportkasper-live-post__image img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
}

.sportkasper-live-error::before {
    content: "⚠️ ";
    margin-right: var(--skl-spacing-xs);
}

/* ==========================================================================
   8. ANIMATIONS
   ========================================================================== */

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

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

@keyframes pulseRed {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
    from { transform: translateX(-100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}


/* Neue Beiträge Animation */
.sportkasper-live-post.new-post {
    animation: slideIn 0.5s ease-out;
}

/* ==========================================================================
   9. ACCESSIBILITY
   ========================================================================== */

.sportkasper-live-sort-link:focus,
.sportkasper-live-read-more:focus {
    outline: none;
}

.sportkasper-live-new-indicator:focus {
    outline: 2px solid white;
    outline-offset: 2px;
}

/* Screen Reader Only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ==========================================================================
   12. HEADER HINTERGRUNDBILD
   ========================================================================== */

/* Transparenz-Gradient von oben nach unten - deaktiviert */
.sportkasper-live-post__header::before {
    display: none;
}

/* Header-Content über dem Gradient */
.sportkasper-live-post__header-content {
    position: relative;
    padding-top: 10px;
    padding-bottom: 5px;
    margin-top: 0;
}

/* Status-Bar über dem Gradient */
.sportkasper-live-post__status-bar {
    position: relative;
}


/* Read More Button */
.sportkasper-live-post__read-more {
    position: absolute;
    bottom: 14px;
    right: 10px;
    z-index: 2;
}

.sportkasper-live-read-more {
    background: #ffffff;
    color: #992020;
    padding: 8px 8px;
    border-radius: 3px;
    border: 1px solid #992020;
    text-decoration: none;
    font-size: 0.75em;
    font-weight: 600;
    transition: background-color 0.3s ease;
}

.sportkasper-live-read-more:hover {
    background: #888888;
    color: #992020;
    border: 1px solid #992020;
    text-decoration: none;
}

/* Read More Button nur bei collapsed Posts anzeigen */
.sportkasper-live-post--expanded .sportkasper-live-post__read-more {
    display: none;
}

@media print {
    .sportkasper-live-sort,
    .sportkasper-live-new-indicator,
    .sportkasper-live-loading {
        display: none;
    }
    
    .sportkasper-live-post {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }
    
    .sportkasper-live-post__title a {
        color: black;
        text-decoration: none;
    }
    
    .sportkasper-live-read-more {
        display: none;
    }
}

/* ==========================================================================
   11. POST EXPANSION
   ========================================================================== */

/* Post-Expansion States */
.sportkasper-live-post--expanded {
    border-color: #1c110a;
    box-shadow: 0 4px 15px rgba(0, 115, 170, 0.2);
}

.sportkasper-live-post--expanded .sportkasper-live-post__header {
    background-color: #1c110a;
}

.sportkasper-live-post--expanded::after {
    background-color: #1c110a;
}

.sportkasper-live-post--expanded .sportkasper-live-post__title-link {
    color: #e2e2e2;
    font-weight: 600;
}

.sportkasper-live-post--expanded .sportkasper-live-post__title {
    color: #e2e2e2;
}

.sportkasper-live-post--expanded .sportkasper-live-post__image {
    display: none;
}

/* Content-Container für Expansion */
.sportkasper-live-post__text {
    overflow: hidden;
}

.sportkasper-live-post__excerpt,
.sportkasper-live-post__full {
    transition: opacity 0.3s ease;
}

/* Slide-Animationen */
.sportkasper-live-post__excerpt.slide-up {
    transform: translateY(-100%);
    opacity: 0;
}

.sportkasper-live-post__full.slide-down {
    transform: translateY(0);
    opacity: 1;
}

/* Hover-Effekte für Titel-Links */
.sportkasper-live-post__title-link {
    transition: none;
    cursor: pointer;
    color: inherit;
    text-decoration: none;
}

.sportkasper-live-post__title-link:hover {
    color: #999;
    text-decoration: none;
}

/* Loading-State für Expansion */
.sportkasper-live-post--loading .sportkasper-live-post__title-link {
    opacity: 0.6;
    cursor: wait;
}

.sportkasper-live-post--loading .sportkasper-live-post__title-link::after {
    content: " ⟳";
    animation: spin 1s linear infinite;
    margin-left: 5px;
}

/* Status-Streifen für jeden Post */
.sportkasper-live-post__status-bar {
    height: 35px;
    background-color: #a2a2a2;
    margin: 0 calc(-1 * var(--skl-spacing-lg)) 0 calc(-1 * var(--skl-spacing-lg)); /* Negatives Margin für links und rechts */
    padding: 4px var(--skl-spacing-lg); /* Padding nur horizontal */
    font-size: 13px;
    color: #333;
    cursor: pointer;
    transition: background-color 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center; /* Text zentrieren */
    border-radius: 0; /* Nur oben abgerundet */
}

.sportkasper-live-post__status-bar:hover {
    background-color: #888888; /* Dunkleres Grau beim Hover */
}

.sportkasper-live-post__status-bar.has-new {
    background-color: rgba(153, 32, 32, 0.8); /* Transparentes Dunkelrot */
    color: white;
}

.sportkasper-live-post__status-bar.has-new:hover {
    background-color: rgba(122, 26, 26, 0.9); /* Transparentes dunkleres Dunkelrot beim Hover */
}

.sportkasper-live-post__status-text {
    font-weight: 500;
}
