/* Shared Earl header bar. Injected before </body> on every Earl app.
   Light palette, consistent dark-green text (forced with !important so no
   app's own stylesheet can bleed white/other colours into the bar). */
:root { --earl-bar-h: 44px; }

#earl-bar, #earl-bar * { box-sizing: border-box; }

#earl-bar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--earl-bar-h);
    z-index: 2147483647;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 12px;
    background: #FFFFFF;
    border-bottom: 1px solid #E4E9E0;
    box-shadow: 0 1px 3px rgba(21, 46, 18, .06);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 13px;
    line-height: 1;
    color: #1B3D18 !important;
    -webkit-font-smoothing: antialiased;
}

#earl-bar a { text-decoration: none !important; color: #1B3D18 !important; }

#earl-bar .earl-brand {
    display: flex; align-items: center; gap: 8px;
    padding-right: 10px; margin-right: 4px;
    border-right: 1px solid #E4E9E0;
    height: 26px;
}
#earl-bar .earl-brand-word {
    font-weight: 700; letter-spacing: .3px; color: #1B3D18 !important; font-size: 14px;
}

#earl-bar nav { display: flex; align-items: center; gap: 2px; }

#earl-bar .earl-app {
    display: flex; align-items: center; gap: 7px;
    height: 30px; padding: 0 10px; border-radius: 7px;
    color: #3A4A36 !important; transition: background .12s, color .12s;
    white-space: nowrap;
}
#earl-bar .earl-app:hover { background: #F0F4EE; color: #1B3D18 !important; }
#earl-bar .earl-app.active { background: #E7F1E2; color: #152E12 !important; }
#earl-bar .earl-app svg { display: block; width: 20px; height: 20px; border-radius: 5px; flex: 0 0 auto; }
#earl-bar .earl-app-label { font-weight: 500; }

/* Tighten to icons only when space is short so the switcher never wraps. */
@media (max-width: 1000px) { #earl-bar .earl-app-label { display: none; } }

/* Even as bare icons the switcher outgrows a phone, and the bar has no wrap,
   so the right-hand side used to get pushed off screen. Let the icon strip
   scroll sideways instead, and keep the identity block from being squeezed.
   The scroll container holds ONLY the icons: the More dropdown has to stay
   outside it, or overflow-x would clip the open menu (a non-visible overflow
   on one axis forces the other to clip too). */
#earl-bar nav { min-width: 0; }
#earl-bar .earl-apps {
    display: flex; align-items: center; gap: 2px;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
#earl-bar .earl-apps::-webkit-scrollbar { display: none; }
#earl-bar .earl-right { flex: 0 0 auto; }
@media (max-width: 600px) {
    #earl-bar .earl-user { display: none; }   /* the name is the first thing that can go */
    #earl-bar .earl-chat-btn span { display: none; }
    #earl-bar .earl-status { padding-right: 6px; margin-right: 2px; }
}

/* "More" dropdown for second-class tools. */
#earl-bar .earl-more { position: relative; }
#earl-bar .earl-more-btn {
    display: flex; align-items: center; gap: 4px;
    height: 30px; padding: 0 10px; border-radius: 7px;
    border: 0; background: transparent; cursor: pointer;
    font: inherit; font-weight: 500; color: #3A4A36 !important;
}
#earl-bar .earl-more-btn:hover { background: #F0F4EE; color: #1B3D18 !important; }
#earl-bar .earl-caret { font-size: 10px; opacity: .7; }
#earl-bar .earl-menu {
    position: absolute; top: 38px; left: 0;
    display: none; flex-direction: column;
    min-width: 180px; padding: 6px;
    background: #FFFFFF; border: 1px solid #E4E9E0; border-radius: 10px;
    box-shadow: 0 8px 24px rgba(21, 46, 18, .14);
}
#earl-bar .earl-more.open .earl-menu { display: flex; }
#earl-bar .earl-menu a {
    padding: 8px 10px; border-radius: 7px;
    color: #1B3D18 !important; font-weight: 500;
}
#earl-bar .earl-menu a:hover { background: #F0F4EE; }

#earl-bar .earl-spacer { flex: 1 1 auto; }

#earl-bar .earl-right { display: flex; align-items: center; gap: 10px; }
#earl-bar .earl-status {
    display: flex; align-items: center; height: 26px; padding: 0 10px 0 2px; margin-right: 6px;
    border-right: 1px solid #E4E9E0; border-radius: 4px;
}
#earl-bar .earl-status:hover { background: #F0F4EE; }
#earl-bar .earl-status svg { display: block; width: 20px; height: 20px; border-radius: 5px; }
#earl-bar .earl-chat-btn {
    display: flex; align-items: center; gap: 6px;
    height: 30px; padding: 0 10px; border-radius: 7px;
    border: 0; background: transparent; cursor: pointer;
    font: inherit; font-weight: 500; color: #3A4A36 !important;
}
#earl-bar .earl-chat-btn:hover { background: #F0F4EE; color: #1B3D18 !important; }
#earl-bar .earl-chat-btn svg { display: block; width: 18px; height: 18px; }

#earl-bar .earl-user {
    max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    color: #5A6A55 !important;
}

/* The Chat panel is now a native Shadow-DOM overlay drawn by /__earl/chat.js. */

#earl-bar .earl-signout,
#earl-bar .earl-signin {
    display: flex; align-items: center; gap: 6px;
    height: 30px; padding: 0 12px; border-radius: 7px;
    font-weight: 600;
}
/* Sign out: solid dark-green button, white text (the one deliberate white). */
#earl-bar .earl-signout { background: #1B3D18; color: #FFFFFF !important; }
#earl-bar .earl-signout:hover { background: #152E12; color: #FFFFFF !important; }
/* Sign in: lime button, dark text — reads as a front door when logged out. */
#earl-bar .earl-signin { background: #C8FF33; color: #152E12 !important; }
#earl-bar .earl-signin:hover { background: #d6ff5c; color: #152E12 !important; }

/* Empty until the auth probe resolves, so no misleading flash. */
#earl-bar .earl-action:empty { display: none; }

/* ---- Layout: push every app below the fixed bar --------------------------
   padding-top on <html> shifts all normal-flow / min-height / h-screen roots
   down by the bar height, so the bar never overlaps app chrome. */
html.earl-has-bar { padding-top: var(--earl-bar-h) !important; }

/* Full-height SPA roots (e.g. Bulwark mail uses a h-screen container) would
   otherwise extend a bar-height past the viewport and add a scrollbar; cap the
   root so the page still fits exactly under the bar. */
html.earl-app-mail body > div:first-child {
    height: calc(100vh - var(--earl-bar-h)) !important;
}

/* CRM pins its left sidebar and its right record drawer with position:fixed
   top:0, which padding-top on <html> cannot move — without this the bar sits
   on top of them. The settings nav is sticky, so its offset needs the bar
   height adding too. */
html.earl-app-crm .sidebar,
html.earl-app-crm .drawer { top: var(--earl-bar-h) !important; }
html.earl-app-crm .settings-nav { top: calc(24px + var(--earl-bar-h)) !important; }
