/* Reset et base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    background: white;
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.header h1 {
    font-size: 2.5rem;
    color: #2c3e50;
    margin-bottom: 10px;
}

.header-actions {
    display: flex;
    gap: 15px;
}

/* Boutons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #34495e;
    color: white;
}

.btn-secondary:hover {
    background: #2c3e50;
    transform: translateY(-2px);
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
}

/* Statistiques */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    text-align: center;
    transition: all 0.3s ease;
    border-left: 4px solid #3498db;
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.12);
}

.stat-card:nth-child(1) {
    border-left-color: #3498db;
    background: linear-gradient(135deg, #ebf3fd 0%, #d6e9f8 100%);
}

.stat-card:nth-child(2) {
    border-left-color: #2ecc71;
    background: linear-gradient(135deg, #e8f5e8 0%, #d4f1d4 100%);
}

.stat-card:nth-child(3) {
    border-left-color: #e74c3c;
    background: linear-gradient(135deg, #fdeaea 0%, #f8d7da 100%);
}

.stat-card:nth-child(4) {
    border-left-color: #f39c12;
    background: linear-gradient(135deg, #fef9e7 0%, #fcf4dd 100%);
}

.stat-card:nth-child(5) {
    border-left-color: #9b59b6;
    background: linear-gradient(135deg, #f4ecf7 0%, #e8d5ed 100%);
}

.stat-number {
    font-size: 2.2rem;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 8px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.stat-label {
    color: #5a6c7d;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 600;
}

/* Filtres redesignés */
.filters-container {
    background: white;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 30px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.08);
}

.filters-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1.5fr;
    gap: 20px;
    align-items: end;
}

.filter-item {
    display: flex;
    flex-direction: column;
}

.filter-item label {
    font-weight: 600;
    margin-bottom: 6px;
    color: #2c3e50;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-item select,
.filter-item input {
    padding: 10px 12px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    background: white;
    height: 42px;
}

.filter-item select:focus,
.filter-item input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.filter-item input::placeholder {
    color: #adb5bd;
    font-style: italic;
}

/* Responsive pour les filtres */
@media (max-width: 1024px) {
    .filters-row {
        grid-template-columns: 1fr 1fr;
        gap: 15px;
    }
}

@media (max-width: 768px) {
    .filters-row {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .filters-container {
        padding: 15px;
    }
}

/* Loading */
.loading {
    text-align: center;
    padding: 50px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #ecf0f1;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

/* Messages d'erreur et no-data */
.error-message,
.no-data {
    text-align: center;
    padding: 60px 20px;
    color: #7f8c8d;
}

.no-data h3 {
    margin-bottom: 15px;
    color: #34495e;
}

.no-company-selected {
    text-align: center;
    padding: 80px 20px;
    color: #7f8c8d;
    background: #f8f9fa;
    border-radius: 15px;
    margin: 20px auto;
    max-width: 600px;
}

.no-company-selected h3 {
    margin-bottom: 15px;
    color: #34495e;
    font-size: 1.5rem;
}

.no-company-selected p {
    font-size: 1.1rem;
    line-height: 1.6;
}

.webhook-info {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
    text-align: left;
}

.webhook-info code {
    background: #e9ecef;
    padding: 8px 12px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    display: block;
    margin: 10px 0;
    word-break: break-all;
}

/* Posts - Compact 3-Column Layout */
.posts-container {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 15px;
    width: 100%;
    min-width: 0;
}

.posts-container .no-company-selected {
    grid-column: 1 / -1;
    justify-self: center;
}

@media (max-width: 1200px) {
    .posts-container {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (max-width: 768px) {
    .posts-container {
        grid-template-columns: 1fr !important;
    }
}

.post-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 3px 12px rgba(0,0,0,0.06);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
    height: 300px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.post-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.12);
}

.post-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.post-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.post-date {
    color: #7f8c8d;
    font-size: 13px;
    font-weight: 500;
}

.post-type {
    color: #3498db;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    background: #e8f4fd;
    padding: 4px 8px;
    border-radius: 6px;
    display: inline-block;
}

.post-campaign {
    color: #e74c3c;
    font-size: 12px;
    font-weight: 500;
}

.post-metrics {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    flex-shrink: 0;
    background: #f8f9fa;
    padding: 12px;
    border-radius: 8px;
}

.metric {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    color: #34495e;
    font-size: 12px;
    font-weight: 500;
    text-align: center;
}

.metric-icon {
    font-size: 16px;
    margin-bottom: 2px;
}

.metric-value {
    font-weight: 600;
    color: #2c3e50;
    font-size: 14px;
}

.metric small {
    font-size: 10px;
    color: #7f8c8d;
    text-transform: uppercase;
    font-weight: 500;
}

.post-content {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.post-title {
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
    line-height: 1.3;
    margin: 0;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    text-overflow: ellipsis;
}

.post-content-preview {
    font-size: 14px;
    line-height: 1.5;
    color: #4a5568;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    line-clamp: 4;
    -webkit-box-orient: vertical;
    text-overflow: ellipsis;
    margin-top: 5px;
}

.post-footer {
    margin-top: auto;
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.post-author {
    font-size: 11px;
    color: #7f8c8d;
    font-weight: 500;
}

.post-metrics-compact {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.metric-compact {
    font-size: 10px;
    color: #95a5a6;
    background: #f8f9fa;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
}

.post-company {
    font-size: 0.8rem;
    color: #0066cc;
    font-weight: 600;
}

.post-link {
    color: #3498db;
    text-decoration: none;
    font-weight: 500;
    display: inline-block;
    margin: 10px 0;
}

.post-link:hover {
    text-decoration: underline;
}

.post-author {
    color: #7f8c8d;
    font-size: 14px;
    margin: 10px 0;
}

.post-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #ecf0f1;
}

.stat-item {
    font-size: 14px;
    color: #34495e;
}

.stat-item strong {
    color: #2c3e50;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    .header {
        flex-direction: column;
        text-align: center;
        gap: 20px;
    }
    
    .header h1 {
        font-size: 2rem;
    }
    
    .filters {
        grid-template-columns: 1fr;
    }
    
    .posts-container {
        grid-template-columns: 1fr !important;
    }
    
    .post-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .post-metrics {
        justify-content: space-between;
        width: 100%;
    }
}

/* Modal Pop-up */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 30px;
    border-radius: 15px;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.modal-close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    position: absolute;
    right: 20px;
    top: 15px;
    cursor: pointer;
}

.modal-close:hover {
    color: #000;
}

.modal-post-content {
    line-height: 1.6;
    color: #333;
    font-size: 16px;
    font-weight: normal;
    margin-top: 20px;
    text-align: left;
    max-width: 100%;
    padding: 15px;
    background: #fafafa;
    border-radius: 8px;
    border-left: 4px solid #0077b5;
}

.modal-post-info {
    margin: 20px 0;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.modal-metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin: 20px 0;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
}

.modal-metric {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.metric-label {
    font-size: 12px;
    color: #7f8c8d;
    margin-bottom: 5px;
}

.metric-value {
    font-size: 18px;
    font-weight: bold;
    color: #2c3e50;
}

/* Animation d'apparition */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

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