/* ===== RESET & BASE ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #0f0f0f;
    --bg-secondary: #1a1a1a;
    --bg-card: #222222;
    --text-primary: #ffffff;
    --text-secondary: #aaaaaa;
    --accent: #e53935;
    --accent-hover: #c62828;
    --success: #43a047;
    --border: #333333;
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;

    /* Header responsivo */
    --header-height: 0px;

    /* Altura útil para as ofertas (viewport - header) */
    --content-height: calc(100dvh - var(--header-height));
}

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== GARANTIR QUE OCUPA TELA INTEIRA EM QUALQUER DISPOSITIVO ===== */
html {
    height: -webkit-fill-available;
}

body {
    min-height: 100vh;
    min-height: -webkit-fill-available;
    min-height: 100dvh;
}

/* ===== OFERTAS CONTAINER ===== */
.ofertas-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    overflow: hidden;
    touch-action: none;
    background: #0a0a0a;
}

/* ===== OFERTA CARD ===== */
.oferta-card {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0a0a0a;
    transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.4s ease;
    will-change: transform;
    padding: 0 10px 10px;
}

.oferta-card .oferta-imagem-wrapper {
    border-radius: 8px;
    overflow: hidden;
}

/* Garante que cards inativos fiquem fora da tela */
.oferta-card.active {
    z-index: 2;
    transform: translateY(0);
    opacity: 1;
}

.oferta-card.next {
    z-index: 1;
    transform: translateY(100%);
    opacity: 0.95;
}

.oferta-card.prev {
    z-index: 0;
    transform: translateY(-100%);
    opacity: 0;
}

.oferta-card.swiping {
    transition: none;
}

/* ===== IMAGEM DA OFERTA ===== */
.oferta-imagem-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    background: #0a0a0a;
}

/* Remove gradiente decorativo - atrapalhava a visualizacao */
.oferta-imagem-wrapper::after {
    display: none;
}

.oferta-imagem {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    user-select: none;
    -webkit-user-drag: none;
    position: relative;
    z-index: 0;
}

/* Placeholder enquanto carrega */
.oferta-imagem.loading {
    opacity: 0;
}

.oferta-imagem.loaded {
    opacity: 1;
    transition: opacity 0.3s ease;
}

/* Placeholder shimmer enquanto a imagem carrega */
.oferta-imagem-wrapper:has(.oferta-imagem.loading) {
    background: linear-gradient(135deg, #0a0a0a 25%, #1a1a1a 50%, #0a0a0a 75%);
    background-size: 400% 400%;
    animation: shimmer 1.5s ease-in-out infinite;
}

@keyframes shimmer {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* ===== FALLBACK PARA PDF ===== */
.oferta-pdf-fallback {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: var(--bg-secondary);
    gap: 1.5rem;
    padding: 2rem;
}

.oferta-pdf-fallback .pdf-icon {
    width: 80px;
    height: 80px;
    background: var(--accent);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 700;
    color: white;
}

.oferta-pdf-fallback .pdf-nome {
    font-size: 1.1rem;
    color: var(--text-primary);
    text-align: center;
    max-width: 80%;
    word-break: break-word;
}

.btn-pdf {
    padding: 0.8rem 2rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    text-decoration: none;
}

.btn-pdf:hover {
    background: var(--accent-hover);
}

/* ===== HEADER ===== */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.85) 50%, rgba(0,0,0,0) 100%);
    pointer-events: none;
}

.header-logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    pointer-events: auto;
    display: block;
    opacity: 1;
    transition: opacity 0.2s ease;
}

.header-logo:hover {
    opacity: 1;
}

/* ===== CONTADOR DE OFERTAS ===== */
.oferta-counter {
    position: fixed;
    top: 0.5rem;
    right: max(1rem, env(safe-area-inset-right));
    z-index: 11;
    font-size: clamp(0.7rem, 2vw, 0.85rem);
    color: rgba(255,255,255,0.5);
    font-weight: 600;
    pointer-events: none;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
    text-shadow: 0 1px 4px rgba(0,0,0,0.6);
}

/* ===== INDICADOR DE SWIPE ===== */
.fullscreen-btn {
    position: fixed;
    bottom: max(1rem, env(safe-area-inset-bottom));
    right: max(1rem, env(safe-area-inset-right));
    z-index: 15;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: rgba(255,255,255,0.6);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    opacity: 0;
    animation: fadeIn 0.6s ease 1s forwards;
}

.fullscreen-btn:hover {
    background: rgba(0,0,0,0.6);
    color: rgba(255,255,255,0.9);
    transform: scale(1.1);
}

.fullscreen-btn:active {
    transform: scale(0.95);
}

.fullscreen-btn svg {
    width: 20px;
    height: 20px;
}

@media (min-width: 768px) {
    .fullscreen-btn {
        width: 44px;
        height: 44px;
        bottom: max(1.5rem, env(safe-area-inset-bottom));
        right: max(1.5rem, env(safe-area-inset-right));
    }
    .fullscreen-btn svg {
        width: 22px;
        height: 22px;
    }
}

