/* ==========================================================================
   Layout — page wrapper, content area, page header
   ========================================================================== */
.wrapper {
    background: var(--t-bg);
}

.content-wrapper {
    background: var(--t-bg);
}

/* Page container & header grid — guarantees pixel-perfect horizontal boundary alignment across title, breadcrumbs, cards, and tables */
.content-header,
.content,
section.content {
    padding-left: 1.25rem !important;
    padding-right: 1.25rem !important;
    width: 100%;
    box-sizing: border-box;
}
.content-header {
    padding-top: 1.25rem !important;
    padding-bottom: 0.75rem !important;
    margin-bottom: 0;
}
.content,
section.content {
    padding-top: 0 !important;
    padding-bottom: 2rem !important;
}
.content-header .container-fluid,
.content .container-fluid,
section.content .container-fluid {
    padding-left: 0 !important;
    padding-right: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
}

/* Header Row & Grid Alignment — guarantees page titles are strictly LEFT-aligned globally */
.content-header .row {
    margin-left: 0 !important;
    margin-right: 0 !important;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}
.content-header .row > [class*="col-"]:first-child,
.e47-page-header .e47-page-title-wrapper {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    justify-content: flex-start !important;
    text-align: left !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
}
.content-header .row > [class*="col-"]:last-child {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-end !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
}

.content-header .list-header-title,
.content-header h1,
.e47-page-title {
    position: relative;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    text-align: left !important;
    gap: 0.65rem;
    color: var(--t-text) !important;
    font-family: var(--t-font-heading);
    font-weight: 800;
    font-size: 1.4rem;
    line-height: 1.25;
    letter-spacing: -0.015em;
    margin: 0 !important;
    margin-left: 0 !important;
    margin-right: auto !important;
    animation: e47-title-slide-up 380ms cubic-bezier(0.16, 1, 0.3, 1) both;
    animation-delay: 80ms;
}

/* E47 Primary Accent Bar (Vertical Line) */
.content-header .list-header-title::before,
.content-header h1::before,
.e47-page-title::before {
    content: "";
    display: inline-block;
    width: 4px;
    height: 1.15em;
    background: var(--e47-primary);
    border-radius: 4px;
    flex-shrink: 0;
    transform-origin: center bottom;
    animation: e47-accent-draw 300ms cubic-bezier(0.16, 1, 0.3, 1) both;
    animation-delay: 40ms;
    box-shadow: 0 0 8px rgba(214, 179, 108, 0.35);
}

.content-header .page-subtitle,
.content-header .fd-subtitle,
.content-header .tpr-subtitle,
.content-header .sa-subtitle,
.content-header .cor-subtitle,
.e47-page-subtitle {
    color: var(--t-muted) !important;
    font-size: 0.82rem;
    margin: 0.25rem 0 0 1.15rem !important;
    text-align: left !important;
    animation: e47-subtitle-fade 350ms cubic-bezier(0.16, 1, 0.3, 1) both;
    animation-delay: 160ms;
}

/* Breadcrumbs */
.breadcrumb {
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    font-size: 0.8rem;
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.25rem;
    list-style: none;
    animation: e47-breadcrumb-fade 350ms cubic-bezier(0.16, 1, 0.3, 1) both;
    animation-delay: 200ms;
}
.breadcrumb-item {
    display: inline-flex;
    align-items: center;
    color: var(--t-muted);
    font-weight: 500;
    font-size: 0.8rem;
    line-height: 1;
}
.breadcrumb-item a {
    color: var(--t-muted);
    text-decoration: none;
    transition: color var(--t-transition-fast);
}
.breadcrumb-item a:hover {
    color: var(--e47-primary);
}
.breadcrumb-item.active {
    color: var(--t-text);
    font-weight: 600;
}
.breadcrumb-item + .breadcrumb-item::before {
    color: var(--t-muted);
    content: "\f105";
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    font-size: 0.75rem;
    opacity: 0.6;
    padding: 0 0.35rem 0 0.15rem;
    float: none;
}

/* Keyframe Micro-Animations */
@keyframes e47-accent-draw {
    from {
        opacity: 0;
        transform: scaleY(0);
    }
    to {
        opacity: 1;
        transform: scaleY(1);
    }
}

@keyframes e47-title-slide-up {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes e47-subtitle-fade {
    from {
        opacity: 0;
        transform: translateY(4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes e47-breadcrumb-fade {
    from {
        opacity: 0;
        transform: translateX(6px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Reduced Motion Accessibility */
@media (prefers-reduced-motion: reduce) {
    .content-header .list-header-title,
    .content-header h1,
    .content-header .list-header-title::before,
    .content-header h1::before,
    .content-header .page-subtitle,
    .e47-page-title,
    .e47-page-title::before,
    .e47-page-subtitle,
    .breadcrumb {
        animation: none !important;
        opacity: 1 !important;
        transform: none !important;
    }
}

/* Content rows and card boundary synchronization */
.content > .row,
section.content > .row,
.content > .container-fluid > .row,
section.content > .container-fluid > .row {
    margin-left: -0.5rem;
    margin-right: -0.5rem;
}
.content > .row > [class*="col-"],
section.content > .row > [class*="col-"],
.content > .container-fluid > .row > [class*="col-"],
section.content > .container-fluid > .row > [class*="col-"] {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}
.content > .card,
section.content > .card,
.content > .container-fluid > .card,
section.content > .container-fluid > .card,
.content > .dashboard-collapsible,
section.content > .dashboard-collapsible,
.content > .container-fluid > .dashboard-collapsible,
section.content > .container-fluid > .dashboard-collapsible {
    margin-left: 0;
    margin-right: 0;
    width: 100%;
}

/* Loading overlay */
#LoadingImage {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99999999;
    background: rgba(15, 23, 42, 0.35) !important;
    backdrop-filter: blur(2px);
}
#LoadingImage img {
    position: absolute;
    left: 50%;
    top: 50%;
    margin-left: -16px;
    margin-top: -16px;
}
:root[data-theme="dark"] #LoadingImage {
    background: rgba(15, 23, 42, 0.6) !important;
}

/* Page fade-in — deliberately NOT applied to section.content: an element
   with animation-name set (even after the animation finishes) establishes a
   new CSS stacking context, and every modal in this app is nested inside
   section.content rather than being a direct child of <body>. Bootstrap
   always appends .modal-backdrop directly to <body>, so once section.content
   has its own stacking context, the modal's z-index:1050 only applies within
   that local context and the backdrop (z-index:1040 at the body level) paints
   over the whole section — modal included — making it invisible/unclickable.
   .content-header never contains a modal, so it keeps the fade-in safely. */
.content-wrapper > .content-header {
    animation: t-fade-in 260ms ease both;
}

@keyframes t-fade-in {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Footer */
.main-footer {
    background: var(--t-navbar-bg);
    border-top: 1px solid var(--t-border);
    color: var(--t-muted);
    font-size: 0.8rem;
    padding: 0.9rem 1.5rem;
}
.main-footer a { color: var(--t-primary); font-weight: 600; }
