/* iOS 26 STORE - LIQUID GLASS MAXED (FINAL VERSION)
   - FIXED: Logo da Loja (Padrão Ícone App - Squircle Perfeito)
   - FIXED: Scroll "Travado" (Sem efeito elástico/borrachudo)
   - FIXED: Último item cortado (Padding inferior aumentado)
   - FIXED: Scroll lateral contido (Não balança a página)
   - MAINTAINED: Glassmorphism Ultra & Light Mode Only
*/

:root {
    /* Core - LIGHT MODE ONLY */
    --bg: #F2F2F7;
    --card: #FFFFFF;
    --text: #1D1D1F;
    --text-strong: #000000;
    --gray: #8E8E93;

    /* iOS system blues */
    --accent: #007AFF;
    --accent-pressed: #0062CC;

    /* Separators */
    --border: rgba(60, 60, 67, 0.18);
    --separator: rgba(60, 60, 67, 0.29);

    /* Materials ULTRA (glassmorphism intensificado) */
    --material-top: rgba(242, 242, 247, 0.50);
    --material-tab: rgba(249, 249, 249, 0.60);
    --material-sheet: rgba(255, 255, 255, 0.65);

    /* Buttons */
    --btn-get-bg: var(--accent);
    --btn-get-text: #FFFFFF;
    --btn-secondary-bg: rgba(118, 118, 128, 0.12);
    --btn-secondary-text: var(--accent);

    /* Shadows VIBRANTES */
    --shadow-sheet: 0 -8px 32px rgba(0, 122, 255, 0.12), 0 -2px 8px rgba(0, 0, 0, 0.08);
    --shadow-card: 0 8px 24px rgba(0, 122, 255, 0.08), 0 2px 6px rgba(0, 0, 0, 0.04);
    --shadow-glow: 0 0 24px rgba(0, 122, 255, 0.15);

    /* Layout */
    --fixed-top-space: 130px;
    --tabbar-space: 49px;
    --page-max: 600px;

    /* Corner radii */
    --r-icon-list: 22.5%; 
    --r-icon-detail: 22.5%;
    --r-sheet: 14px;
    --r-btn-pill: 999px;

    /* Typography */
    --fs-title: 34px;
    --fs-body: 15px;
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
    * {
        scroll-behavior: auto !important;
        transition: none !important;
        animation: none !important;
    }
}

/* ---------------------------
   RESET / BASE - NATIVE FEEL
---------------------------- */
* {
    -webkit-tap-highlight-color: transparent;
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", system-ui, sans-serif;
}

html {
    height: 100%;
    /* TRAVA O EFEITO ELÁSTICO (BOUNCE) NO IOS */
    overscroll-behavior-y: none;
    -webkit-overflow-scrolling: touch;
}

body {
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
    
    /* Garante consistência no travamento do scroll */
    overscroll-behavior-y: none;
    
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    -webkit-text-size-adjust: 100%;

    padding-top: calc(var(--fixed-top-space) + env(safe-area-inset-top));
    
    /* FIX: Espaço extra para o último item não ficar atrás da TabBar */
    padding-bottom: calc(var(--tabbar-space) + env(safe-area-inset-bottom) + 85px);
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

button, .tab, .app-item {
    -webkit-user-select: none;
    user-select: none;
}

/* ---------------------------
   HEADER + SEARCH (LIQUID GLASS)
---------------------------- */
.fixed-top {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;

    background: var(--material-top);
    
    /* GLASSMORPHISM ULTRA */
    backdrop-filter: blur(28px) saturate(180%) brightness(105%) contrast(102%);
    -webkit-backdrop-filter: blur(28px) saturate(180%) brightness(105%) contrast(102%);

    border-bottom: 1px solid rgba(255, 255, 255, 0.25);
    box-shadow: 0 4px 16px rgba(0, 122, 255, 0.06), inset 0 -1px 0 rgba(255, 255, 255, 0.18);

    padding-top: max(10px, env(safe-area-inset-top));
}

header {
    max-width: var(--page-max);
    margin: 0 auto;

    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));

    padding-top: 8px;
    padding-bottom: 8px;

    display: flex;
    justify-content: space-between;
    align-items: center;
}

