/* News Manager Styles - Enhanced Version 3.3 */

/* Variables */
:root {
    --nm-primary: #6B9BD1;
    --nm-secondary: #4E7A95;
    --nm-success: #8FBC8F;
    --nm-dark: #36424B;
    --nm-accent: #B4C6D3;
}

/* Base */
.nm-dashboard,
.nm-dashboard * {
    box-sizing: border-box;
    font-family: 'Poppins', sans-serif;
}

.nm-dashboard {
    max-width: 1000px;
    margin: 0 auto;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    overflow: hidden;
}

/* Tabs */
.nm-tabs {
    display: flex;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.nm-tab {
    flex: 1;
    padding: 16px 24px;
    background: none;
    border: none;
    font-weight: 500;
    color: #6c757d;
    cursor: pointer;
    transition: all 0.3s ease;
}

.nm-tab:hover:not(.active) {
    background: #f1f1f1;
}

.nm-tab.active {
    color: var(--nm-primary);
    border-bottom: 3px solid var(--nm-primary);
    background: #ffffff;
}

.nm-tab-content {
    display: none;
    padding: 30px;
}

.nm-tab-content.active {
    display: block;
}

.nm-section {
    margin-bottom: 30px;
}

.nm-section h2 {
    font-size: 1.5rem;
    color: var(--nm-dark);
    margin-top: 0;
    margin-bottom: 20px;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

/* Forms and Fields */
.nm-form {
    max-width: 800px;
    margin: 0 auto;
}

.nm-field {
    margin-bottom: 20px;
}

.nm-field label {
    display: block;
    font-weight: 500;
    color: var(--nm-dark);
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.nm-field input[type="text"],
.nm-field textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.nm-field input[type="text"]:focus,
.nm-field textarea:focus {
    border-color: var(--nm-primary);
    outline: none;
    box-shadow: 0 0 0 2px rgba(107, 155, 209, 0.2);
}

.nm-help-text {
    font-size: 0.85rem;
    color: #888;
    margin-top: 5px;
}

/* Quill Editor */
.nm-editor {
    height: 200px;
    border: 1px solid #ccc;
    border-radius: 6px;
    overflow: hidden;
}

.nm-editor .ql-container {
    border: none;
    font-family: 'Poppins', sans-serif;
    font-size: 1rem;
}

.nm-editor .ql-toolbar {
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
    background-color: #f8f8f8;
}

/* Checkbox */
.nm-checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: normal;
    font-size: 1rem;
}

.nm-checkbox-label input[type="checkbox"] {
    margin-right: 10px;
    width: 18px;
    height: 18px;
}

/* Buttons */
.nm-btn-primary {
    background: var(--nm-primary);
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s ease;
    display: inline-block;
    font-size: 1rem;
}

.nm-btn-primary:hover {
    background: #5a88c0;
}

.nm-btn-secondary {
    background: #ccc;
    color: var(--nm-dark);
    border: none;
    padding: 12px 25px;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.3s ease;
    display: inline-block;
    font-size: 1rem;
}

.nm-btn-secondary:hover {
    background: #bbb;
}

.nm-btn-upload {
    background: var(--nm-accent);
    color: var(--nm-dark);
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.nm-btn-upload:hover {
    background: #a9bdcb;
}

/* Images Upload/Preview */
.nm-images-gallery {
    margin-top: 15px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
}

/* 🔥 CORRECCIÓN FINAL Y REFORZADA: Estilos de Máxima Especificidad (Anidados) */

.nm-dashboard .nm-image-preview {
    position: relative !important; 
    width: 100% !important;
    height: 120px !important;
    border-radius: 6px !important;
    overflow: hidden !important;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1) !important;
    line-height: 0 !important;
}

.nm-dashboard .nm-image-preview img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block !important;
}

.nm-dashboard .nm-remove-image {
    position: absolute !important;
    top: 5px !important;
    right: 5px !important;
    
    /* Diseño del círculo/fondo */
    background: rgba(0, 0, 0, 0.4) !important; /* Fondo semi-transparente oscuro */
    border: none !important;
    border-radius: 50% !important; /* Forma circular */
    
    /* Dimensiones */
    width: 24px !important;
    height: 24px !important;
    
    /* Estilos de la 'X' */
    color: #fff !important; /* Color blanco */
    font-size: 18px !important; 
    
    /* Centrado de la 'X' dentro del círculo */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    line-height: 1 !important;
    padding: 0 !important;
    
    cursor: pointer !important;
    opacity: 0.9 !important;
    transition: opacity 0.2s, background 0.2s !important;
    z-index: 10 !important;
}

.nm-dashboard .nm-remove-image:hover {
    opacity: 1 !important;
    background: var(--nm-primary) !important; /* Resaltar con el color primario */
    color: #fff !important;
}
/* 🔥 FIN DE CORRECCIÓN FINAL Y REFORZADA */


/* Messages */
.nm-message {
    margin-top: 20px;
    padding: 15px;
    border-radius: 6px;
    font-weight: 500;
}

.nm-message.success {
    background: rgba(143, 188, 143, 0.15);
    color: var(--nm-success);
    border: 1px solid var(--nm-success);
}

/* News List (Dashboard) */
.nm-news-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.nm-news-item {
    display: flex;
    align-items: center;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 15px;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    transition: box-shadow 0.2s ease;
}

.nm-news-item:hover {
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
}

.nm-news-thumb {
    width: 70px;
    height: 70px;
    min-width: 70px;
    border-radius: 6px;
    overflow: hidden;
    margin-right: 15px;
    background: #f0f0f0;
}

.nm-news-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.nm-news-info {
    /* Asegura que la información crezca pero respeta el espacio de los botones */
    flex-grow: 1; 
    padding-right: 15px;
}

.nm-news-info h4 {
    margin: 0 0 5px 0;
    font-size: 1.1rem;
    color: var(--nm-dark);
    font-weight: 600;
}

.nm-news-info p {
    /* La descripción breve irá aquí */
    margin: 0 0 5px 0;
    font-size: 0.9rem;
    color: #6c757d;
    line-height: 1.4;
}

.nm-news-meta {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 5px;
}

.nm-news-date {
    font-size: 0.8rem;
    color: #999;
}

.nm-newsletter-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(107, 155, 209, 0.1);
    color: var(--nm-primary);
    font-size: 0.75rem;
    font-weight: 600;
}

