/* ============================================================
   Portail Seniors Golf Club de Lavaux – Feuille de style
   ============================================================ */

:root {
    --golf-indigo:   #4f46e5;
    --golf-blue:     #3b82f6;
    --golf-light:    #eff6ff;
    --golf-gold:     #f59e0b;
    --topbar-h:      58px;
    --sidebar-w:     268px;
    --sidebar-bg:    #1e1b4b; /* indigo-950 */
}

/* ============================================================
   RESET & BODY
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    background: linear-gradient(135deg, var(--golf-light) 0%, #e0e7ff 100%);
    min-height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    display: flex;
    flex-direction: column;
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    height: var(--topbar-h);
    background: linear-gradient(90deg, var(--golf-indigo) 0%, var(--golf-blue) 100%);
    display: flex;
    align-items: center;
    padding: 0 1rem;
    gap: .75rem;
    box-shadow: 0 2px 10px rgba(0,0,0,.18);
    flex-shrink: 0;
}

/* Hamburger */
.hamburger-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: .45rem .5rem;
    border-radius: .375rem;
    display: flex;
    flex-direction: column;
    gap: 5px;
    transition: background .2s;
    flex-shrink: 0;
}
.hamburger-btn:hover,
.hamburger-btn:focus-visible { background: rgba(255,255,255,.18); outline: none; }
.hamburger-btn span {
    display: block;
    width: 22px;
    height: 2px;
    background: #fff;
    border-radius: 2px;
    transition: transform .28s ease, opacity .2s ease;
}
body.sidebar-open .hamburger-btn span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
body.sidebar-open .hamburger-btn span:nth-child(2) { opacity: 0; transform: scaleX(0); }
body.sidebar-open .hamburger-btn span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Brand */
.topbar-brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    font-size: .95rem;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}
.topbar-brand:hover { color: #e0e7ff; }
.topbar-brand span { overflow: hidden; text-overflow: ellipsis; }

/* Right side */
.topbar-right {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-left: auto;
    flex-shrink: 0;
}
.topbar-user {
    display: flex;
    align-items: center;
    gap: .45rem;
    color: rgba(255,255,255,.9);
    text-decoration: none;
    font-size: .875rem;
    padding: .3rem .6rem;
    border-radius: .375rem;
    transition: background .2s;
}
.topbar-user:hover { background: rgba(255,255,255,.15); color: #fff; }
.topbar-logout {
    color: rgba(255,255,255,.75);
    text-decoration: none;
    padding: .35rem .55rem;
    border-radius: .375rem;
    border: 1px solid rgba(255,255,255,.3);
    font-size: .9rem;
    transition: background .2s, color .2s;
}
.topbar-logout:hover { background: rgba(255,255,255,.15); color: #fff; }

/* ============================================================
   SIDEBAR OVERLAY
   ============================================================ */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 1040;
}
.sidebar-overlay.open { display: block; animation: fadeOverlay .2s ease; }
@keyframes fadeOverlay { from { opacity: 0; } to { opacity: 1; } }

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    position: fixed;
    top: 0;
    left: calc(-1 * var(--sidebar-w) - 10px);
    width: var(--sidebar-w);
    height: 100dvh;
    background: var(--sidebar-bg);
    z-index: 1050;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: left .3s cubic-bezier(.4,0,.2,1);
    box-shadow: 6px 0 28px rgba(0,0,0,.3);
}
.sidebar.open { left: 0; }

/* Sidebar brand */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 1.1rem 1.1rem .9rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
    flex-shrink: 0;
}
.sidebar-brand-text { line-height: 1.25; }
.sidebar-brand-name { color: #fff; font-weight: 700; font-size: .9rem; }
.sidebar-brand-sub  { color: rgba(255,255,255,.5); font-size: .75rem; }

/* Scrollable body */
.sidebar-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: .5rem 0 .75rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.1) transparent;
}
.sidebar-body::-webkit-scrollbar { width: 4px; }
.sidebar-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 2px; }

/* Section titles */
.sidebar-section-title {
    font-size: .6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: rgba(255,255,255,.35);
    padding: .85rem 1.1rem .2rem;
}