.page-title {
    font-size: var(--fs-title);
    font-weight: 700;
    letter-spacing: 0.2px;
    color: var(--text-strong);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* LOGO DA LOJA (PADRÃO APP ICON) */
.store-avatar {
    /* Tamanho fixo e quadrado (Igual aos ícones da lista) */
    width: 52px;
    height: 52px;
    
    /* REMOVIDO PADDING: A imagem vai encostar na borda */
    padding: 0;
    
    /* Formato Squircle Perfeito (22.5%) - O mesmo dos Apps */
    border-radius: 22.5%; 
    
    /* Garante que a imagem respeite as curvas */
    overflow: hidden;
    position: relative;
    
    /* Fundo sutil apenas se a imagem for PNG transparente */
    background: rgba(118, 118, 128, 0.12);
    
    /* Borda interna (Glass) igual aos apps */
    border: none;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.1), 0 4px 10px rgba(0, 0, 0, 0.1);
    
    cursor: pointer;
    flex-shrink: 0;
    
    display: flex;
    align-items: center;
    justify-content: center;
}

.store-avatar img {
    width: 100%;
    height: 100%;
    
    /* ESSENCIAL: 'cover' faz a imagem preencher TODO o quadrado */
    object-fit: cover; 
    
    display: block;
}

/* Search (glass input) */
.search-box {
    max-width: var(--page-max);
    margin: 0 auto;

    padding-bottom: 12px;
    position: relative;

    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));
}

.search-input {
    width: 100%;
    min-height: 40px;
    padding: 8px 12px 8px 36px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    
    background: rgba(118, 118, 128, 0.14);
    backdrop-filter: blur(12px) saturate(150%);
    -webkit-backdrop-filter: blur(12px) saturate(150%);

    font-size: 17px;
    color: var(--text-strong);
    font-weight: 400;

    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.08), 0 1px 0 rgba(255, 255, 255, 0.15);
}

.search-input::placeholder {
    color: var(--gray);
}

.search-input:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    background: rgba(255, 255, 255, 0.25);
    box-shadow: var(--shadow-glow), inset 0 1px 2px rgba(0, 0, 0, 0.08);
}

.search-icon {
    position: absolute;
    left: calc(max(20px, env(safe-area-inset-left)) + 10px);
    top: 40%;
    transform: translateY(-50%);
    width: 16px;
    color: var(--gray);
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.1));
}

/* ---------------------------
   LISTA DE APPS
---------------------------- */
.content {
    max-width: var(--page-max);
    margin: 0 auto;

    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));

    display: flex;
    flex-direction: column;
    gap: 0;
}

.app-item {
    display: flex;
    align-items: center;

    padding: 12px 0;
    background: transparent;
    border-bottom: 0.5px solid var(--separator);
    cursor: pointer;

    min-height: 74px;
}

.app-item:last-child {
    border-bottom: none;
}

.app-item:active {
    opacity: 0.85;
}

/* ÍCONE (LISTA) */
.icon-box {
    width: 62px;
    height: 62px;
    border-radius: var(--r-icon-list);
    overflow: hidden;
    margin-right: 15px;
    flex-shrink: 0;
    position: relative;
    
    -webkit-mask-image: -webkit-radial-gradient(white, black);
    mask-image: radial-gradient(white, black);

    background: rgba(118,118,128,0.12);
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.1), 0 4px 12px rgba(0, 0, 0, 0.08);
}

.icon-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.info-box {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-right: 10px;
}

.app-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-strong);
    margin-bottom: 2px;

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-sub {
    font-size: 13px;
    color: var(--gray);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* BOTÃO OBTER (GLASS PILL) */
.get-btn {
    min-height: 32px;
    padding: 6px 18px;

    background: linear-gradient(180deg, rgba(0, 122, 255, 1) 0%, rgba(0, 100, 220, 1) 100%);
    color: var(--btn-get-text);

    font-weight: 800;
    font-size: 13px;
    letter-spacing: 0.2px;

    border-radius: var(--r-btn-pill);
    border: 1px solid rgba(255, 255, 255, 0.25);
    flex-shrink: 0;
    text-transform: uppercase;
    cursor: pointer;

    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.25), 
                inset 0 1px 0 rgba(255, 255, 255, 0.35),
                inset 0 -1px 0 rgba(0, 0, 0, 0.15);
}

