/* ==========================================================================
   tpl_agp_cu — Base Template Styles
   v1.0.0

   Dependencies replaced from JoomShaper (per CSS audit):
   - a text-decoration reset
   - img block/max-width reset
   - .container padding
   - .row gutter width
   - label font-weight

   Everything else is self-contained in AGP modules.
   ========================================================================== */

/* ---------- CSS Custom Properties (set by index.php from admin params) --- */
:root {
    --agp-tpl-primary: #2D2A26;
    --agp-tpl-accent: #C45D3E;
    --agp-tpl-accent-hover: #A84D32;
    --agp-tpl-bg: #FAF8F5;
    --agp-tpl-surface: #FFFFFF;
    --agp-tpl-header-bg: #FFFFFF;
    --agp-tpl-footer-bg: #2D2A26;
    --agp-tpl-font-display: 'DM Serif Display', Georgia, serif;
    --agp-tpl-font-body: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}


/* ---------- JoomShaper Parity Resets ------------------------------------ */
a,
a:hover,
a:focus,
a:active {
    text-decoration: none;
}

img {
    display: block;
    max-width: 100%;
    height: auto;
}

.container {
    padding-left: 15px;
    padding-right: 15px;
}

.row {
    --bs-gutter-x: 1.875rem;
}

label {
    font-weight: normal;
}


/* ---------- Base Typography --------------------------------------------- */
body {
    font-family: var(--agp-tpl-font-body);
    color: var(--agp-tpl-primary);
    background-color: var(--agp-tpl-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    margin: 0;
    padding: 0;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--agp-tpl-font-display);
    font-weight: 400;
    color: var(--agp-tpl-primary);
    line-height: 1.3;
}

h1 { font-size: 2.75rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }

p {
    line-height: 1.7;
    margin-bottom: 1rem;
}


/* ---------- Links (article content) ------------------------------------- */
/* :where() gives this rule 0 specificity, so ANY class-based selector
   in AGP modules (.agp-pn__pill, .agp-cr__rate-link, etc.) wins.
   Bare <a> tags in article HTML still get styled because they have
   no competing class selector. */
:where(.agp-article) a {
    color: var(--agp-tpl-accent);
    transition: color 0.2s ease;
}

:where(.agp-article) a:hover,
:where(.agp-article) a:focus {
    color: var(--agp-tpl-accent-hover);
}

/* ---------- Bootstrap table overlay reset (article HTML) ---------------- */
/* BS5 uses --bs-table-* variables + inset box-shadow to control table
   row/cell backgrounds. This covers inline-styled article HTML tables
   that can't use scoped module CSS. Without this, any background-color
   set via inline style="" is hidden behind the box-shadow overlay. */
.agp-article .table {
    --bs-table-bg: transparent;
    --bs-table-color: inherit;
    --bs-table-bg-state: transparent;
    --bs-table-bg-type: transparent;
    --bs-table-accent-bg: transparent;
}

.agp-article .table tbody tr,
.agp-article .table tbody td {
    box-shadow: none;
}


/* ==========================================================================
   TOP BAR
   ========================================================================== */
.agp-topbar {
    background: var(--agp-tpl-topbar-bg);
    color: var(--agp-tpl-topbar-text);
    font-size: 0.8125rem;
    line-height: 1;
}

.agp-topbar__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
}

.agp-topbar__left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.agp-topbar__right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.agp-topbar__item {
    color: var(--agp-tpl-topbar-text);
    opacity: 0.85;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: opacity 0.2s ease;
}

.agp-topbar__item:hover {
    opacity: 1;
    color: var(--agp-tpl-topbar-text);
}

.agp-topbar__item span[class*="fa-"] {
    font-size: 0.6875rem;
}

.agp-topbar__social {
    color: var(--agp-tpl-topbar-text);
    opacity: 0.6;
    font-size: 0.875rem;
    transition: opacity 0.2s ease;
}

.agp-topbar__social:hover {
    opacity: 1;
    color: var(--agp-tpl-topbar-text);
}


/* ==========================================================================
   HEADER
   ========================================================================== */
.agp-header {
    background: var(--agp-tpl-header-bg);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    position: sticky;
    top: 0;
    z-index: 1030;
    transition: box-shadow 0.2s ease;
    overflow: visible;
}

.agp-header--scrolled {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.agp-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--agp-tpl-header-height, 90px);
    overflow: visible;
}

.agp-header__logo {
    flex-shrink: 0;
}

.agp-header__logo img {
    height: auto;
    width: auto;
}

.agp-header__logo a {
    display: inline-flex;
    align-items: center;
}

/* Navigation — Joomla renders the menu module here */
.agp-header__nav {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    flex-shrink: 0;
}

