/* Self-hosted Open Sans (no external CDN dependency) */
@font-face {
    font-family: 'Open Sans';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('fonts/OpenSans-400.woff2') format('woff2');
}
@font-face {
    font-family: 'Open Sans';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('fonts/OpenSans-600.woff2') format('woff2');
}
@font-face {
    font-family: 'Open Sans';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('fonts/OpenSans-700.woff2') format('woff2');
}

:root {
    --primary-color: #e30613; /* Boncourt Red */
    --secondary-color: #000000;
    --bg-color: #ffffff;
    --card-bg: #f9f9f9;
    --text-color: #333333;
    --white: #ffffff;
}

html, body {
    width: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

body {
    font-family: 'Open Sans', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

.container {
    width: 95%;
    max-width: 1200px; /* Widened for better admin experience */
    margin: 0 auto;
    padding: 0 15px;
}

header {
    background-color: var(--white);
    color: var(--secondary-color);
    text-align: center;
    padding: 1.5rem 0;
    border-bottom: 3px solid var(--primary-color);
}

header img.logo {
    max-width: 120px;
    height: auto;
    margin-bottom: 10px;
}

header h1 {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 700;
    text-transform: uppercase;
    flex: 1;
}

/* Navigation Menu */
.menu-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 10px;
    color: var(--secondary-color);
}

.side-drawer {
    position: fixed;
    top: 0;
    left: -281px;
    width: 280px;
    height: 100%;
    background: var(--white);
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    z-index: 1000;
    transition: left 0.3s ease, visibility 0.3s;
    padding: 20px 20px 40px 20px; /* More bottom padding for settings visibility */
    display: flex;
    flex-direction: column;
    visibility: hidden;
    overflow-y: auto;
    box-sizing: border-box;
}

.side-drawer.open {
    left: 0;
    visibility: visible;
}

.drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    display: none;
}

.drawer-overlay.active {
    display: block;
}

