/* Optimizado para Core Web Vitals - Dimensiones máximas desde el inicio */
.breaking-news-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10000;
    width: 400px;
    max-width: 90vw;
    max-height: 320px;
    contain: layout style paint;
    will-change: transform;
    transform: translateZ(0);
    transition: width 0.3s ease, height 0.3s ease;
}

/* Ajuste automático cuando hay una sola noticia */
.breaking-news-widget.single-news {
    height: auto;
}

/* Cuando está minimizado, ajustar el contenedor */
.breaking-news-widget.minimized {
    width: auto;
    height: auto;
    min-width: auto;
    min-height: auto;
}

.minimized-widget {
    display: none;
    background: linear-gradient(135deg, #390E12 0%, #4a1519 100%);
    color: white;
    padding: 1rem 1.25rem;
    border-radius: 50px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    cursor: pointer;
    align-items: center;
    gap: 0.75rem;
    width: fit-content;
    height: fit-content;
    flex-shrink: 0;
}

.breaking-news-widget.minimized .minimized-widget {
    display: flex !important;
}

.breaking-news-widget.minimized .expanded-widget {
    display: none !important;
}

.expanded-widget {
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.2);
    width: 100%;
    height: 100%;
    max-height: 320px;
    display: flex;
    flex-direction: column;
    contain: layout style paint;
}

/* Ajuste automático cuando hay una sola noticia */
.breaking-news-widget.single-news .expanded-widget {
    height: auto;
    max-height: 320px;
}

