/* Modern CSS for AVEC Microcredit System */

:root {
    --primary-color: #007bff;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --light-bg: #f8f9fa;
    --dark-text: #212529;
    --border-color: #dee2e6;
    --shadow: 0 2px 4px rgba(0,0,0,0.1);
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--dark-text);
    background-color: var(--light-bg);
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 30px;
}

.app-header {
    max-width: 1200px;
    margin: 0 auto 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    text-align: left;
}

.header-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

.profile-button {
    border: 0;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    padding: 2px;
}

.profile-button:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 3px;
}

.profile-avatar {
    width: 46px;
    height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    font-weight: 700;
    position: relative;
}

.profile-summary, .collaboration-heading, .attachment-row, .meeting-item, .presence-member {
    display: flex;
    align-items: center;
    gap: 12px;
}

.profile-summary {
    margin: 0 0 18px;
}

.profile-photo-placeholder {
    width: 64px;
    height: 64px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #e7f1ff;
    color: #0056b3;
    font-size: 1.2rem;
    font-weight: 700;
}

.profile-identifier {
    margin: -6px 0 16px;
}

.portal-nav, .wallet-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 18px 0;
}

.action-menu-list {
    display: grid;
    gap: 10px;
    margin: 18px 0;
}

.action-menu {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: #fff;
}

.action-menu summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 48px;
    padding: 12px 16px;
    color: #173f67;
    cursor: pointer;
    font-weight: 700;
}

.action-menu summary::-webkit-details-marker { display: none; }
.action-menu summary::after { content: "+"; color: var(--primary-color); font-size: 1.35rem; line-height: 1; }
.action-menu[open] summary::after { content: "−"; }

.action-menu summary span {
    margin-left: auto;
    color: #495057;
    font-size: 0.9rem;
    font-weight: 400;
}

.action-menu summary:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: -3px;
}

.action-menu > .button-grid {
    margin: 0;
    padding: 0 16px 16px;
}

.portal-screen {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

/* The portal is an application shell: navigation remains available while one screen is active. */
#portalSection {
    display: grid;
    grid-template-columns: minmax(190px, 260px) minmax(0, 1fr);
    gap: 18px 24px;
    align-items: start;
}
#portalSection > .dashboard-heading { grid-column: 1 / -1; margin-bottom: 0; }
#portalSection > .portal-nav {
    grid-column: 1;
    grid-row: 2 / span 20;
    position: sticky;
    top: 12px;
    margin: 0;
    max-height: calc(100vh - 24px);
    overflow: auto;
}
.portal-mobile-nav { display: none; }
#portalSection > #portalNotice,
#portalSection > .portal-screen { grid-column: 2; }
#portalSection > .portal-screen { margin-top: 0; }

