/* ============================================
   HORIZON NATIONAL - Design Épuré Bleu
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Palette de couleurs bleue épurée */
    --blue-50: #eff6ff;
    --blue-100: #dbeafe;
    --blue-200: #bfdbfe;
    --blue-300: #93c5fd;
    --blue-400: #60a5fa;
    --blue-500: #3b82f6;
    --blue-600: #2563eb;
    --blue-700: #1d4ed8;
    --blue-800: #1e40af;
    --blue-900: #1e3a8a;
    
    --primary: #1e40af;
    --primary-dark: #1e3a8a;
    --primary-light: #3b82f6;
    --secondary: #dc2626;
    --accent: #2563eb;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #2563eb;
    
    /* Couleurs de fond épurées */
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-card: #ffffff;
    --bg-card-hover: #f1f5f9;
    
    /* Texte */
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    
    /* Bordures */
    --border-color: #e2e8f0;
    --border-radius: 12px;
    --border-radius-sm: 8px;
    
    /* Ombres douces */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    
    /* Transitions */
    --transition: all 0.2s ease;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-secondary);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* Mobile viewport fix */
@supports (-webkit-touch-callout: none) {
    body {
        min-height: -webkit-fill-available;
    }
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ============================================
   HEADER
   ============================================ */

header {
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 24px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 1rem;
    text-decoration: none;
    color: var(--text-primary);
}

.logo img {
    height: 50px;
    width: auto;
    object-fit: contain;
}

.logo-text {
    display: flex;
    flex-direction: column;
}

.logo-text h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    margin: 0;
    letter-spacing: -0.5px;
}

.tagline {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0;
}

nav {
    display: flex;
    gap: 0.5rem;
}

nav a {
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius-sm);
    transition: var(--transition);
    font-size: 0.9375rem;
}

nav a:hover {
    color: var(--primary);
    background: var(--bg-secondary);
}

nav a.active {
    color: var(--primary);
    background: var(--blue-50);
}

/* ============================================
   MAIN CONTENT
   ============================================ */

main {
    padding: 4rem 0 3rem 0;
    min-height: calc(100vh - 200px);
}

/* ============================================
   ARTICLES GRID
   ============================================ */

.articles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

/* ============================================
   ARTICLE CARD
   ============================================ */

.article-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    overflow: hidden;
    transition: var(--transition);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sm);
}

.article-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--blue-300);
}

.article-card.pinned {
    border: 2px solid var(--primary);
    box-shadow: var(--shadow);
}

.article-cover {
    width: 100%;
    height: 220px;
    object-fit: cover;
    background: linear-gradient(135deg, var(--blue-100), var(--blue-200));
}

.article-content {
    padding: 1.5rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.article-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
    gap: 1rem;
}

.article-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    flex: 1;
    line-height: 1.4;
}

.pinned-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
    color: var(--primary);
}

.article-date {
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 400;
    margin-bottom: 1rem;
}

.article-excerpt {
    color: var(--text-secondary);
    margin-top: auto;
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 0.9375rem;
}

/* ============================================
   EMPTY STATE
   ============================================ */

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.3;
}

.empty-state h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-weight: 600;
}

.empty-state p {
    color: var(--text-muted);
    font-size: 1rem;
}

/* ============================================
   ADMIN SECTION
   ============================================ */

.login-section {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 3rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
}

.login-card h2 {
    margin-bottom: 2rem;
    text-align: center;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary);
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
}

.admin-header h2 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary);
}

.form-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 2rem;
    border-radius: var(--border-radius);
    margin-bottom: 2rem;
    box-shadow: var(--shadow-sm);
}

.form-card h3 {
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.875rem;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 1rem;
    font-family: inherit;
    color: var(--text-primary);
    transition: var(--transition);
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--blue-100);
    background: var(--bg-primary);
}

.form-group textarea {
    resize: vertical;
    min-height: 200px;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

/* ============================================
   BUTTONS
   ============================================ */

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius-sm);
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: var(--blue-300);
}

