/* Articles Grid - Version corrigée */
.articles-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
    margin-bottom: 40px;
    max-width: 100%;
}

/* Responsive breakpoints non-chevauchants */
@media (min-width: 768px) {
    .articles-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
}

@media (min-width: 1200px) {
    .articles-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 24px;
    }
}

@media (min-width: 1600px) {
    .articles-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 28px;
    }
}

/* Style alternatif masonry - Version corrigée */
.articles-grid--masonry {
    display: block;
    column-count: 1;
    column-gap: 24px;
    column-fill: balance;
    grid-template-columns: none; /* Override grid */
}

@media (min-width: 768px) {
    .articles-grid--masonry {
        column-count: 2;
        column-gap: 20px;
    }
}

@media (min-width: 1200px) {
    .articles-grid--masonry {
        column-count: 3;
        column-gap: 24px;
    }
}

@media (min-width: 1600px) {
    .articles-grid--masonry {
        column-count: 4;
        column-gap: 24px;
    }
}

.articles-grid--masonry .article-card {
    break-inside: avoid;
    margin-bottom: 24px;
    display: block !important;
    width: 100%;
    /* Reset flex properties for masonry */
    min-height: auto;
    height: auto;
    page-break-inside: avoid; /* Fallback for older browsers */
    /* Force block layout */
    flex-direction: column;
    align-items: stretch;
}

/* Ensure content flows properly in masonry */
.articles-grid--masonry .article-card__content {
    margin-bottom: 16px;
    flex-grow: 0;
}

.articles-grid--masonry .article-card__actions {
    margin-top: 16px;
    flex-shrink: 0;
}

/* Fix for nested grid in masonry */
.articles-grid--masonry .articles-grid {
    display: block;
    column-count: inherit;
    column-gap: inherit;
}

