/* =========================================================================
   Seedates – Shared logged-in Header & Footer (matches the dashboard)
   -------------------------------------------------------------------------
   Every frontend page that requires a logged-in user links this stylesheet
   so the top navigation bar (logo, tier badge, avatar menu) and the bottom
   footer (language toggle + copyright) render identically to dashboard.html.

   Rules are scoped to `.header` (and the `footer` element) so they never
   clash with page-specific `.avatar`/`.badge` classes (e.g. the large
   profile-photo avatar shown on profile.html).
   ========================================================================= */

/* ── Page background (identical to dashboard.css `body`) ────────
   Soft mint wash with a green glow radiating from the centre, fixed so it
   does not scroll. Only the background longhands are set here — pages keep
   their own `margin`, `padding`, `min-height`, `display` and text colour. */
body {
    background-color: #f0f8f4;
    background-image: radial-gradient(circle at center, #3EAC77 0%, #f0f8f4 100%);
    background-size: cover;
    background-attachment: fixed;
    background-repeat: no-repeat;
    background-position: center;
}

/* ── Header bar ─────────────────────────────────────────────── */
.header {
    background: #3EAC76;
    color: white;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.header .logo {
    font-size: 2rem;
    font-weight: 600;
    letter-spacing: -0.5px;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header .logo a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: #fff;
}

.header .site-logo {
    height: 45px;
    width: auto;
    display: block;
}

.header .logo-text {
    display: inline-block;
    line-height: 1;
    vertical-align: middle;
    color: #fff;
}

.header .header-right {
    display: flex;
    align-items: center;
    /* 0.1rem matches dashboard.html (dashboard.css) so every header lines up identically. */
    gap: 0.1rem;
}

/* Tier badge (yellow pill) – same as dashboard */
.header .badge {
    background: #FAEB16;
    color: #2f855a;
    padding: 0.3rem 1rem;
    border-radius: 30px;
    font-size: 0.9rem;
    font-weight: 600;
}

/* Points dropdown on the tier badge (same as dashboard) */
.header .credits-badge-wrap {
    position: relative;
}

.header .credits-badge-wrap .badge {
    cursor: pointer;
    user-select: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.header .credits-badge-wrap .badge:hover {
    filter: brightness(0.98);
}

/* The points pill is DB-backed only, so it is empty until /auth/users/me
   answers — hide it instead of flashing an empty bubble. */
.header .credits-badge-wrap .badge:empty {
    display: none;
}

.header .badge-plus-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    color: #fff;
    font-size: 13px;
    font-weight: 800;
    line-height: 1;
}

.header .credits-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.15);
    display: none;
    min-width: 275px;
    z-index: 200;
    padding: 0;
    overflow: hidden;
}

.header .credits-dropdown.show {
    display: block;
}

.header .credits-dropdown a.credits-dd-link {
    display: block;
    padding: 0.57rem 0.9rem;
    text-decoration: none;
    color: #1f6b45;
    background: linear-gradient(135deg, #3EAC77 0%, #ffffff 100%);
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 0;
    white-space: nowrap;
}

.header .credits-dropdown a.credits-dd-link:hover {
    background: linear-gradient(135deg, #3EAC77 0%, #ffffff 100%);
    color: #143d29;
    filter: brightness(0.97);
}

/* Avatar (green circle) + dropdown – same as dashboard */
.header .avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3EAC76 0%, #ffffff 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
    cursor: pointer;
    position: relative;
    transition: background 0.2s;
    /* Reset any page-specific .avatar styling (e.g. the large
       profile-photo avatar) so the header always matches dashboard. */
    font-size: 1rem;
    border: 0;
    box-shadow: none;
    /* WARNING: must stay visible. overflow:hidden here clips
       .avatar-dropdown, which hangs below the 45px circle – that is
       what hid the Settings/Logout menu on every page using this
       stylesheet (the dashboard escaped because it has its own CSS). */
    overflow: visible;
}

.header .avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;              /* hidden by default, shown via JS */
    position: absolute;
    top: 0;
    left: 0;
    border-radius: 50%;
}

.header .avatar span {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    position: absolute;         /* take it out of flow */
}

.header .avatar span[style*="display: none"] {
    visibility: hidden;         /* keep space but hide */
}

.header .avatar:hover {
    background: linear-gradient(135deg, #e8e6c9 0%, #ffffff 100%);
}

.header .avatar:hover .avatar-dropdown {
    display: block;
}

.header .avatar-dropdown {
    position: absolute;
    /* Flush with the bottom of the circle: 100% is the avatar's own height.
       The old fixed 55px left a 10px band below the 45px avatar, and hovering
       that band dropped .avatar:hover, so the menu closed on the way down. */
    top: 100%;
    right: 0;
    background: white;
    border-radius: 10px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.15);
    display: none;
    min-width: 176px;
    z-index: 100;
    overflow: hidden;
}

.header .avatar-dropdown.show {
    display: block;
}

.header .avatar-dropdown a {
    display: block;
    padding: 0.67rem 1.2rem;
    text-decoration: none;
    color: #1f6b45;
    background: linear-gradient(135deg, #3EAC77 0%, #ffffff 100%);
    transition: background 0.2s;
}

.header .avatar-dropdown a:hover {
    background: linear-gradient(135deg, #3EAC77 0%, #ffffff 100%);
    filter: brightness(0.97);
}

/* ── Footer bar ─────────────────────────────────────────────── */
footer {
    background: white;
    border-top: 1px solid #dddfe2;
    padding: 0 1.5rem;
    text-align: center;
    color: #999da3;
    margin-top: 2rem;
}

footer #langToggle {
    color: #3EAC77;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
}

/* NOTE: the footer's `.footer-legal` links row is styled in button-theme.css,
   NOT here — index.html and dashboard.html do not link this sheet, and the row
   is in every page. See the two-section footer block in that file. */

/* ── Responsive tweaks (mirror dashboard/button-theme) ─────── */
@media (max-width: 900px) {
    /* Top/bottom padding is 0 site-wide; only the inline gutters change here. */
    .header { padding: 0 1rem; }
    .header .avatar { width: 40px; height: 40px; }
}
@media (max-width: 480px) {
    .header .avatar { width: 36px; height: 36px; }
    .header .logo-text { font-size: 1rem; }
}

/* ── RTL overrides (Arabic) ────────────────────────────────── */
[dir="rtl"] .header .avatar-dropdown,
html[dir="rtl"] .header .avatar-dropdown,
html[dir="rtl"] .header .avatar-dropdown.show {
    right: auto !important;
    left: 0 !important;
    text-align: right !important;
}

[dir="rtl"] .header .credits-dropdown,
html[dir="rtl"] .header .credits-dropdown,
html[dir="rtl"] .header .credits-dropdown.show {
    right: auto !important;
    left: 0 !important;
    text-align: right !important;
}

[dir="rtl"] footer {
    direction: rtl;
}