.get-btn:hover {
    filter: brightness(1.05);
    box-shadow: 0 6px 16px rgba(0, 122, 255, 0.35), 
                inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.get-btn:active {
    background: linear-gradient(180deg, rgba(0, 100, 220, 1) 0%, rgba(0, 80, 180, 1) 100%);
    transform: translateY(0.5px);
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.3), 
                inset 0 1px 0 rgba(0, 0, 0, 0.15);
}

.get-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ---------------------------
   BANNER DESTAQUE (GLASS OVERLAY)
---------------------------- */
.featured-label {
    font-size: 11px;
    font-weight: 800;
    color: var(--accent);
    text-transform: uppercase;

    margin: 20px 0 8px;

    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));
    
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.featured-container {
    margin-left: max(20px, env(safe-area-inset-left));
    margin-right: max(20px, env(safe-area-inset-right));
    margin-bottom: 30px;

    position: relative;
    aspect-ratio: 16/9;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: var(--shadow-card);
    border: 1.5px solid rgba(255, 255, 255, 0.25);
}

.feat-slide {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: 0.6s;
    cursor: pointer;
}

.feat-slide.active {
    opacity: 1;
    z-index: 2;
}

.feat-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.feat-overlay {
    position: absolute;
    bottom: 0;
    width: 100%;

    padding: 18px;
    
    background: linear-gradient(to top, 
                rgba(0,0,0,0.85) 0%, 
                rgba(0,0,0,0.55) 50%,
                transparent 100%);
    
    backdrop-filter: blur(12px) saturate(140%);
    -webkit-backdrop-filter: blur(12px) saturate(140%);
    
    color: #fff;
    
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* ---------------------------
   SHEET FULLSCREEN (LIQUID GLASS ULTRA)
---------------------------- */
.sheet-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.50);
    z-index: 2000;
    
    backdrop-filter: blur(8px) saturate(120%);
    -webkit-backdrop-filter: blur(8px) saturate(120%);
}

.sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;

    height: calc(100dvh - env(safe-area-inset-top));
    max-height: 100dvh;

    background: var(--material-sheet);
    
    /* LIQUID GLASS EXTREMO */
    backdrop-filter: blur(42px) saturate(190%) brightness(108%) contrast(103%);
    -webkit-backdrop-filter: blur(42px) saturate(190%) brightness(108%) contrast(103%);
    
    z-index: 2001;

    border-radius: var(--r-sheet) var(--r-sheet) 0 0;
    
    border-top: 2px solid rgba(255, 255, 255, 0.35);
    border-left: 1px solid rgba(255, 255, 255, 0.15);
    border-right: 1px solid rgba(255, 255, 255, 0.15);
    
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);

    display: flex;
    flex-direction: column;
    
    box-shadow: var(--shadow-sheet),
                inset 0 1px 0 rgba(255, 255, 255, 0.25);

    contain: layout paint;
}

@supports not (height: 100dvh) {
    .sheet {
        height: calc(100vh - env(safe-area-inset-top));
        max-height: 100vh;
    }
}

.sheet.show {
    transform: translateY(0);
}

/* Barra "puxar" (glass handle) */
.sheet-handle-bar {
    width: 100%;
    height: 28px;

    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;

    background: transparent;
    border-radius: var(--r-sheet) var(--r-sheet) 0 0;
}

.sheet-handle {
    width: 40px;
    height: 5px;
    background: rgba(118, 118, 128, 0.35);
    border-radius: 3px;
    
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15),
                inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.sheet-header { display: none; }

.sheet-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;

    padding-bottom: calc(40px + env(safe-area-inset-bottom));
}