.drawer-header {
    border-bottom: 1px solid #eee;
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.drawer-menu-item {
    padding: 12px 15px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
    font-weight: 600;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.drawer-menu-item:hover, .drawer-menu-item.active {
    background: #f0f0f0;
    color: var(--primary-color);
}

.card {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    margin: 20px 0;
}

.btn {
    display: inline-block;
    padding: 12px 24px;
    border-radius: 4px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    font-family: 'Open Sans', sans-serif;
}

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

.btn-primary:hover {
    background-color: #c40510;
}

.btn:active {
    transform: scale(0.98);
}

h2, h3 {
    color: var(--secondary-color);
    font-weight: 700;
}

/* =====================================================
   Rubrique Selector (Segmented Buttons)
   ===================================================== */
.rubrique-selector {
    margin-top: 15px;
    margin-bottom: 20px;
}

.rubrique-buttons {
    display: flex;
    background: #f0f0f0;
    padding: 4px;
    border-radius: 10px;
    gap: 4px;
}

.rub_btn {
    flex: 1;
    border: none;
    background: none;
    padding: 10px 5px;
    font-size: 0.85rem;
    font-family: 'Open Sans', sans-serif;
    font-weight: 700;
    color: #666;
    cursor: pointer;
    border-radius: 7px;
    transition: all 0.2s ease;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rub_btn:hover {
    background: rgba(255, 255, 255, 0.5);
}

.rub_btn.active {
    background: var(--primary-color);
    color: #fff;
    box-shadow: 0 2px 4px rgba(227, 6, 19, 0.2);
}

@media (max-width: 360px) {
    .rub_btn {
        font-size: 0.75rem;
        padding: 10px 2px;
    }
}

/* =====================================================
   Accordion (Communications Communales)
   ===================================================== */
.accordion-item {
    background: var(--card-bg);
    border-radius: 8px;
    margin-bottom: 10px;
    border-left: 4px solid var(--primary-color);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    overflow: hidden;
}

.accordion-header {
    padding: 15px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s;
    user-select: none;
}

.accordion-header:hover {
    background: #f0f0f0;
}

.accordion-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.accordion-icon {
    font-size: 0.7rem;
    color: var(--primary-color);
    transition: transform 0.3s ease;
    display: inline-block;
}

.accordion-item.open .accordion-icon {
    transform: rotate(90deg);
}

.accordion-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease;
    padding: 0 15px;
}

.accordion-item.open .accordion-body {
    max-height: 2000px;
    padding: 0 15px 15px;
}

.accordion-content {
    padding-top: 10px;
    border-top: 1px solid #eee;
    font-size: 0.95rem;
    line-height: 1.7;
    color: #333;
}

/* =====================================================
   Agenda
   ===================================================== */
.agenda-month {
    margin-bottom: 30px;
}

.agenda-month-title {
    font-size: 1.3rem;
    font-weight: 900;
    text-transform: uppercase;
    color: var(--secondary-color);
    margin: 0 0 15px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid #eee;
}

.agenda-event {
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f0;
    line-height: 1.6;
}

.agenda-event:last-child {
    border-bottom: none;
}

.agenda-date {
    color: var(--primary-color);
    font-weight: 700;
    font-size: 0.95rem;
}

.agenda-separator {
    color: #666;
}

.agenda-event-title {
    font-weight: 600;
    color: var(--text-color);
}

.agenda-emojis {
    font-size: 1.1rem;
}

.agenda-description {
    color: #666;
    font-size: 0.9rem;
    margin-top: 2px;
    padding-left: 0;
}

.agenda-link {
    display: inline-block;
    margin-top: 4px;
    color: var(--secondary-color);
    text-decoration: underline;
    font-size: 0.9rem;
}

.agenda-link:hover {
    color: var(--primary-color);
}

/* =====================================================
   PWA Installation Overlays
   ===================================================== */

/* Android Banner */
.pwa-install-banner {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 400px;
    background: #fff;
    border: 2px solid var(--primary-color);
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    z-index: 2000;
    padding: 15px;
}

.pwa-install-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.pwa-install-text {
    flex: 1;
}

/* iOS Overlays */
.pwa-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pwa-overlay.ios-bottom-overlay {
    align-items: flex-end;
    padding-bottom: 30px;
}

.pwa-overlay-content {
    background: #fff;
    width: 90%;
    max-width: 400px;
    padding: 25px;
    border-radius: 16px;
    text-align: center;
    box-shadow: 0 5px 20px rgba(0,0,0,0.3);
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(15px); }
    60% { transform: translateY(7px); }
}

/* =====================================================
   Header Layout (replaces inline styles)
   ===================================================== */
.header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.header-center {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    justify-content: center;
}
.header-logo {
    height: 35px;
    margin: 0;
}
.header-title {
    font-size: 1.2rem;
}
.header-spacer {
    width: 44px;
}

/* =====================================================
   Drawer Layout (replaces inline styles)
   ===================================================== */
.drawer-section-label {
    margin: 0 0 10px 15px;
    font-size: 0.8rem;
    color: #999;
    text-transform: uppercase;
}
.drawer-settings {
    margin-top: 40px;
    border-top: 1px solid #eee;
    padding-top: 20px;
    padding-bottom: 20px;
}
.drawer-notif-section {
    padding: 0 15px;
}
.drawer-notif-label {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 10px;
}
.drawer-notif-btn {
    width: 100%;
    padding: 8px;
    font-size: 0.8rem;
}
.drawer-install-wrapper {
    padding: 15px 15px 5px;
}
.drawer-install-btn {
    width: 100%;
    padding: 12px;
    font-weight: bold;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(227, 6, 19, 0.2);
}
.drawer-guide-link-wrapper {
    padding: 15px;
    margin-top: 0;
}
.drawer-guide-link {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--primary-color);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 5px;
}
.drawer-footer {
    margin-top: auto;
    border-top: 1px solid #eee;
    padding-top: 10px;
}
.drawer-legal-link {
    font-size: 0.8rem;
    opacity: 0.7;
}

/* =====================================================
   Section Titles & Hidden Sections (replaces inline)
   ===================================================== */
.section-title {
    margin-top: 20px;
}
.hidden-section {
    display: none !important;
}

/* =====================================================
   PWA Guide (replaces inline styles)
   ===================================================== */
.pwa-guide-hidden {
    display: none;
    padding-top: 20px;
}
.pwa-guide-intro {
    text-align: center;
}
.pwa-guide-back {
    text-align: center;
}
.pwa-guide-back .back-link {
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px;
}
.icon-large {
    font-size: 1.2rem;
}

/* =====================================================
   Mentions Légales (moved from inline <style>)
   ===================================================== */