/* Navigation Controls */
.nav__controls {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

/* Format Toggle */
.format-toggle {
    display: flex;
    background: var(--white, #ffffff);
    border-radius: 8px;
    padding: 3px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(0,0,0,0.06);
    margin-right: 12px;
}

.format-toggle__btn {
    padding: 8px 12px;
    border: none;
    background: transparent;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-light, #999);
    white-space: nowrap;
    min-width: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.format-toggle__btn.active {
    background: var(--primary, #2196F3);
    color: white;
    box-shadow: 0 1px 3px rgba(33, 150, 243, 0.3);
}

.format-toggle__btn:not(.active):hover {
    background: rgba(33, 150, 243, 0.1);
    color: var(--primary, #2196F3);
}

/* View Toggle */
.view-toggle {
    display: flex;
    background: var(--white, #ffffff);
    border-radius: 8px;
    padding: 3px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(0,0,0,0.06);
}

.view-toggle__btn {
    padding: 8px 12px;
    border: none;
    background: transparent;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-light, #999);
    white-space: nowrap;
    min-width: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.view-toggle__btn.active {
    background: var(--success, #4CAF50);
    color: white;
    box-shadow: 0 1px 3px rgba(76, 175, 80, 0.3);
}

.view-toggle__btn:not(.active):hover {
    background: rgba(76, 175, 80, 0.1);
    color: var(--success, #4CAF50);
}

.article-card {
    background: var(--white);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    border: 1px solid rgba(0,0,0,0.06);
    overflow: hidden;
    height: fit-content;
    min-height: 320px;
    display: flex;
    flex-direction: column;
}

.article-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--medium-gray), var(--medium-gray));
    transition: all 0.3s ease;
}

.article-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.12);
    border-color: rgba(0,0,0,0.1);
}

.article-card:hover::before {
    height: 6px;
}

.article-card--court::before {
    background: linear-gradient(90deg, #FF6B35, #F7931E);
}

.article-card--moyen::before {
    background: linear-gradient(90deg, #2196F3, #21CBF3);
}

.article-card--long::before {
    background: linear-gradient(90deg, #4CAF50, #8BC34A);
}

.article-card--published {
    background: linear-gradient(135deg, #f8fff8 0%, #f0fdf4 100%);
    border-color: rgba(76, 175, 80, 0.1);
}

.article-card--published::after {
    content: '✅';
    position: absolute;
    top: 16px;
    right: 16px;
    font-size: 16px;
    opacity: 0.7;
}

.article-card__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.article-card__title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0;
    flex: 1;
    margin-right: 12px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 8px;
}

.article-card__priority {
    flex-shrink: 0;
    font-size: 18px;
    opacity: 0.8;
}

.article-card__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.format-badge,
.channel-badge,
.date-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 16px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.format-badge--court {
    background: linear-gradient(135deg, #FF6B35, #F7931E);
    color: white;
}

.format-badge--moyen {
    background: linear-gradient(135deg, #2196F3, #21CBF3);
    color: white;
}

.format-badge--long {
    background: linear-gradient(135deg, #4CAF50, #8BC34A);
    color: white;
}

.channel-badge {
    background: rgba(0,0,0,0.05);
    color: #666;
    border: 1px solid rgba(0,0,0,0.1);
}

.date-badge {
    background: rgba(0,0,0,0.03);
    color: #888;
    font-size: 10px;
}

.article-card__content {
    color: #4a5568;
    margin-bottom: 16px;
    line-height: 1.6;
    font-size: 14px;
    position: relative;
    max-height: 120px;
    overflow: hidden;
    flex-grow: 1;
}

.article-card__content::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 30px;
    background: linear-gradient(transparent, var(--white));
    pointer-events: none;
}

.article-card__actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn--small {
    padding: 6px 12px;
    font-size: 12px;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal__backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
}

.modal__content {
    background: var(--white);
    border-radius: var(--border-radius);
    max-width: 600px;
    width: 90%;
    max-height: 90%;
    overflow-y: auto;
    position: relative;
    z-index: 1;
}

.modal__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 20px 0;
    border-bottom: 1px solid var(--medium-gray);
    margin-bottom: 20px;
}

.modal__header h2 {
    margin: 0;
    color: var(--primary);
}

.modal__close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 5px;
    color: var(--dark-gray);
}

/* Forms */
.article-form {
    padding: 0 20px 20px;
}

.form-group {
    margin-bottom: 20px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #333;
    white-space: nowrap;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--medium-gray);
    border-radius: var(--border-radius);
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.form-group textarea {
    resize: vertical;
    min-height: 120px;
}

.checkbox-label {
    display: flex !important;
    align-items: center;
    cursor: pointer;
    font-weight: normal !important;
}

.checkbox-label input[type="checkbox"] {
    width: auto !important;
    margin-right: 10px;
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--medium-gray);
}

/* États vides */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--dark-gray);
}

.empty-state h3 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: var(--primary);
}

/* Format Tabs dans le formulaire */
.formats-container {
    margin-bottom: 20px;
}

/* Sélecteurs de canaux */
.channels-selector {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
    margin-top: 8px;
}

.channel-checkbox {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    border: 2px solid var(--medium-gray);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--white);
}

.channel-checkbox:hover {
    border-color: var(--primary);
    background: rgba(33, 150, 243, 0.05);
}

.channel-checkbox input[type="checkbox"] {
    margin-right: 8px;
    width: auto;
}

.channel-checkbox input[type="checkbox"]:checked + .channel-label {
    color: var(--primary);
    font-weight: 600;
}

.channel-checkbox:has(input:checked) {
    border-color: var(--primary);
    background: rgba(33, 150, 243, 0.1);
}

.channel-label {
    font-size: 12px;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.format-tabs {
    display: flex;
    border-bottom: 2px solid var(--medium-gray);
    margin-bottom: 20px;
}

.format-tab {
    padding: 12px 20px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 3px solid transparent;
    transition: all 0.2s ease;
}

.format-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: rgba(33, 150, 243, 0.05);
}

.format-tab:hover:not(.active) {
    color: var(--primary);
    background: rgba(33, 150, 243, 0.02);
}

.format-content {
    display: none;
}

.format-content.active {
    display: block;
}

.format-info {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 5px;
    padding: 8px 12px;
    background: rgba(33, 150, 243, 0.05);
    border-radius: 4px;
    border-left: 3px solid var(--primary);
}

/* Responsive pour composants */
@media (max-width: 768px) {
    .articles-grid {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .article-card__actions {
        justify-content: center;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .format-tabs {
        flex-direction: column;
    }
    
    .format-tab {
        text-align: left;
        border-bottom: 1px solid var(--medium-gray);
        border-right: 3px solid transparent;
    }
    
    .format-tab.active {
        border-bottom-color: var(--medium-gray);
        border-right-color: var(--primary);
    }
}


.article-card__actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid rgba(0,0,0,0.06);
    flex-shrink: 0;
}

.actions-primary,
.actions-secondary {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.btn--small {
    padding: 8px 12px;
    font-size: 11px;
    border-radius: 6px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
    white-space: nowrap;
}

.btn--small:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.btn--info {
    background: linear-gradient(135deg, #17a2b8, #20c997);
    color: white;
}

.btn--info:hover {
    background: linear-gradient(135deg, #138496, #1e7e34);
}

.copy-btn {
    background: linear-gradient(135deg, #6c757d, #495057);
    color: white;
}

.copy-btn:hover {
    background: linear-gradient(135deg, #5a6268, #343a40);
}

.edit-btn {
    background: linear-gradient(135deg, #ffc107, #ffb300);
    color: #333;
}

.edit-btn:hover {
    background: linear-gradient(135deg, #e0a800, #ff8f00);
}

.share-btn {
    background: linear-gradient(135deg, #28a745, #20c997);
    color: white;
}

.share-btn:hover {
    background: linear-gradient(135deg, #218838, #1e7e34);
}

.dropdown-toggle {
    background: linear-gradient(135deg, #6f42c1, #e83e8c);
    color: white;
    position: relative;
}

.dropdown-toggle:hover {
    background: linear-gradient(135deg, #5a32a3, #d91a72);
}

/* Badge template actif sur les cartes */
.article-card[data-template-enabled="true"]::before {
    content: "🎨";
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--accent);
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    z-index: 1;
}

/* Style pour les cartes avec groupe - Version moderne */
.article-card[data-group-name]:not([data-group-id]) {
    position: relative;
    border-left: 4px solid var(--primary);
    background: linear-gradient(135deg, #ffffff 0%, #f8f9ff 100%);
}

.article-card[data-group-name]:not([data-group-id])::after {
    content: attr(data-group-name);
    position: absolute;
    top: -8px;
    left: 12px;
    background: linear-gradient(135deg, var(--primary), #1976d2);
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    z-index: 2;
    box-shadow: 0 2px 4px rgba(33, 150, 243, 0.3);
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.article-card[data-group-name]:not([data-group-id]):hover::after {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(33, 150, 243, 0.4);
}

/* Style alternatif si les deux attributs sont présents */
.article-card[data-group-name][data-group-id] {
    border-left: 4px solid var(--success);
    background: linear-gradient(135deg, #ffffff 0%, #f0fff4 100%);
}

/* Sample Data Modal - Version aérée */
.sample-data-modal .modal__content {
    max-width: 750px;
    padding: 0;
}

.sample-data-modal .modal__header {
    padding: 28px 32px 20px;
    margin-bottom: 24px;
}

.sample-data-modal .modal__body {
    padding: 0 32px;
}

.sample-data-modal .modal__footer {
    padding: 24px 32px 28px;
    margin-top: 32px;
}

.sample-data-info {
    padding: 0;
}

.sample-data-info p {
    color: #666;
    margin-bottom: 28px;
    line-height: 1.7;
    font-size: 15px;
}

.sample-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 20px;
    margin: 32px 0;
    padding: 28px;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-radius: 16px;
    border: 1px solid rgba(0,0,0,0.06);
}

.sample-stat {
    text-align: center;
    padding: 20px 16px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    transition: transform 0.2s ease;
}

.sample-stat:hover {
    transform: translateY(-2px);
}

.sample-stat__number {
    display: block;
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 8px;
}

.sample-stat__label {
    font-size: 13px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 600;
}

.sample-details {
    margin-top: 32px;
}

.sample-details h4 {
    color: var(--primary);
    margin: 28px 0 16px 0;
    font-size: 15px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sample-breakdown {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 24px;
}

.sample-tag {
    background: rgba(33, 150, 243, 0.1);
    color: var(--primary);
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 13px;
    font-weight: 600;
    border: 1px solid rgba(33, 150, 243, 0.2);
    transition: all 0.2s ease;
}

.sample-tag:hover {
    background: rgba(33, 150, 243, 0.15);
    transform: translateY(-1px);
}

.sample-warning {
    background: linear-gradient(135deg, #fff3cd, #ffeaa7);
    border: 1px solid #ffc107;
    border-radius: 12px;
    padding: 20px;
    margin-top: 28px;
}

.sample-warning p {
    margin: 0;
    color: #856404;
    font-size: 14px;
    line-height: 1.6;
}

/* Autres formats disponibles */
.article-card__other-formats {
    margin: 12px 0;
    padding: 8px 12px;
    background: rgba(33, 150, 243, 0.05);
    border-radius: 6px;
    border-left: 3px solid var(--primary);
}

.other-formats-label {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 600;
}

.other-formats-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.other-format-badge {
    font-size: 10px;
    padding: 3px 6px;
    border-radius: 10px;
    background: rgba(0,0,0,0.05);
    color: var(--text-secondary);
    border: 1px solid rgba(0,0,0,0.1);
    transition: all 0.2s ease;
}

.other-format-badge.published {
    background: rgba(76, 175, 80, 0.1);
    color: var(--success);
    border-color: rgba(76, 175, 80, 0.2);
}

.other-format-badge.draft {
    background: rgba(255, 193, 7, 0.1);
    color: var(--warning);
    border-color: rgba(255, 193, 7, 0.2);
}

.other-format-badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Tags et statistiques de contenu */
.article-card__tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 12px 0 16px 0;
}

.article-tag {
    background: rgba(0,0,0,0.05);
    color: #666;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 500;
    border: 1px solid rgba(0,0,0,0.08);
    transition: all 0.2s ease;
}

.article-tag:hover {
    background: rgba(33, 150, 243, 0.1);
    color: var(--primary);
    border-color: rgba(33, 150, 243, 0.2);
}

.more-tags {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.article-card__content-stats {
    display: flex;
    gap: 12px;
    margin: 12px 0;
    padding: 8px 0;
    border-top: 1px solid rgba(0,0,0,0.06);
    font-size: 11px;
    color: #888;
}

.content-stat {
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 500;
    background: rgba(0,0,0,0.03);
    padding: 2px 6px;
    border-radius: 8px;
}

/* Améliorations responsive */
@media (max-width: 767px) {
    .articles-grid {
        grid-template-columns: 1fr !important;
        gap: 20px;
    }
    
    .articles-grid--masonry {
        column-count: 1 !important;
        display: block;
    }
    
    .article-card {
        padding: 20px;
        min-height: 280px;
    }
    
    .article-card__title {
        font-size: 1rem;
    }
    
    .article-card__content {
        font-size: 13px;
        max-height: 100px;
    }
    
    .article-card__actions {
        flex-direction: column;
        gap: 8px;
    }
    
    .actions-primary,
    .actions-secondary {
        justify-content: center;
        width: 100%;
    }
    
    .btn--small {
        padding: 6px 10px;
        font-size: 10px;
    }
    
    .sample-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .article-card__content-stats {
        flex-wrap: wrap;
        gap: 6px;
    }
    
    .content-stat {
        font-size: 10px;
    }
    
    /* Navigation responsive */
    .nav__controls {
        flex-direction: column;
        gap: 12px;
        width: 100%;
    }
    
    .nav__search {
        width: 100%;
    }
    
    .nav__search input {
        width: 100%;
    }
    
    .unified-toggle {
        align-self: center;
    }
    
    /* Masonry mobile fix */
    .articles-grid--masonry {
        column-count: 1 !important;
        column-gap: 0;
    }
    
    .articles-grid--masonry .article-card {
        margin-bottom: 20px;
        width: 100%;
    }
}