/*
 * P4Books Header/Toolbar Styles
 * Aligned with DesignSystemLayout.razor sandbox (source of truth)
 * Pure HTML appbar — no Radzen components
 * Updated: 2026-01-28
 */

/* ============================================
   TOP UTILITY BAR (above the appbar)
   ============================================ */

.p4-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 30px;
    padding: 0 16px;
    background: linear-gradient(90deg, #0a1f44 0%, #16356b 100%);
    color: #cdd8ec;
    font-size: 12px;
    line-height: 1;
}

.p4-topbar-contact {
    display: flex;
    align-items: center;
    gap: 6px;
}

.p4-topbar-contact .p4-icon {
    font-size: 15px;
    opacity: 0.85;
}

.p4-topbar-contact a {
    color: #cdd8ec;
    text-decoration: none;
}

.p4-topbar-contact a:hover {
    color: #ffffff;
}

.p4-topbar-sep {
    opacity: 0.4;
    margin: 0 4px;
}

.p4-topbar-lang {
    display: flex;
    align-items: center;
    gap: 2px;
}

.p4-topbar-lang a {
    color: #9fb0cc;
    cursor: pointer;
    text-decoration: none;
    font-weight: 600;
    padding: 2px 5px;
    border-radius: 3px;
}

.p4-topbar-lang a:hover {
    color: #ffffff;
}

.p4-topbar-lang a.active {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.12);
}

@media (max-width: 640px) {
    .p4-topbar-contact {
        font-size: 11px;
        gap: 4px;
    }
    .p4-topbar-contact span:not(.p4-icon):not(.p4-topbar-sep) {
        display: none;
    }
    .p4-topbar-contact a {
        display: inline;
    }
}

/* ============================================
   APPBAR CONTAINER
   ============================================ */

.p4-appbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height, 56px);
    padding: 0 12px;
    background: var(--p4-surface, #FFFFFF);
    color: var(--p4-on-surface, #1E293B);
    border-bottom: 1px solid var(--p4-outline-variant, #E2E8F0);
    flex-shrink: 0;
    z-index: 1001;
    font-family: var(--font-primary);
}

/* ============================================
   LEFT / RIGHT SECTIONS
   ============================================ */

.p4-appbar-left,
.p4-appbar-right {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ============================================
   ICON BUTTONS (hamburger, notifications, help, theme)
   ============================================ */

.p4-appbar-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: inherit;
    border-radius: var(--p4-shape-full, 9999px);
    cursor: pointer;
    transition: background 0.15s;
    padding: 0;
    font-family: inherit;
}

.p4-appbar-icon-btn:hover {
    background: var(--p4-primary-8, rgba(25, 118, 210, 0.08));
}

.p4-appbar-icon-btn:active {
    background: var(--p4-primary-12, rgba(25, 118, 210, 0.12));
}

.p4-appbar-icon-btn .e-icons {
    font-size: 22px;
}

/* ============================================
   LOGO
   ============================================ */

.p4-appbar-logo {
    display: flex;
    align-items: center;
    margin-left: 4px;
    cursor: pointer;
}

.p4-logo-img {
    height: 46px;
    cursor: pointer;
    transition: opacity 0.15s;
}

.p4-logo-img:hover {
    opacity: 0.8;
}

/* ============================================
   ENVIRONMENT BADGE (ADMIN, Sandbox, etc.)
   ============================================ */

.p4-env-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    margin-left: 12px;
    background: var(--p4-orange, #F97316);
    color: #FFFFFF;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
    border-radius: var(--p4-shape-full, 9999px);
    text-transform: uppercase;
}

/* ============================================
   DIVIDER
   ============================================ */

.p4-appbar-divider {
    width: 1px;
    height: 28px;
    background: var(--p4-outline-variant, #E2E8F0);
    margin: 0 4px;
}

/* ============================================
   PROFILE BUTTON
   ============================================ */

.p4-appbar-profile {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px 4px 4px;
    border: none;
    background: transparent;
    color: inherit;
    border-radius: var(--p4-shape-full, 9999px);
    cursor: pointer;
    transition: background 0.15s;
    font-family: inherit;
    position: relative;
}

.p4-appbar-profile:hover {
    background: var(--p4-primary-8, rgba(25, 118, 210, 0.08));
}

/* ============================================
   AVATAR CIRCLE
   ============================================ */

.p4-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--p4-shape-full, 9999px);
    background: var(--p4-primary-container, #DBEAFE);
    color: var(--p4-on-primary-container, #1E3A5F);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.p4-profile-name {
    font-size: 13px;
    font-weight: 500;
}

/* ============================================
   PROFILE DROPDOWN MENU
   ============================================ */

.p4-profile-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    min-width: 200px;
    background: var(--p4-surface, #FFFFFF);
    border: 1px solid var(--p4-outline-variant, #E2E8F0);
    border-radius: var(--p4-shape-lg, 8px);
    box-shadow: var(--p4-elevation-3, 0 2px 8px rgba(0,0,0,0.14));
    padding: 4px;
    z-index: 1100;
    font-family: var(--font-primary);
}

.p4-profile-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: none;
    background: transparent;
    color: var(--p4-on-surface, #1E293B);
    font-size: 13.5px;
    font-weight: 450;
    border-radius: var(--p4-shape-sm, 4px);
    cursor: pointer;
    width: 100%;
    text-align: left;
    transition: background 0.15s;
    font-family: inherit;
    text-decoration: none;
}

.p4-profile-dropdown-item:hover {
    background: var(--p4-primary-8, rgba(25, 118, 210, 0.08));
}

.p4-profile-dropdown-item .e-icons {
    font-size: 20px;
    color: var(--p4-on-surface-muted, #64748B);
}

.p4-profile-dropdown-divider {
    height: 1px;
    background: var(--p4-outline-variant, #E2E8F0);
    margin: 4px 0;
}

.p4-profile-dropdown-item.danger {
    color: var(--p4-error, #DC2626);
}

.p4-profile-dropdown-item.danger .e-icons {
    color: var(--p4-error, #DC2626);
}

/* ============================================
   DARK MODE ADJUSTMENTS
   ============================================ */

[data-theme="fluent2-dark"] .p4-appbar,
.theme-dark .p4-appbar,
body.e-dark-mode .p4-appbar {
    background: var(--p4-surface);
    border-bottom-color: var(--p4-outline-variant);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

[data-theme="fluent2-dark"] .p4-profile-dropdown,
.theme-dark .p4-profile-dropdown,
body.e-dark-mode .p4-profile-dropdown {
    background: var(--p4-surface-container, #1E293B);
    border-color: var(--p4-outline-variant);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

/* Profile dropdown backdrop - invisible click catcher to close menu */
.p4-profile-dropdown-backdrop {
    position: fixed;
    inset: 0;
    z-index: 999;
    background: transparent;
}

/* ============================================
   RESPONSIVE - MOBILE
   ============================================ */

@media (max-width: 768px) {
    .p4-appbar {
        padding: 0 8px;
    }

    .p4-profile-name {
        display: none;
    }

    .p4-appbar-profile {
        padding: 4px;
    }

    .p4-logo-img {
        height: 38px;
    }
}

/* ============================================
   ACCESSIBILITY - REDUCED MOTION
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    .p4-appbar-icon-btn,
    .p4-appbar-profile,
    .p4-logo-img {
        transition: none;
    }
}
