/* ==========================================================================
   DAPEN PPIP-PUSRI UNIFIED PORTAL COMMON STYLES (Header, Footer, Tokens)
   ========================================================================== */

:root {
    /* Brand Palette derived from DAPEN PPIP Logo */
    --brand-navy-dark: #07223D;
    --brand-navy: #0B3558;
    --brand-navy-light: #134B7C;
    --brand-blue: #0284C7;
    --brand-blue-light: #E0F2FE;
    --brand-gold: #F59E0B;
    --brand-gold-light: #FEF3C7;
    --brand-gold-hover: #D97706;
    --brand-crimson: #DC2626;
    --brand-crimson-light: #FEE2E2;
    
    /* Neutral Palette */
    --bg-page: #F8FAFC;
    --bg-surface: #FFFFFF;
    --bg-surface-elevated: #FFFFFF;
    --text-main: #0F172A;
    --text-secondary: #475569;
    --text-muted: #64748B;
    --border-subtle: #E2E8F0;
    --border-strong: #CBD5E1;
    
    /* Shadows & Transitions */
    --shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.03);
    --shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, 0.1), 0 8px 10px -6px rgba(15, 23, 42, 0.04);
    --shadow-glow-blue: 0 0 25px rgba(2, 132, 199, 0.2);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
}

/* Top Brand Color Spectrum Bar */
.brand-top-bar {
    height: 4px;
    width: 100%;
    background: linear-gradient(90deg, 
        var(--brand-navy-dark) 0%, 
        var(--brand-navy) 25%, 
        var(--brand-blue) 55%, 
        var(--brand-gold) 80%, 
        var(--brand-crimson) 100%
    );
}

/* Header Navigation */
.portal-header {
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    padding: 0 28px 0 20px;
    height: 74px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
    width: 100%;
    box-sizing: border-box;
}

.portal-header-inner {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.portal-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Sidebar Hamburger Toggle — ghost style, blends with the nav bar */
.btn-sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--brand-navy);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    flex-shrink: 0;
    padding: 0;
    margin-right: 4px;
}

.btn-sidebar-toggle:hover {
    background: rgba(11, 53, 88, 0.07);
    color: var(--brand-blue);
}

.btn-sidebar-toggle:active {
    background: rgba(2, 132, 199, 0.12);
    color: var(--brand-blue);
}

/* Thin vertical divider between toggle and brand logo */
.portal-header-left .toggle-divider {
    width: 1px;
    height: 28px;
    background: var(--border-subtle);
    flex-shrink: 0;
}

.portal-logo-container {
    display: flex;
    align-items: center;
    gap: 14px;
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.portal-logo-container:hover {
    opacity: 0.92;
}

.portal-logo-img {
    height: 44px;
    width: auto;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(11, 53, 88, 0.12));
}

.portal-brand-text {
    display: flex;
    flex-direction: column;
}

.portal-brand-title {
    font-size: 17px;
    font-weight: 800;
    color: var(--brand-navy);
    letter-spacing: -0.02em;
    line-height: 1.15;
    display: flex;
    align-items: center;
    gap: 6px;
}

.portal-brand-title span.badge-tag {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--brand-gold-light);
    color: #92400E;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.portal-brand-subtitle {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: 0.01em;
}

/* User & Header Action Area */
.portal-header-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}

/* Status Indicator */
.system-status-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 12px;
    font-weight: 600;
    color: #065F46;
    background: #ECFDF5;
    padding: 5px 12px;
    border-radius: 20px;
    border: 1px solid #A7F3D0;
}

.status-dot {
    width: 7px;
    height: 7px;
    background-color: #10B981;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
    animation: pulse-green 2s infinite ease-in-out;
}

@keyframes pulse-green {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.7; }
}

/* Button to Home / Main Portal */
.btn-header-home {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    background: #F1F5F9;
    color: var(--brand-navy);
    font-size: 12.5px;
    font-weight: 600;
    text-decoration: none;
    border: 1px solid var(--border-subtle);
    transition: all 0.2s ease;
}

.btn-header-home:hover {
    background: #E2E8F0;
    color: var(--brand-navy-dark);
}

/* User Profile Pill */
.user-profile-pill {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 12px 4px 5px;
    background: #F1F5F9;
    border-radius: 24px;
    border: 1px solid var(--border-subtle);
}

.user-avatar-circle {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-navy) 0%, var(--brand-blue) 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
    box-shadow: var(--shadow-sm);
}