.widget-header {
    background: linear-gradient(135deg, #390E12 0%, #4a1519 100%);
    color: white;
    padding: 0.75rem 1rem;
    border-radius: 12px 12px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.bell-icon-header {
    font-size: 1rem;
    color: #ffc107;
}

/* Optimización: pausar animación cuando no está visible o cuando el usuario prefiere movimiento reducido */
@media (prefers-reduced-motion: no-preference) {
    .bell-icon-header {
        animation: ring 2s infinite;
    }
}

.widget-title {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 700;
}

.minimize-button {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.minimize-button:hover {
    background: rgba(255,255,255,0.3);
}

.widget-content {
    padding: 0.75rem;
    overflow-y: auto;
    flex: 1;
    max-height: 240px;
    contain: layout style;
}

/* Ajuste automático cuando hay una sola noticia */
.breaking-news-widget.single-news .widget-content {
    overflow-y: visible;
    max-height: none;
}

.news-item {
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.5rem;
    border-radius: 6px;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
    border-left: 3px solid;
}

.news-content-wrapper {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 0.3rem;
}

.news-text-content {
    flex: 1;
    min-width: 0;
}

.news-item-ultima_hora {
    background: #fff3cd;
    border-left-color: #ffc107;
}

.news-item-atencion {
    background: #f8d7da;
    border-left-color: #dc3545;
}

.news-meta {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.3rem;
}

.news-badge {
    padding: 0.15rem 0.4rem;
    font-size: 0.6rem;
    font-weight: 700;
    border-radius: 3px;
    text-transform: uppercase;
}

.badge-ultima_hora {
    background: #ffc107;
    color: #212529;
}

.badge-atencion {
    background: #dc3545;
    color: white;
}

.news-time {
    color: #6c757d;
    font-size: 0.65rem;
}

.news-title {
    margin: 0 0 0.4rem 0;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #212529;
    line-height: 1.3;
}

.news-excerpt {
    display: none;
    margin: 0;
    font-size: 0.75rem;
    color: #6c757d;
    line-height: 1.4;
}

/* Mostrar contenido solo en pantallas grandes (1920x1080 o más) */
@media (min-width: 1920px) {
    .news-excerpt {
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .news-content-wrapper {
        align-items: flex-start;
    }
    
    .news-cta {
        margin-top: 0;
        padding-top: 0;
    }
}

/* Limitar a 3 líneas en pantallas pequeñas */
@media (max-width: 980px) {
    .news-content-wrapper {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .news-cta {
        align-self: flex-end;
        width: 100%;
    }
    
    .cta-button {
        width: 100%;
        justify-content: center;
    }
    
    .news-title {
        display: -webkit-box;
        -webkit-line-clamp: 3;
        line-clamp: 3;
        -webkit-box-orient: vertical;
        overflow: hidden;
        text-overflow: ellipsis;
        max-height: calc(1.3em * 3); /* line-height * número de líneas */
    }
}

/* Widget más compacto en pantallas medianas (menos de 800px de altura) */
@media (max-height: 800px) {
    .breaking-news-widget {
        width: 300px;
        max-width: 85vw;
        max-height: 240px;
        bottom: 15px;
        right: 15px;
    }
    
    .expanded-widget {
        max-height: 240px;
    }
    
    .breaking-news-widget.single-news .expanded-widget {
        max-height: 240px;
    }
    
    .widget-header {
        padding: 0.5rem 0.75rem;
    }
    
    .widget-title {
        font-size: 0.75rem;
    }
    
    .bell-icon-header {
        font-size: 0.875rem;
    }
    
    .minimize-button {
        width: 20px;
        height: 20px;
        font-size: 0.65rem;
    }
    
    .widget-content {
        padding: 0.5rem;
        max-height: 180px;
    }
    
    .breaking-news-widget.single-news .widget-content {
        max-height: none;
        overflow-y: visible;
    }
    
    .news-item {
        padding: 0.4rem 0.5rem;
        margin-bottom: 0.35rem;
    }
    
    .news-badge {
        padding: 0.1rem 0.3rem;
        font-size: 0.55rem;
    }
    
    .news-time {
        font-size: 0.6rem;
    }
    
    .news-title {
        font-size: 0.75rem;
    }
    
    .news-content-wrapper {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.4rem;
    }
    
    .news-cta {
        align-self: flex-end;
        margin-top: 0;
        padding-top: 0;
    }
    
    .cta-button {
        padding: 0.4rem 0.8rem;
        font-size: 0.7rem;
    }
    
    .view-all-link {
        font-size: 0.7rem;
        padding: 0.3rem 0.6rem;
    }
    
    .minimized-widget {
        padding: 0.75rem 1rem;
    }
    
    .minimized-text {
        font-size: 0.8rem;
    }
    
    .bell-icon {
        font-size: 1.1rem;
    }
    
    .news-count {
        padding: 0.2rem 0.4rem;
        font-size: 0.7rem;
    }
}

.news-link {
    color: #212529;
    text-decoration: none;
    display: block;
}

.news-item:hover {
    transform: translateX(4px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.news-link:hover {
    color: #390E12;
    text-decoration: underline;
}

.news-cta {
    margin-top: 0;
    padding-top: 0;
    flex-shrink: 0;
    align-self: flex-start;
}

.cta-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, #ffc107 0%, #ffb300 100%);
    color: #212529;
    text-decoration: none;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 700;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(255, 193, 7, 0.4), 0 2px 4px rgba(0,0,0,0.1);
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

/* Optimización: pausar animación cuando no está visible o cuando el usuario prefiere movimiento reducido */
@media (prefers-reduced-motion: no-preference) {
    .cta-button {
        animation: cta-pulse 2s ease-in-out infinite;
    }
}

.cta-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    transition: left 0.5s ease;
}

.cta-button:hover::before {
    left: 100%;
}

.cta-button:hover {
    background: linear-gradient(135deg, #ffb300 0%, #ffa000 100%);
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 6px 20px rgba(255, 193, 7, 0.6), 0 4px 8px rgba(0,0,0,0.15);
    color: #212529;
}

.cta-button:active {
    transform: translateY(0) scale(0.98);
    box-shadow: 0 2px 8px rgba(255, 193, 7, 0.4);
}

.cta-button i {
    font-size: 0.75rem;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 900;
}

.cta-button:hover i {
    transform: translateX(4px);
}

@keyframes cta-pulse {
    0%, 100% {
        box-shadow: 0 4px 12px rgba(255, 193, 7, 0.4), 0 2px 4px rgba(0,0,0,0.1);
    }
    50% {
        box-shadow: 0 4px 16px rgba(255, 193, 7, 0.6), 0 2px 6px rgba(0,0,0,0.15);
    }
}

/* CTA más destacado para noticias de atención */
.news-item-atencion .cta-button {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.4), 0 2px 4px rgba(0,0,0,0.1);
}

/* Optimización: pausar animación cuando no está visible o cuando el usuario prefiere movimiento reducido */
@media (prefers-reduced-motion: no-preference) {
    .news-item-atencion .cta-button {
        animation: cta-pulse-danger 2s ease-in-out infinite;
    }
}

.news-item-atencion .cta-button:hover {
    background: linear-gradient(135deg, #c82333 0%, #bd2130 100%);
    box-shadow: 0 6px 20px rgba(220, 53, 69, 0.6), 0 4px 8px rgba(0,0,0,0.15);
}

@keyframes cta-pulse-danger {
    0%, 100% {
        box-shadow: 0 4px 12px rgba(220, 53, 69, 0.4), 0 2px 4px rgba(0,0,0,0.1);
    }
    50% {
        box-shadow: 0 4px 16px rgba(220, 53, 69, 0.6), 0 2px 6px rgba(0,0,0,0.15);
    }
}

.widget-footer {
    text-align: center;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid #e9ecef;
}

.view-all-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: #390E12;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.75rem;
    padding: 0.4rem 0.75rem;
    background: #f8f9fa;
    border-radius: 5px;
    transition: background-color 0.2s;
}

.view-all-link:hover {
    background: #e9ecef;
}

.bell-icon {
    font-size: 1.25rem;
    color: #ffc107;
}

/* Optimización: pausar animación cuando no está visible o cuando el usuario prefiere movimiento reducido */
@media (prefers-reduced-motion: no-preference) {
    .bell-icon {
        animation: ring 2s infinite;
    }
}

.minimized-text {
    font-weight: 600;
    font-size: 0.875rem;
}

.news-count {
    background: #ffc107;
    color: #212529;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
    min-width: 24px;
    text-align: center;
}

.minimized-widget:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 25px rgba(0,0,0,0.4);
}

@keyframes ring {
    0%, 100% { transform: rotate(0deg); }
    10%, 30% { transform: rotate(-10deg); }
    20%, 40% { transform: rotate(10deg); }
    50% { transform: rotate(0deg); }
}

@media (max-width: 768px) {
    .breaking-news-widget {
        bottom: 10px;
        right: 10px;
        width: calc(100vw - 20px);
        max-width: calc(100vw - 20px);
        max-height: 280px;
    }
    
    .breaking-news-widget.minimized {
        width: auto;
        height: auto;
    }
    
    .breaking-news-widget.single-news {
        height: auto;
    }
    
    .expanded-widget {
        max-height: 280px;
    }
    
    .breaking-news-widget.single-news .expanded-widget {
        max-height: 280px;
    }
    
    .widget-content {
        max-height: 200px;
    }
}

/* Optimización: remover will-change cuando no se necesita */
.breaking-news-widget:not(:hover):not(.minimized) {
    will-change: auto;
}