/* Links & buttons */
.sidebar-link,
button.sidebar-toggle-sub {
    display: flex;
    align-items: center;
    gap: .65rem;
    width: 100%;
    padding: .56rem 1.1rem;
    color: rgba(255,255,255,.78);
    text-decoration: none;
    font-size: .875rem;
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: background .15s, color .15s, border-color .15s;
}
.sidebar-link:hover,
button.sidebar-toggle-sub:hover {
    background: rgba(255,255,255,.08);
    color: #fff;
}
.sidebar-link.active,
button.sidebar-toggle-sub.active {
    background: rgba(255,255,255,.12);
    color: #fff;
    border-left-color: var(--golf-gold);
    font-weight: 600;
}

.sidebar-icon {
    width: 16px;
    text-align: center;
    font-size: .85rem;
    opacity: .8;
    flex-shrink: 0;
}

/* Chevron */
.sidebar-arrow {
    margin-left: auto;
    font-size: .7rem;
    opacity: .5;
    transition: transform .25s;
}
button.sidebar-toggle-sub[aria-expanded="true"] .sidebar-arrow { transform: rotate(180deg); }

/* Sub-menus */
.sidebar-sub {
    overflow: hidden;
    max-height: 0;
    transition: max-height .3s ease;
    background: rgba(0,0,0,.18);
}
.sidebar-sub.open { max-height: 400px; }
.sidebar-sub .sidebar-link { padding-left: 2.5rem; font-size: .84rem; }