.btn-danger {
    background: var(--danger);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-danger:hover {
    background: #dc2626;
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}

.btn-info {
    background: var(--info);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-info:hover {
    background: var(--blue-700);
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}

.btn-warning {
    background: var(--warning);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-warning:hover {
    background: #d97706;
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.error-message {
    color: var(--danger);
    margin-top: 1rem;
    text-align: center;
    font-size: 0.875rem;
}

/* ============================================
   ARTICLES MANAGEMENT
   ============================================ */

.articles-management {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
}

.articles-management h3 {
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.articles-list-admin {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.article-item-admin {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    transition: var(--transition);
}

.article-item-admin:hover {
    border-color: var(--blue-300);
    box-shadow: var(--shadow-sm);
}

.article-preview-admin {
    display: flex;
    gap: 1rem;
    flex: 1;
    align-items: center;
}

.article-preview-admin img {
    width: 100px;
    height: 80px;
    object-fit: cover;
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border-color);
}

.article-info-admin h4 {
    margin: 0 0 0.25rem 0;
    color: var(--text-primary);
    font-weight: 600;
}

.article-date-admin {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin: 0.25rem 0;
}

.pinned-badge {
    display: inline-block;
    background: var(--primary);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 0.25rem;
}

.article-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.no-articles {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

/* ============================================
   MODAL
   ============================================ */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--bg-primary);
    margin: 5% auto;
    padding: 2rem;
    border-radius: var(--border-radius);
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    position: relative;
    border: 1px solid var(--border-color);
    animation: slideUp 0.3s ease;
}

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

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 2rem;
    cursor: pointer;
    color: var(--text-muted);
    background: none;
    border: none;
    line-height: 1;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--text-primary);
    background: var(--bg-secondary);
}

/* ============================================
   FOOTER
   ============================================ */

footer {
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    margin-top: 4rem;
    padding: 2rem 0;
    text-align: center;
    color: var(--text-muted);
}

/* ============================================
   RESPONSIVE - MOBILE FIRST
   ============================================ */

/* Mobile Small (jusqu'à 480px) */
@media (max-width: 480px) {
    html {
        font-size: 14px;
    }

    .container {
        padding: 0 16px;
    }

    header .container {
        padding: 0.75rem 16px;
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }

    .logo {
        flex-direction: row;
        justify-content: center;
        gap: 0.75rem;
    }

    .logo img {
        height: 40px;
    }

    .logo-text h1 {
        font-size: 1.25rem;
    }

    .tagline {
        font-size: 0.625rem;
    }

    nav {
        width: 100%;
        justify-content: space-around;
        gap: 0.25rem;
    }

    nav a {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
        flex: 1;
        text-align: center;
    }

    main {
        padding: 2rem 0 1.5rem 0;
    }

    .articles-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .article-card {
        border-radius: 8px;
    }

    .article-cover {
        height: 180px;
    }

    .article-content {
        padding: 1.25rem;
    }

    .article-title {
        font-size: 1.125rem;
    }

    .article-excerpt {
        font-size: 0.875rem;
    }

    .empty-state {
        padding: 3rem 1.5rem;
    }

    .empty-icon {
        font-size: 2.5rem;
    }

    .empty-state h2 {
        font-size: 1.25rem;
    }

    .empty-state p {
        font-size: 0.875rem;
    }

    /* Admin Mobile */
    .login-card {
        padding: 2rem 1.25rem;
        margin: 1rem;
    }

    .login-card h2 {
        font-size: 1.5rem;
    }

    .admin-header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
        padding: 1.25rem;
    }

    .admin-header h2 {
        font-size: 1.5rem;
    }

    .form-card {
        padding: 1.5rem;
    }

    .form-card h3 {
        font-size: 1.25rem;
    }

    .form-actions {
        flex-direction: column;
        gap: 0.75rem;
    }

    .form-actions .btn {
        width: 100%;
    }

    .articles-management {
        padding: 1.5rem;
    }

    .articles-management h3 {
        font-size: 1.25rem;
    }

    .article-item-admin {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
        padding: 1rem;
    }

    .article-preview-admin {
        flex-direction: column;
        align-items: flex-start;
    }

    .article-preview-admin img {
        width: 100%;
        height: 150px;
    }

    .article-actions {
        width: 100%;
        flex-direction: column;
        gap: 0.5rem;
    }

    .article-actions .btn {
        width: 100%;
    }

    .modal-content {
        margin: 10% auto;
        padding: 1.5rem;
        max-width: calc(100% - 2rem);
    }

    footer {
        padding: 1.5rem 0;
        font-size: 0.875rem;
    }
}

/* Mobile Medium (481px - 768px) */
@media (min-width: 481px) and (max-width: 768px) {
    .container {
        padding: 0 20px;
    }

    header .container {
        padding: 1rem 20px;
        flex-wrap: wrap;
    }

    .logo {
        gap: 1rem;
    }

    .logo img {
        height: 45px;
    }

    nav {
        width: 100%;
        justify-content: center;
        gap: 0.5rem;
    }

    nav a {
        padding: 0.5rem 1rem;
    }

    .articles-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 1.5rem;
    }

    .article-cover {
        height: 200px;
    }

    .admin-header {
        flex-wrap: wrap;
    }

    .article-item-admin {
        flex-wrap: wrap;
    }

    .article-actions {
        flex-wrap: wrap;
    }

    .form-actions {
        flex-wrap: wrap;
    }

    .modal-content {
        max-width: 90%;
        padding: 2rem;
    }
}