/* ---------------------------
   DETALHES DO APP
---------------------------- */
.detail-top {
    padding-top: 10px;
    padding-bottom: 20px;

    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));

    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.detail-icon {
    width: 118px;
    height: 118px;
    border-radius: var(--r-icon-detail);
    border: none;
    object-fit: cover;
    background: rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
    
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.1), 0 8px 24px rgba(0, 122, 255, 0.12);
}

.detail-meta {
    flex: 1;
    padding-top: 2px;
    min-width: 0;
}

.detail-meta h2 {
    font-size: 22px;
    font-weight: 800;
    color: var(--text-strong);
    line-height: 1.2;
    margin-bottom: 4px;

    overflow: hidden;
    text-overflow: ellipsis;
    
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.detail-meta p {
    color: var(--gray);
    font-size: 15px;
    margin-bottom: 12px;

    overflow: hidden;
    text-overflow: ellipsis;
}

.action-buttons {
    display: flex;
    gap: 10px;
}

.btn-install {
    min-height: 36px;
    
    background: linear-gradient(180deg, rgba(0, 122, 255, 1) 0%, rgba(0, 100, 220, 1) 100%);
    color: #fff;
    border: 1.5px solid rgba(255, 255, 255, 0.30);

    padding: 8px 24px;
    border-radius: var(--r-btn-pill);
    font-weight: 800;
    font-size: 15px;
    cursor: pointer;
    
    box-shadow: 0 6px 18px rgba(0, 122, 255, 0.30),
                inset 0 1px 0 rgba(255, 255, 255, 0.40),
                inset 0 -1px 0 rgba(0, 0, 0, 0.15);
}

.btn-install:active {
    background: linear-gradient(180deg, rgba(0, 100, 220, 1) 0%, rgba(0, 80, 180, 1) 100%);
    transform: translateY(0.5px);
    box-shadow: 0 3px 10px rgba(0, 122, 255, 0.35),
                inset 0 1px 0 rgba(0, 0, 0, 0.15);
}

.btn-share {
    width: 36px;
    height: 36px;
    border-radius: 50%;

    background: rgba(118, 118, 128, 0.16);
    backdrop-filter: blur(10px) saturate(150%);
    -webkit-backdrop-filter: blur(10px) saturate(150%);
    
    color: var(--accent);

    display: flex;
    align-items: center;
    justify-content: center;

    border: 1px solid rgba(255, 255, 255, 0.30);
    cursor: pointer;
    
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08),
                inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.btn-share:active {
    filter: brightness(0.92);
    transform: translateY(0.5px);
}

/* ---------------------------
   STATS GRID (TRAVADO LATERAL)
---------------------------- */
.meta-grid {
    display: flex;
    justify-content: space-between;
    gap: 12px;

    padding-top: 15px;
    padding-bottom: 15px;

    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));

    /* Bordas sutis no lugar de fundo */
    border-top: 1px solid rgba(142, 142, 147, 0.15);
    border-bottom: 1px solid rgba(142, 142, 147, 0.15);
    
    background: transparent;
    backdrop-filter: none;

    margin-bottom: 20px;
    overflow-x: auto;
    scrollbar-width: none;
    
    /* Impede que o scroll lateral balance a página (Navegação voltar) */
    overscroll-behavior-x: contain;
}

.meta-grid::-webkit-scrollbar { display: none; }

.meta-item {
    text-align: center;
    min-width: 60px;
}

.meta-label {
    font-size: 10px;
    color: #8A8A8E;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.meta-val {
    font-size: 18px;
    font-weight: 700;
    color: #8A8A8E;
}

.meta-val.highlight {
    color: var(--text-strong);
}

/* Screenshots (TRAVADO LATERAL) */
.screenshots {
    display: flex;
    overflow-x: auto;
    gap: 15px;

    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));
    padding-bottom: 25px;

    scrollbar-width: none;
    
    /* Impede que o scroll lateral balance a página */
    overscroll-behavior-x: contain;
}
.screenshots::-webkit-scrollbar { display: none; }

