:root {
    --primary: #3498db;
    --secondary: #2ecc71;
    --accent: #e74c3c;
    --light: #ecf0f1;
    --dark: #2c3e50;
    --text: #333;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
}

/* Ajustement spécifique pour l'élément "Ressources" */

body {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--text);
    background-color: #f9f9f1;
}

/* Pour empêcher le header de se superposer */
header {
    position: relative;
    top: 0;
    display: flex;
    flex-direction: row;
    justify-content: center;
        width: 100%;
    max-width: 100%;
    height: 150px;
    background: transparent;
    z-index: 30;
    color: white;
    padding: 2vw;
    text-align: center;
}

/* Header et connexion */
.header-top {
    display: flex;
    position: relative;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1vw;
        width: 100%;
    max-width: 100%;
    flex-wrap: wrap;
    gap: 3vw;
}



/* Adaptation mobile */

@media (max-width: 768px) {

        .welcome-msg {
        font-size: 0.8rem;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .welcome-msg button {
        margin-left: 0;
    }
    
    .header-top {
        flex-direction: column;
        gap: 1rem;
          max-width: 100%;
          font-size: 3vw
    }
           .header-h1 {
        flex-direction: column;
            display: flex;
        
          max-width: 50%;
          font-size: 3vw;
    }

    .header-h1 a {
    display: flex;

          max-width: 50%;
          font-size: 3vw;
    }
    header h1 {
        font-size: 4vw;
    }
}
@media (max-width: 600px) {
    header h1 {
        font-size: 3vw;
    }
   .header-top {
        flex-direction: column;
        gap: 1rem;
          max-width: 100%;
          font-size: 3vw
    }
           .header-h1 {
        flex-direction: column;
            display: flex;
    gap: 10px; /* Réduit l’espace entre les éléments */
    margin: 0;
    padding: 0;
        
          max-width: 50%;
          font-size: 3vw;
    }
    .header-h1 a {
    display: flex;
    margin: 0;
    padding: 0;
          max-width: 50%;
          font-size: 3vw;
    }
}
@media (max-width: 480px) {

    nav a {
        margin: 0 0.5rem;
        padding: 0.5rem 0.8rem;
        font-size: 0.9rem;
        width: 90%; /* Réduit davantage pour s'adapter */
        flex-shrink: 1; /* Permet aux éléments de rapetisser */
    }
       .header-top {
        flex-direction: column;
        gap: 1rem;
          max-width: 100%;
          font-size: 3vw
    }
}

/* ===== Profil Page Overrides ===== */
body {
    background: linear-gradient(135deg, #a9c7ef 0%, #bfd5f3 52%, #d7e5f8 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header.header {
    height: 220px;
    display: block;
    padding: 2rem;
    box-sizing: border-box;
    position: relative;
    border-radius: 0 0 24px 24px;
    background: linear-gradient(180deg, #1f5ea8, #4d97e2);
    color: #fff;
    box-shadow: 0 10px 24px rgba(31, 94, 168, 0.18);
}

.header-nav {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 1rem;
    max-width: 1100px;
    margin: 0 auto;
}

.header-left-links {
    display: inline-flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.55rem;
    width: max-content;
    margin-left: calc(150px - (50vw - 50%));
}

.header-left-top,
.header-left-bottom {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.header-left-bottom {
    width: 100%;
}

.header-left-bottom .home-btn {
    flex: 1 1 0;
}

.nav-links {
    display: flex;
    gap: 0.8rem;
}

.header-main {
    max-width: 1100px;
    margin: 0 auto;
}

.header-title-stack {
    position: absolute;
    top: 50%;
    right: 200px;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    text-align: center;
}

.header-title-stack .nav-links {
    justify-content: center;
    margin-bottom: 0.35rem;
}

.home-btn,
.nav-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    text-decoration: none;
    height: 38px;
    min-height: 38px;
    padding: 0 1.2rem;
    font-size: 1rem;
    line-height: 1.1;
    font-weight: 500;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.14);
    box-sizing: border-box;
    transition: 0.2s ease;
}

.home-btn:hover,
.nav-link:hover {
    transform: translateY(-1px);
    background: rgba(255, 255, 255, 0.24);
}

.header-title-stack .nav-link {
    font-weight: 600;
}

.header-left-links .home-btn {
    font-weight: 500;
}

.header-nav .header-left-links > .a11y-toggle-btn {
    width: 100%;
    box-sizing: border-box;
    margin: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 999px;
    height: 38px;
    min-height: 38px;
    padding: 0 1.2rem;
    font-size: 1rem;
    line-height: 1.1;
    font-weight: 700;
    transition: 0.2s ease;
}

.header-nav .header-left-links > .a11y-toggle-btn:hover,
.header-nav .header-left-links > .a11y-toggle-btn:focus-visible {
    transform: translateY(-1px);
    background: rgba(255, 255, 255, 0.24);
    outline: none;
}

#profile-name {
    margin: 0 0 0.35rem;
    text-align: center;
    font-size: clamp(1.9rem, 4vw, 2.7rem);
    line-height: 1.15;
}

#profile-name.profile-name-editable {
    cursor: pointer;
    transition: opacity 0.2s ease;
}