.nm-news-actions {
    /* Evita que los botones salten de línea */
    display: flex;
    gap: 8px;
    white-space: nowrap;
    min-width: fit-content;
}

.nm-btn-view,
.nm-btn-edit,
.nm-btn-delete {
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: opacity 0.2s ease;
}

.nm-btn-view {
    background: var(--nm-accent);
    color: var(--nm-dark);
}

.nm-btn-view:hover {
    opacity: 0.8;
}

.nm-btn-edit {
    background: var(--nm-primary);
    color: white;
}

.nm-btn-edit:hover {
    opacity: 0.8;
}

.nm-btn-delete {
    background: #dc3545;
    color: white;
}

.nm-btn-delete:hover {
    background: #c82333;
}

/* Modal */
.nm-modal {
    display: none; 
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.4);
}

.nm-modal-content {
    background-color: #fefefe;
    margin: 10% auto;
    padding: 30px;
    border-radius: 8px;
    width: 90%;
    max-width: 700px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    position: relative;
    animation-name: animatetop;
    animation-duration: 0.4s
}

@keyframes animatetop {
    from {top: -300px; opacity: 0}
    to {top: 0; opacity: 1}
}

.nm-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.nm-modal-header h3 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--nm-dark);
}

/* Estilo minimalista para la 'X' (cierre de modal) */
.nm-modal-close {
    cursor: pointer;
    font-size: 28px;
    font-weight: 300;
    color: #6c757d; 
    line-height: 1;
    transition: color 0.2s ease;
    padding: 0 4px; 
    background: none; 
    border: none;
}

.nm-modal-close:hover {
    color: var(--nm-dark); 
}

.nm-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

/* Carousel Styles */
.nm-carousel-container {
    padding: 30px 0;
    margin: 0 auto;
    max-width: 1200px;
}

.nm-carousel-header {
    text-align: center;
    margin-bottom: 30px;
}

.nm-carousel-header h2 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--nm-dark);
    margin: 0;
}

.nm-card {
    background: #ffffff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.nm-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12);
}

.nm-card-image {
    width: 100%;
    height: 180px;
    overflow: hidden;
}

.nm-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.nm-card-content {
    padding: 20px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.nm-card-date {
    font-size: 0.8rem;
    color: var(--nm-primary);
    font-weight: 600;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.nm-card-content h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--nm-dark);
    margin: 0 0 10px 0;
    line-height: 1.3;
}

.nm-card-content p {
    font-size: 0.95rem;
    color: #6c757d;
    margin-bottom: 15px;
    flex-grow: 1;
}

.nm-card-link {
    display: inline-block;
    color: var(--nm-primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: color 0.2s ease;
    margin-top: auto;
}

.nm-card-link:hover {
    color: var(--nm-secondary);
}

/* Swiper overrides */
.nm-swiper {
    padding-bottom: 40px; 
}

.swiper-pagination-bullet-active {
    background: var(--nm-primary);
}

.swiper-button-next,
.swiper-button-prev {
    color: var(--nm-primary);
}

.swiper-button-next:after,
.swiper-button-prev:after {
    font-size: 20px;
}

/* Responsive */
@media (max-width: 768px) {
    .nm-dashboard {
        margin: 10px;
        border-radius: 12px;
    }
    
    .nm-tab {
        padding: 12px 16px;
        font-size: 13px;
    }
    
    .nm-tab-content {
        padding: 20px;
    }
    
    .nm-form {
        max-width: 100%;
    }
    
    .nm-images-gallery {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 8px;
    }
    
    .nm-news-item {
        flex-direction: column;
        text-align: center;
    }
    
    .nm-news-thumb {
        align-self: center;
        width: 100px;
        height: 100px;
        margin-right: 0;
        margin-bottom: 10px;
    }

    .nm-news-info {
        padding-right: 0;
        text-align: center;
    }
    
    .nm-news-actions {
        flex-direction: row;
        width: 100%;
        justify-content: center;
        margin-top: 10px;
    }

    .nm-btn-view,
    .nm-btn-edit,
    .nm-btn-delete {
        flex: 1;
        max-width: 120px;
        padding: 10px 0;
    }

    .nm-modal-content {
        margin: 5% auto;
    }
}