/* Sidebar footer (user info) */
.sidebar-footer {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .85rem 1rem;
    border-top: 1px solid rgba(255,255,255,.08);
    flex-shrink: 0;
}
.sidebar-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,.2);
    flex-shrink: 0;
}
.sidebar-footer-info { flex: 1; min-width: 0; }
.sidebar-footer-name { color: #fff; font-size: .82rem; font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-footer-role { color: rgba(255,255,255,.45); font-size: .72rem; }
.sidebar-footer-logout {
    color: rgba(255,255,255,.55);
    text-decoration: none;
    padding: .3rem .45rem;
    border: 1px solid rgba(255,255,255,.2);
    border-radius: .35rem;
    font-size: .85rem;
    transition: all .2s;
    flex-shrink: 0;
}
.sidebar-footer-logout:hover { background: rgba(255,255,255,.12); color: #fff; }

/* ============================================================
   MAIN CONTENT & FOOTER
   ============================================================ */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.content-inner {
    flex: 1;
    padding: 1.25rem 1.5rem;
}
.app-footer {
    background: linear-gradient(90deg, var(--golf-indigo) 0%, var(--golf-blue) 100%);
    color: rgba(255,255,255,.65);
    text-align: center;
    padding: .6rem 1rem;
    font-size: .8rem;
    flex-shrink: 0;
}

/* ============================================================
   CARTES
   ============================================================ */
.card {
    border: none;
    box-shadow: 0 4px 12px rgba(79,70,229,.10);
    border-radius: .75rem;
}
.card-header-golf {
    background: linear-gradient(90deg, var(--golf-indigo) 0%, var(--golf-blue) 100%);
    color: white;
    border-radius: .75rem .75rem 0 0 !important;
}

/* ---- Bouton primaire ---- */
.btn-golf {
    background: linear-gradient(90deg, var(--golf-indigo), var(--golf-blue));
    color: white;
    border: none;
}
.btn-golf:hover { opacity: .9; color: white; }

/* ---- Stats dashboard ---- */
.stat-card-link {
    display: block;
    text-decoration: none;
    color: inherit;
}
.stat-card-link:hover .stat-card {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(79,70,229,.18);
}
.stat-card {
    background: white;
    border-radius: 1rem;
    padding: 1.5rem;
    text-align: center;
    box-shadow: 0 4px 12px rgba(79,70,229,.10);
    transition: transform .2s, box-shadow .2s;
    min-width: 160px;
}
.stat-card .stat-icon {
    font-size: 2rem;
    background: linear-gradient(135deg, var(--golf-indigo), var(--golf-blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.stat-card .stat-number { font-size: 2.5rem; font-weight: 700; color: #1e1b4b; }

/* ============================================================
   TROMBINOSCOPE
   ============================================================ */
.trombi-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.25rem;
}
.member-card-grid {
    background: white;
    border-radius: .75rem;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,.08);
    transition: transform .25s, box-shadow .25s;
    cursor: pointer;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}
.member-card-grid:hover { transform: scale(1.04); box-shadow: 0 12px 24px rgba(0,0,0,.14); }
.member-card-grid .photo-wrap { width: 100%; padding-top: 100%; position: relative; overflow: hidden; }
.member-card-grid .photo-wrap img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.member-card-grid .card-footer-golf {
    padding: .75rem 1rem;
    background: linear-gradient(90deg, var(--golf-indigo), var(--golf-blue));
    color: white;
}
.member-card-grid.milestone .card-footer-golf {
    background: linear-gradient(90deg, var(--golf-gold), #eab308);
    color: #1a1a1a;
}
.member-card-grid .member-name { font-weight: 700; font-size: 1rem; }
.member-card-grid .member-sub  { font-size: .8rem; opacity: .85; }

.milestone-section {
    background: linear-gradient(to right, #fef3c7, #fde68a);
    border-radius: 1rem;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 8px rgba(0,0,0,.06);
}
.milestone-section h5 { color: #92400e; }
.milestone-mini-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: .75rem; }
.milestone-mini-card {
    background: white; border-radius: .5rem; overflow: hidden;
    box-shadow: 0 2px 6px rgba(0,0,0,.1); cursor: pointer; transition: transform .2s;
}
.milestone-mini-card:hover { transform: translateY(-3px); }
.milestone-mini-card .photo-wrap { width: 100%; padding-top: 100%; position: relative; overflow: hidden; }
.milestone-mini-card .photo-wrap img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.milestone-mini-card .mini-info {
    padding: .3rem .4rem;
    background: linear-gradient(90deg, var(--golf-gold), #eab308);
    font-size: .7rem; font-weight: 700; text-align: center;
}

/* ============================================================
   CHAT
   ============================================================ */
.chat-messages {
    height: 450px; overflow-y: auto; display: flex; flex-direction: column;
    gap: .5rem; padding: 1rem; background: #f8fafc;
    border-radius: .5rem; border: 1px solid #e2e8f0;
}
.chat-bubble {
    max-width: 70%; padding: .5rem .9rem;
    border-radius: 1rem; font-size: .9rem; line-height: 1.4;
}
.chat-bubble.mine {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--golf-indigo), var(--golf-blue));
    color: white; border-bottom-right-radius: .2rem;
}
.chat-bubble.theirs {
    align-self: flex-start; background: white;
    border: 1px solid #e2e8f0; border-bottom-left-radius: .2rem;
}
.chat-bubble .bubble-author { font-size: .7rem; opacity: .7; margin-bottom: .15rem; }
.chat-bubble .bubble-time   { font-size: .65rem; opacity: .6; margin-top: .2rem; text-align: right; }

/* ============================================================
   FORMULAIRES
   ============================================================ */
.form-card { max-width: 860px; margin: 0 auto; }
.section-label {
    font-size: .7rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .08em; color: var(--golf-indigo);
    margin-bottom: .5rem; padding-bottom: .25rem; border-bottom: 2px solid #e0e7ff;
}
.photo-preview {
    width: 120px; height: 120px; object-fit: cover;
    border-radius: .5rem; border: 3px solid #e0e7ff;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 576px) {
    .trombi-gallery { grid-template-columns: repeat(2, 1fr); }
    .stat-card .stat-number { font-size: 1.75rem; }
    .content-inner { padding: 1rem .75rem; }
}

/* ---- Loading spinner ---- */
.loading-spinner { display: none; text-align: center; padding: 1.5rem; color: var(--golf-indigo); font-weight: 600; }
.spinner-border-golf { border-color: var(--golf-indigo); border-right-color: transparent; }