#profile-name.profile-name-editable:hover {
    opacity: 0.88;
}

#profile-role {
    text-align: center;
    opacity: 0.95;
    margin: 0;
}

.admin-management-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 0.3rem;
    text-decoration: none;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.45);
    background: rgba(255, 255, 255, 0.16);
    color: #ffffff;
    padding: 0.45rem 1rem;
    font-size: 0.92rem;
    font-weight: 700;
    line-height: 1.1;
    transition: 0.2s ease;
}

.admin-management-btn:hover {
    transform: translateY(-1px);
    background: rgba(255, 255, 255, 0.28);
}

#profile-function-title {
    text-align: center;
    margin: 0.15rem auto 0;
    font-weight: 700;
    font-size: 0.95rem;
    color: #dbeafe;
    max-width: 92%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

main.container {
    max-width: 1100px;
    width: 100%;
    margin: 2rem auto 1.2rem;
    padding: 0 1rem;
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 1.5rem;
    flex: 1 0 auto;
}

.profile-footer {
    margin-top: auto;
    padding: 0.7rem 1rem;
    text-align: center;
    color: #ffffff;
    background: linear-gradient(135deg, #1f5ea8, #2f7ed1);
    border-top: 1px solid rgba(255, 255, 255, 0.3);
}

.profile-footer p {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 600;
}

.profile-details,
.user-posts {
    background: #fff;
    border: 1px solid #d9e7fb;
    border-radius: 16px;
    box-shadow: 0 8px 18px rgba(21, 67, 140, 0.08);
    padding: 1.2rem;
}

.profile-avatar {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

#profile-photo {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid #dbeafe;
}

.edit-btn {
    border: 0;
    border-radius: 10px;
    padding: 0.55rem 0.9rem;
    background: #1f5ea8;
    color: #fff;
    cursor: pointer;
    font-weight: 600;
}

.edit-btn:hover {
    background: #164a84;
}

.profile-info p {
    margin-bottom: 0.6rem;
    color: #1f2d3d;
}

.ime-status-editor {
    margin-top: 0.55rem;
    padding: 0.75rem;
    border: 1px solid #dbe7fb;
    border-radius: 10px;
    background: #f7fbff;
}

.function-editor {
    margin-top: 0.55rem;
    padding: 0.75rem;
    border: 1px solid #dbe7fb;
    border-radius: 10px;
    background: #f7fbff;
}

.function-editor label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.45rem;
    color: #1f5ea8;
}

.function-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

#profileFunctionInput {
    flex: 1;
    border: 1px solid #b7d6f5;
    border-radius: 8px;
    padding: 0.45rem 0.6rem;
    background: #fff;
}

#profileFunctionSaveBtn {
    border: 0;
    border-radius: 8px;
    padding: 0.48rem 0.75rem;
    background: #1f5ea8;
    color: #fff;
    font-weight: 600;
    cursor: pointer;
}

#profileFunctionSaveBtn:hover {
    background: #164a84;
}

.ime-status-editor label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.45rem;
    color: #1f5ea8;
}

.ime-status-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

#imeStatusSelect {
    flex: 1;
    border: 1px solid #b7d6f5;
    border-radius: 8px;
    padding: 0.45rem 0.6rem;
    background: #fff;
}

#imeStatusSaveBtn {
    border: 0;
    border-radius: 8px;
    padding: 0.48rem 0.75rem;
    background: #1f5ea8;
    color: #fff;
    font-weight: 600;
    cursor: pointer;
}

#imeStatusSaveBtn:hover {
    background: #164a84;
}

.profile-actions {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-top: 0.85rem;
}

.admin-help-section {
    margin-top: 0.95rem;
    padding-top: 0.8rem;
    border-top: 1px dashed #bcd8fb;
}

.admin-help-section h3 {
    margin: 0 0 0.3rem;
    color: #1f5ea8;
    font-size: 1rem;
}

.admin-help-section p {
    margin: 0 0 0.6rem;
    color: #4b5d73;
    font-size: 0.9rem;
}

