/* AdMob Banner — dedicated footer space, smooth transition, no overlap */
:root { --ad-banner-height: 0px; }

html:not(.has-banner) #bannerCloseBtn { display: none !important; }

/* Always transition smoothly when banner appears/disappears */
.app-nav {
    transition: bottom 0.3s ease;
}

.ask-ai-trigger {
    transition: bottom 0.3s ease;
}

.ask-ai-modal {
    transition: bottom 0.3s ease;
}

/* Mobile banners occupy the bottom 50dp. The navigation always sits above
   that reserved area and content always clears both surfaces. */
@media (max-width: 768px) {
    .main-content {
        padding-bottom: calc(var(--nav-height-mobile, 50px) + env(safe-area-inset-bottom, 0px) + 8px) !important;
    }

    html.has-banner .app-nav {
        bottom: var(--ad-banner-height, 0px) !important;
        height: var(--nav-height-mobile, 50px) !important;
        min-height: var(--nav-height-mobile, 50px) !important;
        padding-bottom: 0 !important;
    }

    html.has-banner .main-content {
        padding-bottom: calc(var(--nav-height-mobile, 50px) + var(--ad-banner-height, 0px) + 8px) !important;
    }

    html.has-banner .ask-ai-trigger {
        bottom: calc(var(--nav-height-mobile, 50px) + var(--ad-banner-height, 0px) + 12px) !important;
    }

    html.has-banner .ask-ai-modal {
        bottom: calc(var(--nav-height-mobile, 50px) + var(--ad-banner-height, 0px) + 60px) !important;
    }
}

/* Banner close button adjusts position right above the banner */
#bannerCloseBtn,
html.has-banner #bannerCloseBtn {
    bottom: calc(var(--ad-banner-height, 0px) + 2px) !important;
}

/* Inline transaction ads use a real native AdMob banner over this reserved
   slot. The slot remains clearly marked as sponsored and follows the same
   visual rhythm as a transaction without impersonating financial data. */
.transaction-ad-slot {
    position: relative;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    flex-shrink: 0;
    min-height: 78px;
    padding: 7px 10px !important;
    overflow: hidden;
    border: 1px solid rgba(99, 102, 241, 0.22);
    border-left: 4px solid #6366f1 !important;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.06), rgba(255, 255, 255, 0.98));
}

/* A native ad is the only thing that can reveal this row. During loading or
   no-fill the slot consumes no visible space and shows no sponsored label. */
.transaction-ad-slot.is-loading {
    min-height: 0;
    height: 0;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent;
    opacity: 0;
    pointer-events: none;
}

.transaction-ad-slot.is-loading::before,
.transaction-ad-slot.is-loading .transaction-ad-space {
    display: none;
}

.transaction-ad-slot.is-loaded {
    opacity: 1;
}

.transaction-ad-slot::before {
    content: "Sponsored";
    position: absolute;
    top: 4px;
    left: 8px;
    z-index: 1;
    padding: 1px 5px;
    border-radius: 999px;
    background: rgba(30, 41, 59, 0.82);
    color: #fff;
    font-size: 0.5rem;
    font-weight: 800;
    letter-spacing: 0.35px;
    text-transform: uppercase;
}

.transaction-ad-slot .transaction-ad-space {
    width: 100%;
    height: var(--transaction-ad-height, 54px);
    min-height: var(--transaction-ad-height, 54px);
    margin-top: 12px;
}

/* Security/export controls must stack cleanly on narrow phones. */
.backup-export-grid,
.backup-range-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    align-items: end;
}

.backup-range-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 12px;
}

@media (max-width: 560px) {
    .backup-export-grid,
    .backup-range-grid,
    .backup-range-actions {
        grid-template-columns: 1fr;
    }

    .backup-export-grid button,
    .backup-range-actions button {
        width: 100%;
        margin-top: 0 !important;
    }
}