.user-meta-info {
    display: flex;
    flex-direction: column;
    text-align: left;
}

.user-name-label {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.2;
    max-width: 140px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-status-role {
    font-size: 10.5px;
    font-weight: 500;
    color: var(--text-muted);
    line-height: 1;
}

/* Buttons */
.btn-header-logout {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--brand-crimson);
    font-size: 12.5px;
    font-weight: 600;
    text-decoration: none;
    border: 1px solid rgba(220, 38, 38, 0.25);
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s ease;
}

.btn-header-logout:hover {
    background: var(--brand-crimson-light);
    border-color: var(--brand-crimson);
    color: #B91C1C;
}

.btn-header-login {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--brand-navy) 0%, var(--brand-navy-light) 100%);
    color: white;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    box-shadow: 0 2px 4px rgba(11, 53, 88, 0.2);
    transition: all 0.2s ease;
}

.btn-header-login:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(11, 53, 88, 0.3);
    background: linear-gradient(135deg, var(--brand-navy-light) 0%, var(--brand-blue) 100%);
}

/* Footer */
.portal-footer {
    background-color: var(--bg-surface);
    border-top: 1px solid var(--border-subtle);
    padding: 22px 32px;
    margin-top: auto;
    width: 100%;
    box-sizing: border-box;
}

.portal-footer-inner {
    max-width: 1360px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.footer-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

.footer-brand-highlight {
    font-weight: 700;
    color: var(--brand-navy);
}

.footer-links {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: var(--text-muted);
}

.footer-links a {
    color: var(--brand-navy);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.footer-links a:hover {
    color: var(--brand-blue);
    text-decoration: underline;
}

/* Global Sidebar Transitions & Collapsible Mechanics */
.sidebar, .catalog-sidebar {
    width: 250px !important;
    min-width: 250px !important;
    max-width: 250px !important;
    margin-left: 0 !important;
    opacity: 1 !important;
    transition: margin-left 0.32s cubic-bezier(0.2, 0, 0, 1),
                opacity 0.25s cubic-bezier(0.2, 0, 0, 1) !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
}

/* Prevent text wrapping/shifting */
.sidebar *, .catalog-sidebar * {
    white-space: nowrap;
}

.sidebar .sidebar-nav, 
.catalog-sidebar .sidebar-nav {
    min-width: 250px;
    width: 250px;
    box-sizing: border-box;
}

/* Collapsed Desktop State */
@media (min-width: 769px) {
    body.sidebar-collapsed .sidebar,
    body.sidebar-collapsed .catalog-sidebar {
        margin-left: -250px !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }
}

/* App Layout Container & Fluid Main Content Centering across all modules */
.app-layout-body,
.catalog-app-body,
.layout {
    display: flex !important;
    flex: 1 1 auto !important;
    width: 100% !important;
    min-height: calc(100vh - 74px) !important;
    position: relative !important;
    box-sizing: border-box !important;
}

.main-content,
.catalog-main {
    flex: 1 1 0% !important;
    width: 100% !important;
    max-width: 1400px !important;
    margin: 0 auto !important;
    box-sizing: border-box !important;
    transition: max-width 0.3s cubic-bezier(0.16, 1, 0.3, 1),
                padding 0.3s cubic-bezier(0.16, 1, 0.3, 1),
                margin 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

/* Mobile Sidebar Drawer & Backdrop */
.sidebar-mobile-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background-color: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 998;
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
}

@media (max-width: 768px) {
    .portal-header {
        padding: 0 14px;
        height: 64px;
    }
    .portal-brand-subtitle, .system-status-chip {
        display: none;
    }
    .user-meta-info {
        display: none;
    }
    .portal-footer {
        padding: 20px 16px;
    }
    .portal-footer-inner {
        flex-direction: column;
        text-align: center;
    }

    /* Mobile off-canvas drawer */
    .sidebar, .catalog-sidebar {
        position: fixed !important;
        top: 68px !important;
        left: 0 !important;
        bottom: 0 !important;
        height: calc(100vh - 68px) !important;
        z-index: 999 !important;
        transform: translateX(-100%) !important;
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
    }

    body.sidebar-mobile-open .sidebar,
    body.sidebar-mobile-open .catalog-sidebar {
        transform: translateX(0) !important;
    }

    body.sidebar-mobile-open .sidebar-mobile-backdrop {
        display: block;
        opacity: 1;
        pointer-events: auto;
    }
}