/* Tablet (769px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    .container {
        padding: 0 24px;
    }

    .articles-grid {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
        gap: 1.75rem;
    }

    .article-cover {
        height: 220px;
    }

    .modal-content {
        max-width: 85%;
    }
}

/* Desktop Large (1025px+) */
@media (min-width: 1025px) {
    .container {
        max-width: 1200px;
    }

    .articles-grid {
        grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    }
}

/* Améliorations générales pour tous les écrans mobiles */
@media (max-width: 768px) {
    /* Header mobile */
    header {
        box-shadow: var(--shadow);
    }

    /* Amélioration de la lisibilité */
    body {
        font-size: 15px;
    }

    /* Boutons plus grands sur mobile pour faciliter le tap */
    .btn {
        min-height: 44px;
        padding: 0.75rem 1.25rem;
    }

    .btn-small {
        min-height: 40px;
        padding: 0.625rem 1rem;
    }

    /* Formulaires plus espacés */
    .form-group {
        margin-bottom: 1.25rem;
    }

    .form-group input,
    .form-group textarea {
        padding: 0.875rem;
        font-size: 16px; /* Évite le zoom automatique sur iOS */
    }

    /* Cards plus espacées */
    .article-card {
        margin-bottom: 0.5rem;
    }

    /* Navigation améliorée */
    nav a {
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Logo responsive */
    .logo {
        min-height: 44px;
    }

    /* Modal full screen sur très petits écrans */
    @media (max-width: 360px) {
        .modal-content {
            margin: 0;
            border-radius: 0;
            max-width: 100%;
            max-height: 100vh;
            height: 100vh;
        }
    }
}

/* Orientation paysage sur mobile */
@media (max-width: 768px) and (orientation: landscape) {
    header .container {
        flex-direction: row;
        align-items: center;
    }

    .logo img {
        height: 35px;
    }

    nav {
        width: auto;
    }

    main {
        padding: 2rem 0;
    }
}

/* Touch improvements */
@media (hover: none) and (pointer: coarse) {
    /* Amélioration pour les écrans tactiles */
    .article-card:active {
        transform: scale(0.98);
        opacity: 0.9;
    }

    .btn:active {
        transform: scale(0.97);
        opacity: 0.9;
    }

    nav a:active {
        background: var(--blue-100);
        transform: scale(0.95);
    }

    /* Zones de tap plus grandes */
    .btn {
        min-height: 44px;
        min-width: 44px;
    }

    nav a {
        min-height: 44px;
    }

    /* Désactiver les sélections de texte accidentelles */
    .article-card,
    .btn,
    nav a {
        -webkit-tap-highlight-color: rgba(30, 64, 175, 0.1);
        -webkit-touch-callout: none;
        user-select: none;
    }
}

/* Améliorations pour les petits écrans en hauteur */
@media (max-width: 768px) and (max-height: 600px) {
    header .container {
        padding: 0.5rem 16px;
    }

    .logo img {
        height: 35px;
    }

    .logo-text h1 {
        font-size: 1.125rem;
    }

    main {
        padding: 1rem 0;
    }

    .articles-grid {
        gap: 1rem;
    }

    .article-cover {
        height: 150px;
    }

    .article-content {
        padding: 1rem;
    }
}