.profile-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    text-decoration: none;
    padding: 0.55rem 0.85rem;
    border-radius: 10px;
    border: 1px solid #1f5ea8;
    background: #1f5ea8;
    color: #fff;
    font-weight: 600;
    transition: 0.2s ease;
    cursor: pointer;
}

.profile-action-btn[hidden] {
    display: none !important;
}

.profile-action-btn:hover {
    background: #164a84;
    border-color: #164a84;
}

.user-posts h2 {
    margin-bottom: 0.8rem;
}

#userFavoritesSection {
    margin-top: 0.95rem;
    padding-top: 0.8rem;
    border-top: 1px dashed #bcd8fb;
}

#userFavoritesSection h3 {
    margin: 0 0 0.55rem;
    color: #1f5ea8;
    font-size: 1rem;
}

#user-posts-container {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

#user-posts-container .post {
    border: 1px solid #e5edfb;
    border-radius: 12px;
    padding: 0.9rem;
    background: #dbeafe;
}

#user-posts-container .post-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.45rem;
}

#user-posts-container .post-time {
    color: #dbeafe;
    font-size: 0.9rem;
}

#user-posts-container .nav-link {
    background: #1f5ea8;
    color: #fff;
    border: 1px solid #1f5ea8;
    border-radius: 8px;
    padding: 0.45rem 0.75rem;
    text-decoration: none;
    display: inline-block;
}

#user-posts-container .nav-link:hover {
    background: #164a84;
    border-color: #164a84;
}

#user-favorites-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

#user-favorites-container .favorite-item {
    background: #eef6ff;
    border: 1px solid #d8e8fb;
}

#user-favorites-container .favorite-source {
    background: #dbeafe;
    border: 1px solid #bfd8f7;
    border-radius: 999px;
    padding: 0.2rem 0.55rem;
    font-size: 0.72rem;
    font-weight: 700;
    color: #184f8e;
}

#user-favorites-container .favorite-actions {
    margin-top: 0.6rem;
    display: flex;
    gap: 0.45rem;
    align-items: center;
}

#user-favorites-container .nav-link {
    background: #1f5ea8;
    color: #fff;
    border: 1px solid #1f5ea8;
    border-radius: 8px;
    padding: 0.45rem 0.75rem;
    text-decoration: none;
    display: inline-block;
}

#user-favorites-container .nav-link:hover {
    background: #164a84;
    border-color: #164a84;
}

.favorite-remove-btn {
    border: 1px solid #d7b3b3;
    border-radius: 8px;
    padding: 0.45rem 0.7rem;
    background: #fff1f1;
    color: #8e2d2d;
    font-weight: 700;
    cursor: pointer;
}

.favorite-remove-btn:hover {
    background: #ffe3e3;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 1100;
    background: rgba(10, 22, 40, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal[hidden] {
    display: none;
}

.modal-content {
    width: min(420px, 100%);
    background: #ffffff;
    border: 1px solid #d6e6fb;
    border-radius: 14px;
    box-shadow: 0 12px 24px rgba(19, 61, 116, 0.16);
    padding: 1rem 1rem 1.1rem;
    position: relative;
}

.modal-content h3 {
    margin: 0 0 0.75rem;
    color: #1f5ea8;
}

.modal-content form {
    display: grid;
    gap: 0.55rem;
}

.modal-content input {
    border: 1px solid #bfd8f7;
    border-radius: 10px;
    padding: 0.6rem 0.75rem;
    font: inherit;
}

.modal-content button[type="submit"] {
    border: 0;
    border-radius: 10px;
    padding: 0.62rem 0.8rem;
    background: #1f5ea8;
    color: #fff;
    font-weight: 700;
    cursor: pointer;
}

.modal-content button[type="submit"]:hover {
    background: #164a84;
}

.modal-close-btn {
    border: 0;
    background: transparent;
    color: #5c6d84;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.55rem;
}

@media (max-width: 840px) {
    header.header {
        height: auto;
        min-height: 220px;
    }

    .header-nav {
        flex-direction: column;
        gap: 0.6rem;
    }

    .header-left-links {
        margin-left: 0;
        width: 100%;
        align-items: center;
        justify-content: center;
    }

    .header-left-top,
    .header-left-bottom {
        justify-content: center;
        flex-wrap: wrap;
    }

    .header-nav .header-left-links > .a11y-toggle-btn {
        width: auto;
    }

    .header-title-stack {
        position: static;
        transform: none;
        gap: 0.3rem;
    }

    .header-title-stack .nav-links {
        flex-wrap: wrap;
        justify-content: center;
        margin-bottom: 0.15rem;
    }

    main.container {
        grid-template-columns: 1fr;
    }

    .ime-status-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .function-controls {
        flex-direction: column;
        align-items: stretch;
    }
}