/* Basic styling for Joomla's default menu output */
.agp-header__nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 4px;
}

/* Top-level nav links only — exclude mega panel links */
.agp-header__nav > ul > li > a {
    display: block;
    padding: 10px 16px;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--agp-tpl-primary);
    border-radius: 8px;
    transition: background 0.2s ease, color 0.2s ease;
    white-space: nowrap;
}

.agp-header__nav > ul > li > a:hover,
.agp-header__nav > ul > li > a:focus {
    background: rgba(0, 0, 0, 0.04);
}

.agp-header__nav > ul > li.active > a,
.agp-header__nav > ul > li.current > a {
    color: var(--agp-tpl-accent);
}

/* Dropdown menus (exclude mega menu link lists) */
.agp-header__nav ul li ul:not(.agp-mega__links) {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--agp-tpl-surface);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    padding: 8px 0;
    min-width: 200px;
    flex-direction: column;
    z-index: 1031;
}

.agp-header__nav ul li:hover > ul:not(.agp-mega__links) {
    display: flex;
}

.agp-header__nav ul li ul:not(.agp-mega__links) li a {
    padding: 8px 20px;
    font-size: 0.875rem;
    border-radius: 0;
}

/* Parent item positioning */
.agp-header__nav > ul > li {
    position: relative;
}

/* Dropdown menu styling */
.agp-header__nav .dropdown-menu {
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    padding: 8px 0;
    min-width: 200px;
    margin-top: 0;
}

.agp-header__nav .dropdown-item {
    padding: 8px 20px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--agp-tpl-primary);
}

.agp-header__nav .dropdown-item:hover,
.agp-header__nav .dropdown-item:focus {
    background: rgba(0, 0, 0, 0.04);
    color: var(--agp-tpl-primary);
}

.agp-header__nav .dropdown-item.active {
    background: rgba(0, 0, 0, 0.04);
    color: var(--agp-tpl-accent);
}


/* ==========================================================================
   MEGA MENU
   ========================================================================== */

/* Mega parent — position relative to the header, not the li */
.agp-header__nav > ul > li.agp-mega {
    position: static;
}

/* The mega panel — contained card dropdown */
.agp-mega__panel {
    display: none;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: calc(100% - 4px);
    width: calc(100% - 30px);
    max-width: 1200px;
    background: var(--agp-tpl-surface);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    padding: 40px;
    z-index: 1031;
}

.agp-mega:hover > .agp-mega__panel {
    display: block;
}

/* Invisible bridge above the panel to cover the hover gap */
.agp-mega__panel::before {
    content: '';
    position: absolute;
    top: -20px;
    left: 0;
    right: 0;
    height: 20px;
}

/* Grid layout — auto columns for link groups */
.agp-mega__grid {
    display: flex;
    gap: 0;
}

/* Description column (optional, from heading-type menu item) */
.agp-mega__desc {
    flex: 0 0 260px;
    border-right: 1px solid rgba(0, 0, 0, 0.06);
    margin-right: 40px;
    background: rgba(0, 0, 0, 0.02);
    border-radius: 12px 0 0 12px;
    padding: 40px;
    margin: -40px 40px -40px -40px;
}

.agp-mega__desc-title {
    font-family: var(--agp-tpl-font-display);
    font-size: 1.375rem;
    font-weight: 400;
    color: var(--agp-tpl-primary);
    margin: 0 0 12px;
    line-height: 1.3;
}

.agp-mega__desc-text {
    font-size: 0.9375rem;
    color: rgba(0, 0, 0, 0.5);
    line-height: 1.6;
    margin: 0;
}

/* Link columns */
.agp-mega__col {
    flex: 1;
    min-width: 0;
    padding: 0 20px;
}

.agp-mega__col:first-child:not(.agp-mega__desc + .agp-mega__col) {
    padding-left: 0;
}

.agp-mega__col:last-child {
    padding-right: 0;
}

.agp-mega__col-heading {
    font-family: var(--agp-tpl-font-body);
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(0, 0, 0, 0.4);
    margin: 0 0 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.agp-mega__links {
    list-style: none;
    margin: 0;
    padding: 0;
}

.agp-mega__links li {
    margin-bottom: 0;
}

.agp-mega__link {
    display: block;
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--agp-tpl-primary);
    padding: 8px 0;
    transition: color 0.15s ease;
}

.agp-mega__link:hover {
    color: var(--agp-tpl-accent);
}

.agp-mega__link--active {
    color: var(--agp-tpl-accent);
}

/* --- Background Variants --- */

/* Light: warm tint */
.agp-mega--light > .agp-mega__panel {
    background: var(--agp-tpl-bg);
}

