/* Premium PWA App-like Shell */
:root {
    --bg-darker: #0b0c10;
    --bg-dark: #121212;
    --bg-panel: #1f2833;
    --accent-green: #1db954;
    --accent-green-dim: rgba(29, 185, 84, 0.18);

    --bottom-nav-height: 64px;
}

body {
    background: var(--bg-darker);
    color: #fff;
}

/* On screens where the bottom nav is visible we pad the body so content isn't
   hidden under the fixed bar. */
@media (max-width: 768px) {
    body.has-bottom-nav {
        padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom));
    }
}

/* Mobile Bottom Navigation */
.pwa-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background: rgba(10, 10, 10, 0.92);
    backdrop-filter: blur(20px) saturate(140%);
    -webkit-backdrop-filter: blur(20px) saturate(140%);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: none;
    z-index: 50;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding-inline: max(env(safe-area-inset-left), 0.4rem) max(env(safe-area-inset-right), 0.4rem);
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.35);
}

@media (max-width: 768px) {
    .pwa-bottom-nav {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        align-items: stretch;
        gap: 0.15rem;
    }
}

.pwa-bottom-nav.hide-down {
    transform: translateY(100%);
}

.pwa-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    color: var(--color-muted, #cbd5e1);
    font-size: 0.7rem;
    font-weight: 600;
    text-decoration: none;
    min-block-size: 100%;
    inline-size: 100%;
    padding: 0.4rem 0.25rem;
    background: transparent;
    border: 0;
    border-radius: 0.75rem;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.2s, background 0.2s;
}

.pwa-nav-item svg {
    width: 1.3rem;
    height: 1.3rem;
    fill: none;
    stroke: currentColor;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    flex: 0 0 auto;
}

.pwa-nav-item span {
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-inline-size: 100%;
    font-size: 0.7rem;
}

.pwa-nav-item.is-active {
    color: var(--color-green-bright, #1db954);
    background: rgba(29, 185, 84, 0.12);
}

.pwa-nav-item.is-active svg {
    transform: scale(1.12);
}

.pwa-nav-item:active {
    transform: scale(0.96);
}

.pwa-nav-item--menu {
    font: inherit;
    color: var(--color-muted, #cbd5e1);
}

/* WhatsApp floating button — sits above the bottom nav on mobile */
.whatsapp-float {
    position: fixed;
    width: 56px;
    height: 56px;
    bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom) + 14px);
    inset-inline-end: 1rem;
    background-color: #25d366;
    color: #FFF;
    border-radius: 50%;
    text-align: center;
    font-size: 28px;
    box-shadow: 0 12px 28px rgba(37, 211, 102, 0.45);
    z-index: 65;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s, box-shadow 0.3s;
    text-decoration: none;
}

.whatsapp-float:hover {
    transform: scale(1.08);
    box-shadow: 0 16px 32px rgba(37, 211, 102, 0.55);
}

.whatsapp-float svg {
    width: 28px;
    height: 28px;
    fill: #fff;
    display: block;
}

@media (min-width: 769px) {
    .whatsapp-float {
        width: 60px;
        height: 60px;
        bottom: 1.5rem;
        inset-inline-end: 1.5rem;
        font-size: 30px;
    }
    .whatsapp-float svg {
        width: 30px;
        height: 30px;
    }
}

/* Page Transitions (SPA) */
.page-transition-enter {
    opacity: 0;
    transform: translateY(10px);
}
.page-transition-enter-active {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 300ms ease, transform 300ms cubic-bezier(0.4, 0, 0.2, 1);
}
.page-transition-exit {
    opacity: 1;
}
.page-transition-exit-active {
    opacity: 0;
    transition: opacity 200ms ease;
}

/* Skeleton Loaders */
.skeleton {
    background: linear-gradient(90deg, var(--bg-panel) 25%, rgba(255,255,255,0.08) 50%, var(--bg-panel) 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: 8px;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* RTL Helpers */
[dir="rtl"] .margin-start-auto { margin-inline-start: auto; }
[dir="rtl"] .padding-end-lg { padding-inline-end: 2rem; }

/* Manga Reader PWA UI */
[data-manga-reader] {
    background: #000; /* Pitch black for OLED / App-feel */
    min-height: 100vh;
    position: relative;
}

.reader-toolbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    transition: transform 0.3s ease;
}

.reader-toolbar.hide-up {
    transform: translateY(-100%);
}

.reader-canvas {
    padding-bottom: 80px; /* Space for bottom nav */
}

.reader-page {
    margin: 0;
    padding: 0;
}

.reader-page img {
    display: block;
    margin: 0 auto;
}

.reader-page figcaption {
    display: none; /* Hide standard figcaption in app mode */
}

/* Vertical Mode */
.reader-vertical .reader-page img {
    width: 100%;
    max-width: 800px; /* Max readable width */
    height: auto;
}

/* Paged Mode */
.reader-paged .reader-canvas {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 64px);
}

.reader-paged .reader-page {
    position: absolute;
    top: 64px; /* below toolbar */
    left: 0;
    right: 0;
    bottom: 64px; /* above bottom nav */
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.reader-paged .reader-page[style*="display: block"] {
    opacity: 1;
}

.reader-paged .reader-page img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}