.legal-content {
    margin-top: 30px;
    padding-bottom: 50px;
}
.legal-section {
    margin-bottom: 30px;
}
.legal-section h2 {
    font-size: 1.2rem;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 5px;
    margin-bottom: 15px;
}
.legal-section p, .legal-section li {
    font-size: 0.95rem;
    color: #444;
}
.legal-header-center {
    display: flex;
    align-items: center;
    justify-content: center;
}
.legal-header-inner {
    display: flex;
    align-items: center;
    gap: 10px;
}
.legal-header-logo {
    height: 35px;
    margin: 0;
}
.legal-header-title {
    font-size: 1.2rem;
}

/* =====================================================
   Utility Classes (replaces inline styles in JS)
   ===================================================== */
.text-center {
    text-align: center;
}
.empty-msg {
    margin-top: 40px;
}
.error-msg {
    color: red;
}
.no-content {
    color: #999;
}
.group-logo-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    object-fit: cover;
}

/* =====================================================
   News Cards (replaces inline styles in template)
   ===================================================== */
.news-card {
    text-align: left;
    padding: 0;
    overflow: hidden;
    margin-bottom: 25px;
    width: 100%;
}
.news-card-header {
    padding: 15px 15px 8px;
    display: flex;
    align-items: center;
}
.news-card-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid #eee;
    margin-right: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #fff;
}
.news-card-avatar-img {
    width: 80%;
    height: 80%;
    object-fit: contain;
}
.news-card-group {
    color: #444;
    font-weight: 700;
    font-size: 0.95rem;
}
.news-card-image {
    max-width: 100%;
    width: 100%;
    height: auto;
    display: block;
    border-top: 1px solid #f0f0f0;
    border-bottom: 1px solid #eee;
}
.news-card-body {
    padding: 15px;
}
.news-card-title {
    margin: 0 0 10px 0;
    font-size: 1.2rem;
    color: var(--secondary-color);
    line-height: 1.3;
}
.news-content {
    font-size: 1rem;
    color: #333;
}
/* Quill editor text sizes (rendered as .ql-size-* on <span>) */
.news-content .ql-size-small,
.accordion-content .ql-size-small { font-size: 0.75em; }
.news-content .ql-size-large,
.accordion-content .ql-size-large { font-size: 1.5em; }
.news-content .ql-size-huge,
.accordion-content .ql-size-huge { font-size: 2.5em; }
.news-card-pdfs {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.news-card-pdf-btn {
    background: #f8f8f8;
    border: 1px solid #ddd;
    color: #333;
    font-size: 0.85rem;
    padding: 10px 15px;
    display: inline-flex;
    align-items: center;
    border-radius: 6px;
    text-decoration: none;
    width: 100%;
    justify-content: center;
}
.news-card-footer {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.news-card-date {
    color: #999;
    font-size: 0.75rem;
}
.news-card-share {
    background: none;
    color: var(--primary-color);
    padding: 0;
    font-size: 0.8rem;
}

/* =====================================================
   Communication Dates (replaces inline styles)
   ===================================================== */
.comm-date {
    display: block;
    color: #999;
    font-size: 0.75rem;
    margin-top: 2px;
}

/* =====================================================
   PDF Viewer Modal
   ===================================================== */
.pdf-viewer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #fff;
    z-index: 3000;
    display: flex;
    flex-direction: column;
}

.pdf-viewer-header {
    height: 60px;
    background: var(--white);
    border-bottom: 2px solid var(--primary-color);
    display: flex;
    align-items: center;
    padding: 0 15px;
    justify-content: space-between;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.btn-close-viewer {
    background: var(--primary-color);
    color: #fff;
    border: none;
    padding: 8px 15px;
    border-radius: 6px;
    font-weight: 700;
    cursor: pointer;
    font-size: 0.9rem;
}

.pdf-viewer-title {
    font-weight: 700;
    font-size: 1rem;
    color: var(--secondary-color);
    flex: 1;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0 10px;
}

.pdf-viewer-container {
    flex: 1;
    width: 100%;
    overflow: hidden;
    background: #525659;
}

.pdf-viewer-container iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Fix pour le défilement iOS dans les iframes */
@supports (-webkit-overflow-scrolling: touch) {
    .pdf-viewer-container {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}