.screenshot-item {
    flex: 0 0 240px;
    aspect-ratio: 9/19.5;
    border-radius: 20px;

    background: #000;
    overflow: hidden;

    border: 1.5px solid rgba(255, 255, 255, 0.20);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15),
                inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.screenshot-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.desc-text {
    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));
    padding-bottom: 25px;

    font-size: var(--fs-body);
    line-height: 1.5;
    color: var(--text-strong);
}

/* ---------------------------
   AVALIAÇÕES (GLASS CARDS)
---------------------------- */
.reviews-header {
    display: flex;
    justify-content: space-between;
    align-items: center;

    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));
    padding-bottom: 10px;
}

.rev-card {
    background: rgba(118, 118, 128, 0.08);
    backdrop-filter: blur(16px) saturate(150%);
    -webkit-backdrop-filter: blur(16px) saturate(150%);

    padding: 16px;
    border-radius: 14px;

    margin-left: max(20px, env(safe-area-inset-left));
    margin-right: max(20px, env(safe-area-inset-right));
    margin-bottom: 15px;
    
    border: 1px solid rgba(255, 255, 255, 0.25);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08),
                inset 0 1px 0 rgba(255, 255, 255, 0.20);
}

.rev-top {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
    gap: 10px;
}

.rev-user {
    font-weight: 800;
    font-size: 14px;
    color: var(--text-strong);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rev-date {
    color: var(--gray);
    font-size: 13px;
    flex-shrink: 0;
}

.rev-stars {
    color: #FF9500;
    font-size: 12px;
    margin-bottom: 6px;
    filter: drop-shadow(0 1px 2px rgba(255, 149, 0, 0.25));
}

.rev-text {
    font-size: 14px;
    line-height: 1.4;
    color: color-mix(in oklab, var(--text-strong), var(--gray) 18%);
}

/* ---------------------------
   TAB BAR (LIQUID GLASS)
---------------------------- */
.tab-bar-wrap {
    position: fixed;
    bottom: 0;
    width: 100%;

    background: var(--material-tab);
    
    backdrop-filter: blur(32px) saturate(180%) brightness(106%) contrast(102%);
    -webkit-backdrop-filter: blur(32px) saturate(180%) brightness(106%) contrast(102%);

    border-top: 1px solid rgba(255, 255, 255, 0.30);
    box-shadow: 0 -4px 16px rgba(0, 122, 255, 0.06),
                inset 0 1px 0 rgba(255, 255, 255, 0.22);

    padding-bottom: env(safe-area-inset-bottom);

    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

.tab-bar {
    display: flex;
    height: var(--tabbar-space);
    max-width: var(--page-max);
    margin: 0 auto;
}

.tab {
    flex: 1;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    color: color-mix(in oklab, var(--gray), #000 25%);
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;

    min-height: 44px;
}

.tab svg {
    display: block;
    margin-bottom: 2px;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.08));
}

.tab.active {
    color: var(--accent);
}

.tab.active svg {
    filter: drop-shadow(0 1px 2px rgba(0, 122, 255, 0.35));
}

.tab:active {
    opacity: 0.75;
}

/* ---------------------------
   RESPONSIVO (MOBILE-FIRST)
---------------------------- */
@media (max-width: 360px) {
    :root {
        --fixed-top-space: 122px;
    }
    .page-title { 
        font-size: 30px; 
    }
    .screenshot-item { 
        flex-basis: 220px; 
    }
    .detail-icon {
        width: 100px;
        height: 100px;
    }
    .detail-meta h2 {
        font-size: 20px;
    }
    .action-buttons {
        flex-direction: column;
        width: 100%;
    }
    .btn-install {
        width: 100%;
    }
}

@media (max-height: 680px) {
    :root {
        --fixed-top-space: 118px;
    }
}

@media (min-width: 361px) and (max-width: 480px) {
    .screenshot-item {
        flex-basis: 230px;
    }
}

@media (min-width: 481px) {
    .screenshot-item {
        flex-basis: 260px;
    }
}

/* Landscape mobile */
@media (max-height: 500px) and (orientation: landscape) {
    :root {
        --fixed-top-space: 110px;
    }
    .page-title {
        font-size: 28px;
    }
}