/* Dark: primary color bg */
.agp-mega--dark > .agp-mega__panel {
    background: var(--agp-tpl-primary);
}

.agp-mega--dark .agp-mega__desc {
    background: rgba(255, 255, 255, 0.05);
    border-right-color: rgba(255, 255, 255, 0.1);
}

.agp-mega--dark .agp-mega__desc-title {
    color: #fff;
}

.agp-mega--dark .agp-mega__desc-text {
    color: rgba(255, 255, 255, 0.6);
}

.agp-mega--dark .agp-mega__col-heading {
    color: rgba(255, 255, 255, 0.4);
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

.agp-mega--dark .agp-mega__link {
    color: rgba(255, 255, 255, 0.8);
}

.agp-mega--dark .agp-mega__link:hover {
    color: #fff;
}

/* Accent: accent color bg */
.agp-mega--accent > .agp-mega__panel {
    background: var(--agp-tpl-accent);
}

.agp-mega--accent .agp-mega__desc {
    background: rgba(0, 0, 0, 0.08);
    border-right-color: rgba(255, 255, 255, 0.15);
}

.agp-mega--accent .agp-mega__desc-title {
    color: #fff;
}

.agp-mega--accent .agp-mega__desc-text {
    color: rgba(255, 255, 255, 0.7);
}

.agp-mega--accent .agp-mega__col-heading {
    color: rgba(255, 255, 255, 0.5);
    border-bottom-color: rgba(255, 255, 255, 0.15);
}

.agp-mega--accent .agp-mega__link {
    color: rgba(255, 255, 255, 0.9);
}

.agp-mega--accent .agp-mega__link:hover {
    color: #fff;
}


/* Mobile toggle */
.agp-header__toggle {
    display: none;
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: var(--agp-tpl-primary);
    font-size: 1.5rem;
}

/* Header CTA buttons — positioned after nav */
.agp-header__cta {
    display: flex;
    align-items: center;
    align-self: center;
    gap: 16px;
    margin-left: 12px;
    flex-shrink: 0;
}

/* Kill any wrapper div/p margin/padding from Custom HTML module + TinyMCE */
.agp-header__cta > div,
.agp-header__cta p,
.agp-header__cta > div > div {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 0;
    padding: 0;
}

/* Style links inside header-cta as buttons */
.agp-header__cta a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 600;
    padding: 10px 20px;
    border-radius: 8px;
    white-space: nowrap;
    transition: background 0.2s ease, color 0.2s ease;
    line-height: 1;
    height: 40px;
}

/* First CTA: outline style */
.agp-header__cta a:first-child {
    color: var(--agp-tpl-primary);
    border: 1.5px solid rgba(0, 0, 0, 0.15);
    background: transparent;
}

.agp-header__cta a:first-child:hover {
    background: rgba(0, 0, 0, 0.04);
    border-color: var(--agp-tpl-primary);
}

/* Last CTA: solid accent style */
.agp-header__cta a:last-child {
    color: #fff;
    background: var(--agp-tpl-accent);
    border: 1.5px solid var(--agp-tpl-accent);
}

.agp-header__cta a:last-child:hover {
    background: var(--agp-tpl-accent-hover);
    border-color: var(--agp-tpl-accent-hover);
}

/* Search icon button */
.agp-header__search-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--agp-tpl-primary);
    font-size: 1rem;
    margin-left: 8px;
    flex-shrink: 0;
    transition: background 0.2s ease;
}

.agp-header__search-toggle:hover {
    background: rgba(0, 0, 0, 0.04);
}

/* Search slide-down bar */
.agp-search {
    max-height: 0;
    overflow: hidden;
    background: var(--agp-tpl-surface);
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    transition: max-height 0.3s ease, padding 0.3s ease;
    padding: 0;
}

