/* Header shell components — FarmLivo design system */

.fl-app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--fl-space-4, 1rem);
    min-height: 4rem;
    padding: 0.65rem 1.25rem;
    background: var(--fl-surface, #fff);
    border-bottom: 1px solid var(--fl-border, #e5e7eb);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 1250;
    overflow: visible;
}

.fl-app-header-start,
.fl-app-header-end {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 0;
}

.fl-app-header-end {
    justify-content: flex-end;
    overflow: visible;
}

.fl-app-version {
    display: inline-flex;
    align-items: center;
    padding: 0.28rem 0.55rem;
    border: 1px solid var(--fl-border, #e5e7eb);
    border-radius: var(--fl-radius-md, 10px);
    background: var(--fl-bg, #f8fafc);
    color: var(--fl-muted, #64748b);
    font-size: 0.72rem;
    font-weight: 600;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    letter-spacing: 0.02em;
    line-height: 1;
    white-space: nowrap;
    user-select: all;
}

.fl-header-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border: 1px solid var(--fl-border, #e5e7eb);
    border-radius: var(--fl-radius-md, 10px);
    background: var(--fl-surface, #fff);
    color: var(--fl-text, #1f2937);
    text-decoration: none;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.fl-header-icon-btn:hover {
    background: var(--fl-bg, #f8fafc);
    border-color: var(--fl-primary, #2563eb);
    text-decoration: none;
}

.fl-header-notif-btn {
    position: relative;
    overflow: visible;
}

.fl-header-notif-badge {
    position: absolute;
    top: -0.35rem;
    right: -0.35rem;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.2rem;
    height: 1.2rem;
    padding: 0 0.32rem;
    border: 2px solid var(--fl-surface, #fff);
    border-radius: 999px;
    background: #dc2626;
    color: #fff;
    font-size: 0.68rem;
    font-weight: 800;
    line-height: 1;
    text-align: center;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.25);
    pointer-events: none;
}

/* Farm selector */
.fl-farm-selector {
    position: relative;
    z-index: 1;
}

.fl-farm-selector.is-open {
    z-index: 1260;
}

.fl-farm-selector-trigger {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 0;
    max-width: 18rem;
    padding: 0.45rem 0.75rem;
    border: 1px solid var(--fl-border, #e5e7eb);
    border-radius: var(--fl-radius-md, 10px);
    background: var(--fl-surface, #fff);
    color: var(--fl-text, #1f2937);
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.fl-farm-selector-trigger:hover,
.fl-farm-selector.is-open .fl-farm-selector-trigger {
    border-color: var(--fl-primary, #2563eb);
    box-shadow: var(--fl-shadow-sm, 0 1px 2px rgba(0,0,0,.06));
}

.fl-farm-selector-copy {
    display: grid;
    min-width: 0;
    text-align: start;
    line-height: 1.15;
}

.fl-farm-selector-label {
    color: var(--fl-muted, #6b7280);
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.fl-farm-selector-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.92rem;
}

.fl-farm-selector-chevron {
    color: var(--fl-muted, #6b7280);
    font-size: 0.75rem;
}

.fl-farm-selector-backdrop,
.fl-user-menu-backdrop,
.fl-lang-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1255;
}

.fl-farm-selector-menu,
.fl-user-menu-panel,
.fl-lang-menu-panel {
    position: absolute;
    top: calc(100% + 0.35rem);
    z-index: 1260;
    min-width: 16rem;
    border: 1px solid var(--fl-border, #e5e7eb);
    border-radius: var(--fl-radius-lg, 14px);
    background: var(--fl-surface, #fff);
    box-shadow: var(--fl-shadow-lg, 0 12px 32px rgba(15,23,42,.12));
    overflow: hidden;
}

.fl-farm-selector-menu {
    left: 0;
}

.fl-farm-selector-menu-head {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--fl-border, #e5e7eb);
    color: var(--fl-muted, #6b7280);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.fl-farm-selector-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    width: 100%;
    padding: 0.7rem 1rem;
    border: 0;
    background: transparent;
    color: var(--fl-text, #1f2937);
    text-align: start;
    cursor: pointer;
}

.fl-farm-selector-item:hover:not(:disabled) {
    background: var(--fl-bg, #f8fafc);
}

.fl-farm-selector-item.is-active {
    background: color-mix(in srgb, var(--fl-primary, #2563eb) 8%, white);
}

.fl-farm-selector-active-badge {
    padding: 0.15rem 0.45rem;
    border-radius: 999px;
    background: var(--fl-primary, #2563eb);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
}

.fl-farm-selector-actions {
    display: grid;
    gap: 0.25rem;
    padding: 0.5rem;
    border-top: 1px solid var(--fl-border, #e5e7eb);
}

.fl-farm-selector-action {
    display: block;
    padding: 0.55rem 0.75rem;
    border-radius: var(--fl-radius-md, 10px);
    color: var(--fl-primary, #2563eb);
    font-size: 0.88rem;
    font-weight: 650;
    text-decoration: none;
}

.fl-farm-selector-action.subtle {
    color: var(--fl-muted, #6b7280);
    font-weight: 600;
}

.fl-farm-selector-action:hover {
    background: var(--fl-bg, #f8fafc);
    text-decoration: none;
}

/* User menu */
.fl-user-menu {
    position: relative;
}

.fl-user-menu-trigger {
    display: inline-flex;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
}

.fl-user-avatar {
    display: grid;
    place-items: center;
    width: 2.35rem;
    height: 2.35rem;
    border-radius: 50%;
    color: #fff;
    background: linear-gradient(135deg, var(--fl-primary, #2563eb), var(--fl-olive, #65a30d));
    font-size: 0.9rem;
    font-weight: 800;
}

.fl-user-avatar.lg {
    width: 2.75rem;
    height: 2.75rem;
}

.fl-user-menu-panel {
    right: 0;
    min-width: 15rem;
}

.fl-user-menu-head {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    border-bottom: 1px solid var(--fl-border, #e5e7eb);
}

.fl-user-menu-head strong {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 11rem;
    font-size: 0.9rem;
}

.fl-user-menu-head small {
    color: var(--fl-muted, #6b7280);
    font-size: 0.78rem;
}

.fl-user-menu-links {
    display: grid;
    padding: 0.35rem;
}

.fl-user-menu-links a {
    padding: 0.55rem 0.75rem;
    border-radius: var(--fl-radius-md, 10px);
    color: var(--fl-text, #1f2937);
    font-size: 0.88rem;
    text-decoration: none;
}

.fl-user-menu-links a:hover {
    background: var(--fl-bg, #f8fafc);
}

.fl-user-menu-logout {
    width: calc(100% - 1rem);
    margin: 0.35rem 0.5rem 0.65rem;
    padding: 0.6rem 0.75rem;
    border: 1px solid color-mix(in srgb, var(--fl-danger, #dc2626) 25%, white);
    border-radius: var(--fl-radius-md, 10px);
    background: color-mix(in srgb, var(--fl-danger, #dc2626) 6%, white);
    color: var(--fl-danger, #dc2626);
    font-weight: 650;
    cursor: pointer;
}

/* Language menu */
.fl-lang-menu {
    position: relative;
}

.fl-lang-menu-trigger {
    min-width: 2.75rem;
    height: 2.5rem;
    padding: 0 0.65rem;
    border: 1px solid var(--fl-border, #e5e7eb);
    border-radius: var(--fl-radius-md, 10px);
    background: var(--fl-surface, #fff);
    color: var(--fl-text, #1f2937);
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
}

.fl-lang-menu-panel {
    right: 0;
    min-width: 9rem;
    padding: 0.35rem;
}

.fl-lang-menu-item {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 0;
    border-radius: var(--fl-radius-md, 10px);
    background: transparent;
    color: var(--fl-text, #1f2937);
    font-size: 0.88rem;
    text-align: start;
    cursor: pointer;
}

.fl-lang-menu-item.is-active {
    background: color-mix(in srgb, var(--fl-primary, #2563eb) 10%, white);
    color: var(--fl-primary, #2563eb);
    font-weight: 700;
}

.fl-lang-menu-item:hover:not(:disabled) {
    background: var(--fl-bg, #f8fafc);
}

@media (max-width: 640px) {
    .fl-app-header {
        flex-wrap: wrap;
        padding-inline: 1rem;
    }

    .fl-farm-selector-trigger {
        max-width: 100%;
    }

    .fl-app-version {
        display: none;
    }
}