/* ===== INDICADOR DE SWIPE ===== */
.swipe-indicator {
    position: fixed;
    bottom: max(2rem, env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: rgba(255,255,255,0.4);
    font-size: clamp(0.7rem, 2vw, 0.85rem);
    opacity: 0;
    animation: fadeInUp 0.6s ease 0.5s forwards, float 2s ease-in-out 1.1s infinite;
    pointer-events: none;
    text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

.swipe-indicator .arrow {
    width: clamp(20px, 4vw, 28px);
    height: clamp(20px, 4vw, 28px);
    border: 2px solid rgba(255,255,255,0.4);
    border-left: 0;
    border-top: 0;
    transform: rotate(45deg);
    animation: bounce 2s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-50%) translateY(-5px); }
}

@keyframes bounce {
    0%, 100% { transform: rotate(45deg) translateY(0); }
    50% { transform: rotate(45deg) translateY(5px); }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateX(-50%) translateY(10px); }
    to { opacity: 0.6; transform: translateX(-50%) translateY(0); }
}

/* ===== SCROLLBAR CUSTOMIZADA (DESKTOP) ===== */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

/* ===== LOADING SPINNER ===== */
.loading-spinner {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100;
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

.loading-spinner.hidden,
.hidden {
    display: none !important;
}

/* ===== MENSAGEM VAZIA ===== */
.empty-state {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--text-secondary);
    z-index: -1;
    pointer-events: none;
    animation: fadeIn 0.3s ease;
}

.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state p {
    font-size: 1rem;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ===== RESPONSIVO - TABLETS E DESKTOP ===== */
@media (min-width: 768px) {
    :root {
        --header-height: 0px;
    }

    .swipe-indicator .arrow {
        width: 28px;
        height: 28px;
    }
}

/* ===== RESPONSIVO - TELAS GRANDES (DESKTOP) ===== */
@media (min-width: 1200px) {
    html, body {
        background: #1a1a1a;
    }

    body::before {
        content: '';
        position: fixed;
        inset: 0;
        background: 
            radial-gradient(ellipse at 30% 50%, rgba(229,57,53,0.06) 0%, transparent 60%),
            radial-gradient(ellipse at 70% 50%, rgba(229,57,53,0.04) 0%, transparent 60%);
        pointer-events: none;
        z-index: 0;
    }

    .ofertas-container {
        left: 50%;
        transform: translateX(-50%);
        width: 480px;
        max-width: 90vw;
        border-radius: 12px;
        overflow: hidden;
        box-shadow: 0 0 60px rgba(0,0,0,0.5), 0 0 120px rgba(229,57,53,0.08);
        top: 50%;
        height: 85vh;
        max-height: 900px;
        transform: translate(-50%, -50%);
    }

    /* Header acompanha a largura do container no desktop */
    .header {
        width: 480px;
        max-width: 90vw;
        left: 50%;
        transform: translateX(-50%);
        border-radius: 12px 12px 0 0;
    }
}

/* ===== PULL-TO-REFRESH (MOBILE) ===== */
.pull-to-refresh {
    position: fixed;
    top: -60px;
    left: 0;
    right: 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    padding-bottom: 8px;
    height: 60px;
    background: rgba(0,0,0,0.85);
    color: rgba(255,255,255,0.6);
    font-size: 0.75rem;
    transition: transform 0.2s ease;
    pointer-events: none;
}

.pull-to-refresh.visible {
    transform: translateY(60px);
}

.pull-to-refresh.ready {
    transform: translateY(60px);
}

.pull-to-refresh.ready .pull-to-refresh-text {
    color: var(--accent);
}

.pull-to-refresh-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.2);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    opacity: 0;
    transition: opacity 0.2s;
}

.pull-to-refresh.loading .pull-to-refresh-spinner {
    opacity: 1;
}

.pull-to-refresh-arrow {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.5);
    border-left: 0;
    border-bottom: 0;
    transform: rotate(-45deg);
    transition: transform 0.2s;
}

.pull-to-refresh.ready .pull-to-refresh-arrow {
    transform: rotate(-45deg) translateY(3px);
    border-color: var(--accent);
}

/* ===== CREDITO DO DESENVOLVEDOR ===== */
.credit-footer {
    position: fixed;
    bottom: -60px;
    left: 0;
    right: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 60px;
    background: rgba(0,0,0,0.9);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
    pointer-events: none;
}

.credit-footer.visible {
    transform: translateY(-60px);
    opacity: 1;
}

.credit-footer.hiding {
    transform: translateY(0);
    opacity: 0;
    transition: transform 0.5s ease, opacity 0.5s ease;
}

.credit-text {
    font-size: clamp(0.8rem, 2.5vw, 1rem);
    color: rgba(255,255,255,0.6);
    font-weight: 400;
    letter-spacing: 0.03em;
    text-align: center;
}

.credit-text::before {
    content: '👨‍💻 ';
    font-size: 1.1em;
}

/* ===== SCROLLBAR CUSTOMIZADA (DESKTOP) ===== */
@media (orientation: landscape) and (max-height: 500px) {
    :root {
        --header-height: 0px;
    }

    .swipe-indicator {
        display: none;
    }
}