@media (max-width: 720px) {
    body:has(#portalSection:not([hidden])) { padding-bottom: 82px; }
    #portalSection { display: block; }
    #portalSection > .portal-nav { display: none; }
    #portalSection > .portal-screen { margin-top: 16px; border-top: 0; padding-top: 0; }
    .portal-mobile-nav {
        position: fixed;
        z-index: 20;
        right: 0;
        bottom: 0;
        left: 0;
        display: grid;
        grid-template-columns: repeat(6, 1fr);
        gap: 2px;
        padding: 7px 4px max(7px, env(safe-area-inset-bottom));
        border-top: 1px solid #c8d9e8;
        background: rgba(255,255,255,.98);
        box-shadow: 0 -5px 18px rgba(23,63,103,.12);
    }
    .portal-mobile-nav button {
        display: grid;
        place-items: center;
        gap: 2px;
        min-width: 0;
        min-height: 48px;
        border: 0;
        border-radius: 8px;
        background: transparent;
        color: #35536f;
        font: inherit;
        font-size: .62rem;
        cursor: pointer;
    }
    .portal-mobile-nav button:hover,
    .portal-mobile-nav button:focus-visible { color: #0056b3; background: #e7f1ff; outline: none; }
    .portal-mobile-nav .action-icon { width: 21px; height: 21px; }
}

.wallet-card {
    flex: 1 1 240px;
    display: grid;
    gap: 4px;
    padding: 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: #f5f9ff;
}

.wallet-card span {
    color: var(--primary-color);
    font-size: 1.5rem;
    font-weight: 700;
}

.wallet-card small { color: #495057; }
.feed-list { display: grid; gap: 16px; margin-top: 20px; }
.feed-post { padding: 16px; border: 1px solid var(--border-color); border-radius: 8px; background: #fff; }
.feed-image { display: block; max-width: 100%; max-height: 420px; margin: 12px 0; border-radius: 6px; object-fit: contain; }
.content-forms { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; margin-top: 16px; }
.content-form, .price-table { padding: 16px; border: 1px solid var(--border-color); border-radius: 8px; background: #fff; }
.content-form h4, .price-table h4 { margin-bottom: 8px; color: #173f67; }
.content-form .btn { margin-top: 10px; }
.product-details { display: grid; gap: 3px; margin-top: 10px; color: #343a40; }
.public-news-item h3 { color: #173f67; margin-bottom: 4px; }
.public-news-item > p:last-child { white-space: pre-wrap; }
.empty-state { padding: 20px 0; color: #495057; }
.news-filter-action { justify-content: end; }
.news-filter-action .btn { margin-top: auto; }
.publish-portal-action { font-weight: 700; box-shadow: 0 5px 14px rgba(0, 86, 179, 0.22); }
.flash-panel { background: #f6faff; }
.flash-filters, .social-links { display: flex; flex-wrap: wrap; gap: 8px; }
.flash-filter.is-active { background: #173f67; }
.flash-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; margin-top: 16px; }
.flash-card { padding: 15px; border: 1px solid #b8d4ed; border-radius: 8px; background: #fff; box-shadow: 0 4px 12px rgba(23, 63, 103, 0.08); }
.flash-card h3 { color: #173f67; font-size: 1.05rem; }
.flash-sport { background: #f3fbf5; border-color: #a9d9b4; }
.flash-international { background: #f7f5ff; border-color: #cdc6f1; }
.flash-local { background: #fff8ee; border-color: #edca96; }
.public-comments { display: grid; gap: 8px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border-color); }
.public-comments h4 { color: #173f67; }
.comment-list { display: grid; gap: 5px; color: #343a40; }
.comment-list p { padding: 7px 10px; background: #f5f9ff; border-radius: 5px; }
.public-comment-form { display: grid; gap: 8px; }
.public-comment-form small { color: #495057; }
.public-comment-link { display: inline-block; margin-top: 12px; color: #0056b3; font-weight: 600; }
.public-footer { max-width: 1200px; display: flex; justify-content: space-between; align-items: start; gap: 20px; margin: 26px auto 0; padding: 20px 4px; color: #244460; }
.public-footer p { max-width: 65ch; font-size: .9rem; }
.social-links a { padding: 5px 9px; border: 1px solid #9ec5fe; border-radius: 999px; color: #0056b3; background: #fff; font-weight: 600; text-decoration: none; }
.social-links a:hover { background: #e7f1ff; }
.member-item { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 0; border-bottom: 1px solid var(--border-color); }
.profile-photo-placeholder img, img.profile-photo-placeholder { object-fit: cover; }
.emoji-picker { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.emoji-picker button { min-width: 38px; min-height: 38px; border: 1px solid var(--border-color); border-radius: 6px; background: #fff; cursor: pointer; font-size: 1.15rem; }
.emoji-picker button:hover, .emoji-picker button:focus-visible { background: #e7f1ff; outline: 2px solid var(--primary-color); }

.dashboard-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

h1 {
    color: var(--primary-color);
    margin-bottom: 10px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    gap: 20px;
}

.landing-hero, .landing-section {
    max-width: 1200px;
    margin: 0 auto;
}

.landing-hero {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(280px, .7fr);
    gap: 2rem;
    align-items: stretch;
    padding: clamp(2rem, 6vw, 5rem);
    border-radius: 18px;
    color: #fff;
    background: #173f67;
    box-shadow: 0 14px 30px rgba(23, 63, 103, .18);
}

.landing-copy { max-width: 650px; }
.landing-kicker { margin-bottom: .8rem; color: #c7e0f7; font-weight: 700; }
.landing-hero h2 { max-width: 9ch; color: #fff; font-size: clamp(2.5rem, 6vw, 4.8rem); line-height: .98; letter-spacing: -.04em; }
.landing-lede { max-width: 56ch; margin: 1.25rem 0 1.75rem; font-size: 1.12rem; color: #e8f3fc; }
.landing-actions { display: flex; flex-wrap: wrap; gap: .75rem; }
.landing-actions .btn-primary, .landing-cta .btn-primary { background: #ffb020; color: #172433; }
.landing-actions .btn-primary:hover, .landing-cta .btn-primary:hover { background: #e79800; }
.landing-note { margin-top: 1.25rem; color: #c7e0f7; font-size: .88rem; }
.journey-panel { padding: 1.5rem; border: 1px solid rgba(255,255,255,.25); border-radius: 12px; background: rgba(255,255,255,.1); }
.journey-panel > p { margin-bottom: 1rem; font-weight: 700; }
.journey-panel ol { display: grid; gap: 1rem; list-style: none; }
.journey-panel li { display: flex; align-items: center; gap: .75rem; }
.journey-panel strong { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 50%; background: #ffb020; color: #172433; }
.landing-section { padding: clamp(2rem, 5vw, 4rem) 0; }
.landing-section > div:first-child { max-width: 620px; }
.landing-section h2 { color: #173f67; font-size: clamp(1.7rem, 3vw, 2.5rem); line-height: 1.1; }
.landing-section h2 + p { margin-top: .8rem; color: #495057; }
.landing-pillars { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; margin-top: 2rem; }
.landing-pillars article { padding: 1.25rem 0; border-top: 2px solid #9ec5fe; }
.landing-icon { width: 28px; height: 28px; color: #0056b3; }
.landing-pillars h3 { margin: .75rem 0 .35rem; color: #173f67; }
.landing-pillars p { color: #495057; }
.landing-steps { display: grid; grid-template-columns: .75fr 1.25fr; gap: 2rem; border-top: 1px solid var(--border-color); }
.steps-list { display: grid; gap: .75rem; }
.steps-list p { display: flex; align-items: center; gap: .8rem; padding: .75rem 0; border-bottom: 1px solid var(--border-color); }
.steps-list strong { color: #0056b3; font-size: 1.1rem; }
.landing-cta { display: flex; align-items: center; justify-content: space-between; gap: 2rem; margin-bottom: 2rem; padding: 2rem; border-radius: 12px; background: #e7f1ff; }
.landing-cta > div { max-width: 620px; }

.card {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

label {
    margin-bottom: 5px;
    font-weight: 500;
}

input, select, textarea {
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 16px;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0,123,255,0.25);
}

.phone-field {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.phone-field span {
    min-width: 3.5rem;
    font-weight: 700;
}

.phone-field input {
    flex: 1;
}

.field-hint {
    margin-top: 0.35rem;
    color: #495057;
    font-size: 0.9rem;
}

fieldset.form-group {
    min-width: 0;
    margin: 0 0 20px;
    padding: 15px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

fieldset.form-group legend {
    padding: 0 0.35rem;
    font-weight: 600;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.2s;
    display: inline-block;
    text-align: center;
    text-decoration: none;
}

.btn:focus-visible {
    outline: 3px solid #003f7d;
    outline-offset: 2px;
}

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

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

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

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

.btn-secondary:hover {
    background-color: #545b62;
}

.btn-warning {
    background-color: var(--warning-color);
    color: #212529;
}

.btn-warning:hover {
    background-color: #e0a800;
}

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

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

.btn-info {
    background-color: #0dcaf0;
    color: #092b33;
}

.button-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}

.button-grid.icon-grid {
    grid-template-columns: repeat(auto-fit, minmax(52px, 1fr));
}

.icon-button {
    width: 100%;
    min-height: 48px;
    padding: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.action-icon {
    width: 22px;
    height: 22px;
    fill: none;
    flex: 0 0 auto;
}

.icon-button:hover .action-icon {
    transform: translateY(-1px);
}

.notifications {
    background-color: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 4px;
    padding: 10px;
    margin-bottom: 15px;
}

.actions {
    margin-top: 15px;
}

.member-list {
    display: grid;
    gap: 15px;
}

.membre {
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.member-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.member-table th, .member-table td {
    border: 1px solid var(--border-color);
    padding: 8px;
    text-align: left;
}

.member-table th {
    background-color: var(--light-bg);
    font-weight: 600;
    cursor: pointer;
}

.member-table th:hover {
    background-color: #e9ecef;
}

.chat-window {
    height: 300px;
    overflow-y: auto;
    background: var(--light-bg);
    padding: 15px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    margin-bottom: 15px;
}

.chat-message {
    display: flex;
    align-items: flex-start;
    margin-bottom: 10px;
}

.chat-avatar {
    width: 35px;
    height: 35px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    margin-right: 10px;
    flex-shrink: 0;
}

.chat-content {
    background: white;
    border-radius: 8px;
    padding: 8px 12px;
    position: relative;
    max-width: 70%;
    box-shadow: var(--shadow);
}

.reaction-row {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 8px;
}

.reaction-button, .attachment-download {
    border: 1px solid var(--border-color);
    background: #fff;
    color: #173f67;
    border-radius: 999px;
    padding: 3px 8px;
    cursor: pointer;
    font: inherit;
    font-size: 0.82rem;
}

.reaction-button.is-active {
    background: #e7f1ff;
    border-color: var(--primary-color);
}

.attachment-download {
    margin-top: 7px;
    border-radius: 4px;
    text-align: left;
}

.attachment-picker {
    margin: 0;
    color: #0056b3;
    cursor: pointer;
    text-decoration: underline;
}

.attachment-row {
    flex-wrap: wrap;
    margin: -4px 0 12px;
}

.attachment-row input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}

.collaboration-heading {
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.media-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.setup-state {
    background: #e7f1ff;
    border: 1px solid #9ec5fe;
    padding: 10px;
    border-radius: 4px;
    margin: 0 0 14px;
    color: #173f67;
}

.presence-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 8px;
    margin: 0 0 24px;
}

.presence-member {
    min-width: 0;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.presence-member .field-hint {
    margin-left: auto;
}

.presence-dot {
    width: 10px;
    height: 10px;
    display: inline-block;
    border-radius: 50%;
    flex: 0 0 auto;
    background: #6c757d;
}

.availability-online { background: #198754; }
.availability-busy { background: #b76e00; }
.availability-offline { background: #6c757d; }
.profile-avatar.availability-online::after, .profile-avatar.availability-busy::after, .profile-avatar.availability-offline::after {
    content: "";
    width: 11px;
    height: 11px;
    border: 2px solid white;
    border-radius: 50%;
    position: absolute;
    right: 0;
    bottom: 0;
}
.profile-avatar.availability-online::after { background: #198754; }
.profile-avatar.availability-busy::after { background: #b76e00; }
.profile-avatar.availability-offline::after { background: #6c757d; }

.deployment-status-list, .deployment-history-list {
    display: grid;
    gap: 8px;
    margin: 12px 0 20px;
    padding-left: 24px;
}

.deployment-status-list li::marker {
    font-size: 0.85rem;
}

.deployment-status-list .is-ready {
    color: #146c43;
    font-weight: 600;
}

.deployment-status-list .is-missing {
    color: #8a3d00;
    font-weight: 600;
}

.deployment-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 20px;
}

.deployment-check {
    display: block;
    margin: 10px 0;
    font-weight: 500;
}

.deployment-check input {
    width: auto;
    margin-right: 5px;
}

.deployment-checklist, .deployment-history {
    margin-top: 28px;
    padding-top: 18px;
    border-top: 1px solid var(--border-color);
}

.deployment-checklist ol {
    display: grid;
    gap: 8px;
    margin: 12px 0 0 24px;
}

.meeting-calendar {
    display: grid;
    gap: 10px;
    margin: 12px 0 24px;
}

.meeting-item {
    justify-content: space-between;
    align-items: flex-start;
    padding: 14px 0;
    border-bottom: 1px solid var(--border-color);
}

.meeting-item h4 {
    margin-bottom: 3px;
}

.meeting-response {
    min-width: 190px;
    display: grid;
    gap: 7px;
    text-align: right;
}

.meeting-response .btn + .btn {
    margin-left: 5px;
}

.meeting-recipients {
    border: 1px solid var(--border-color);
    border-radius: 4px;
    margin: 0 0 16px;
    padding: 10px;
}

.meeting-recipients legend {
    padding: 0 5px;
    font-weight: 600;
}

.recipient-option {
    display: inline-flex;
    align-items: center;
    margin: 4px 12px 4px 0;
    font-weight: 400;
}

.chat-content .timestamp {
    font-size: 0.75em;
    color: var(--secondary-color);
    position: absolute;
    right: 8px;
    bottom: -18px;
}

.warning {
    color: var(--danger-color);
    font-weight: bold;
}

.stats, .history {
    background: var(--light-bg);
    padding: 15px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

.history-item {
    padding: 8px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9em;
}

.group-item, .alert-item, .momo-item {
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin: 10px 0;
    background: var(--light-bg);
}

.momo-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.8em;
}

.button-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    margin: 15px 0;
}

.notifications {
    background: var(--warning-color);
    color: var(--dark-text);
    padding: 10px;
    border-radius: 4px;
    margin: 10px 0;
    display: none;
}

@media (max-width: 768px) {
    body {
        padding: 14px;
    }

    .app-header, .dashboard-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .collaboration-heading, .meeting-item {
        align-items: stretch;
        flex-direction: column;
    }

    .meeting-response {
        min-width: 0;
        text-align: left;
    }

    .profile-button {
        align-self: flex-end;
    }

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

    .landing-hero, .landing-steps { grid-template-columns: 1fr; }
    .landing-pillars { grid-template-columns: 1fr; }
    .landing-cta { align-items: flex-start; flex-direction: column; }
    
    .button-grid {
        grid-template-columns: 1fr;
    }

    .button-grid.icon-grid {
        grid-template-columns: repeat(auto-fit, minmax(48px, 1fr));
    }

    .action-menu summary {
        align-items: flex-start;
        padding: 14px;
    }

    .action-menu summary span {
        max-width: 17ch;
        text-align: right;
    }

    .action-menu > .button-grid {
        padding: 0 14px 14px;
    }
}