.agp-search--open {
    max-height: 100px;
    padding: 16px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.agp-search__form {
    display: flex;
    align-items: center;
}

.agp-search__input-wrap {
    display: flex;
    align-items: center;
    width: 100%;
    background: var(--agp-tpl-bg);
    border: 1.5px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    padding: 0 16px;
    gap: 12px;
    transition: border-color 0.2s ease;
}

.agp-search__input-wrap:focus-within {
    border-color: var(--agp-tpl-search-focus);
}

.agp-search__icon {
    color: rgba(0, 0, 0, 0.3);
    font-size: 0.875rem;
    flex-shrink: 0;
}

.agp-search__input {
    flex: 1;
    border: none;
    background: none;
    font-family: var(--agp-tpl-font-body);
    font-size: 1rem;
    color: var(--agp-tpl-primary);
    padding: 12px 0;
    outline: none;
}

.agp-search__input::placeholder {
    color: rgba(0, 0, 0, 0.35);
}

.agp-search__close {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    color: rgba(0, 0, 0, 0.35);
    font-size: 0.875rem;
    padding: 4px;
    flex-shrink: 0;
    transition: color 0.2s ease;
}

.agp-search__close:hover {
    color: var(--agp-tpl-primary);
}


/* ==========================================================================
   MAIN CONTENT AREA
   ========================================================================== */
.agp-main {
    min-height: 60vh;
}

/* Wrapper for article body — provides link styling context */
.agp-article {
    padding: 0;
}


/* ==========================================================================
   HERO POSITION
   ========================================================================== */
.agp-hero {
    /* Empty — modules dropped here provide their own styling */
}


/* ==========================================================================
   CONTENT-TOP / CONTENT-BOTTOM POSITIONS
   ========================================================================== */
.agp-content-top {
    /* Pill nav and other above-content modules */
}

.agp-content-bottom {
    padding-top: 24px;
}


/* ==========================================================================
   FOOTER
   ========================================================================== */
.agp-footer {
    background: var(--agp-tpl-footer-bg);
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.875rem;
    line-height: 1.6;
    padding: 48px 0 24px;
}

.agp-footer a {
    color: rgba(255, 255, 255, 0.7);
    transition: color 0.2s ease;
}

.agp-footer a:hover {
    color: #fff;
}

.agp-footer__main {
    display: flex;
    flex-wrap: wrap;
    gap: 40px;
    padding-bottom: 32px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 24px;
}

.agp-footer__col {
    flex: 1;
    min-width: 200px;
}

.agp-footer__col-heading {
    font-family: var(--agp-tpl-font-body);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(255, 255, 255, 0.4);
    margin-bottom: 12px;
}

.agp-footer__contact-value {
    font-weight: 600;
    color: #fff;
}

/* Compliance badges row */
.agp-footer__badges {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.agp-footer__badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
}

.agp-footer__badge img {
    height: 28px;
    width: auto;
}

/* Bottom bar — copyright */
.agp-footer__bottom {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.35);
}


/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 991.98px) {
    .agp-topbar {
        display: none;
    }

    .agp-header__search-toggle,
    .agp-search {
        display: none;
    }

    .agp-header__inner {
        height: var(--agp-tpl-header-height-mobile, 70px);
    }

    .agp-header__nav {
        display: none;
        position: absolute;
        top: var(--agp-tpl-header-height-mobile, 70px);
        left: 0;
        right: 0;
        background: var(--agp-tpl-header-bg);
        border-top: 1px solid rgba(0, 0, 0, 0.06);
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
        padding: 16px;
        z-index: 1031;
    }

    .agp-header__nav--open {
        display: block;
    }

    .agp-header__nav ul {
        flex-direction: column;
        gap: 0;
    }

    .agp-header__nav > ul > li > a {
        padding: 12px 16px;
    }

    /* Dropdowns stack in mobile */
    .agp-header__nav ul li ul:not(.agp-mega__links) {
        position: static;
        box-shadow: none;
        border: none;
        padding-left: 16px;
    }

    .agp-header__nav ul li:hover > ul:not(.agp-mega__links) {
        display: flex;
    }

    .agp-header__toggle {
        display: block;
    }

    /* Mega menu collapses to stacked layout on mobile */
    .agp-mega__panel {
        position: static;
        box-shadow: none;
        border-top: none;
        padding: 8px 0 16px;
        background: rgba(0, 0, 0, 0.02);
        border-radius: 0;
    }

    .agp-mega:hover > .agp-mega__panel {
        display: block;
    }

    .agp-mega__grid {
        flex-direction: column;
        gap: 16px;
    }

    .agp-mega__desc {
        flex: none;
        border-right: none;
        margin: 0 0 8px;
        padding: 16px;
        border-radius: 8px;
    }

    .agp-mega__col {
        padding: 0 16px;
    }

    .agp-mega__col-heading {
        margin-bottom: 8px;
    }

    /* CTA buttons move into mobile nav dropdown */
    .agp-header__cta {
        display: none;
    }

    .agp-header__nav--open ~ .agp-header__cta {
        display: flex;
        flex-direction: column;
        margin: 0;
        padding: 8px 16px 16px;
    }

    h1 { font-size: 2rem; }
    h2 { font-size: 1.625rem; }
}

@media (max-width: 767.98px) {
    .agp-header__inner {
        height: var(--agp-tpl-header-height-mobile, 70px);
    }

    .agp-header__nav {
        top: var(--agp-tpl-header-height-mobile, 70px);
    }

    .agp-footer__main {
        flex-direction: column;
        gap: 24px;
    }

    h1 { font-size: 1.75rem; }
}
