/*
 * SECURITY (Fase 47 — C.1 + C.2b mobile-first): Modernização CSS frontend cliente
 * MOBILE-FIRST: 99% dos clientes usam mobile. Estilos base = mobile.
 * Media queries (min-width) ampliam pra desktop.
 *
 * Performance:
 *   - Shadows simples em mobile (1 layer), camadas em desktop
 *   - Transitions só em GPU-friendly properties (transform, opacity, filter)
 *   - prefers-reduced-motion respeitado
 *   - Touch targets ≥ 44px (Apple HIG)
 *   - Override do sorteio-v5.css mantendo todas as cores
 */

/* =========================================================================
   0. BACKGROUND DA PÁGINA
   ========================================================================= */
body {
    background-color: #f1f5f9 !important; /* slate-100 — limpo */
}

/* =========================================================================
   1. TIPOGRAFIA — system stack (Inter via fallback) — sem custom font HTTP
   ========================================================================= */
body,
.card-container,
.body-cotas-premiadas,
.btns-controls-actions {
    font-family: 'Inter', 'Montserrat', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.card-texts h2 {
    font-size: 19px;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
    margin-bottom: 4px;
}

.card-texts p {
    font-size: 13px;
    font-weight: 500;
    color: #475569;
    line-height: 1.4;
}

.draw-date p {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: #64748b;
}

.draw-date span {
    font-size: 13px;
    font-weight: 600;
}

.price-container .price-content .price-item {
    font-size: 13px;
    font-weight: 600;
}

.price-container .price-content .price-item span {
    font-size: 14px;
    font-weight: 700;
}

/* =========================================================================
   2. CARDS — bordas + shadow simples (1 layer em mobile)
   ========================================================================= */
.card-container .card-item.first-card-item.carousel {
    border-radius: 12px !important;
    overflow: hidden;
    box-shadow: 0 4px 12px -4px rgba(15, 23, 42, 0.12);
}

.card-texts {
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.96);
    border-radius: 0 0 12px 12px;
}

.draw-date span {
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.06);
    padding: 7px 10px;
}

.price-container .price-content .price-item span {
    border-radius: 8px;
    padding: 7px 10px;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.06);
}

/* =========================================================================
   3. BOTÕES PRINCIPAIS — Comprar, Participar, Ver meus títulos
   Touch target ≥ 44px (Apple HIG)
   ========================================================================= */

/* "COMPRAR" verde no topo */
.btns-controls-actions .btn-success.inline-buttons-draw {
    border-radius: 12px;
    font-weight: 700;
    letter-spacing: 0.01em;
    padding: 13px 16px;
    min-height: 48px;
    transition: transform .15s ease, box-shadow .2s ease;
    will-change: transform;
    box-shadow: 0 4px 14px -4px rgba(34, 197, 94, 0.45);
}

.btns-controls-actions .btn-success.inline-buttons-draw:active {
    transform: scale(0.98);
}

/* "Ver meus títulos" — slate moderno (override cinza Bootstrap) */
.btns-controls-actions .button-item {
    background: linear-gradient(135deg, #475569, #64748b) !important;
    border: none !important;
    color: #ffffff !important;
    border-radius: 12px;
    font-weight: 600;
    letter-spacing: 0.01em;
    padding: 12px 16px;
    min-height: 48px;
    transition: transform .15s ease;
    will-change: transform;
    box-shadow: 0 4px 12px -4px rgba(15, 23, 42, 0.20);
}

.btns-controls-actions .button-item:active {
    transform: scale(0.98);
}

/* Override de style="background-color: rgb(108, 117, 125)" inline */
.btns-controls-actions .button-item[style*="rgb(108"],
.btns-controls-actions .button-item[style*="108, 117, 125"] {
    background: linear-gradient(135deg, #475569, #64748b) !important;
    background-color: #475569 !important;
}

/* "Participar R$ X,XX" — verde dentro do card de quantidade */
.button-container .button-item.join {
    border-radius: 12px !important;
    font-weight: 700;
    letter-spacing: 0.01em;
    padding: 13px 16px;
    min-height: 48px;
    border: none;
    transition: transform .15s ease;
    will-change: transform;
    box-shadow: 0 4px 14px -4px rgba(34, 197, 94, 0.45);
}

.button-container .button-item.join:active {
    transform: scale(0.98);
}

.button-container .button-item.join .calculed-price {
    font-weight: 700;
    letter-spacing: -0.01em;
}

/* =========================================================================
   4. CARDS DE QUANTIDADE (+50, +100, +300, +500, +1000, +3000)
   ========================================================================= */
.controls {
    border-radius: 14px;
    padding: 14px;
    background: #ffffff !important;
    box-shadow: 0 2px 12px -4px rgba(15, 23, 42, 0.06);
}

.controls .select-quantity {
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
    letter-spacing: 0.01em;
    margin-bottom: 12px;
}

/* FIX (Fase 53d-3): grid 3 colunas robusto pra mobile.
   Antes usava `flex-wrap` herdado de sorteio-v5.css com `width: 32%` +
   `gap: 10px`, totalizando 96% + 20px > 100% em viewports < 480px.
   Resultado: cards saiam da tela no iPhone real do cliente. */
.container-quantity {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 10px !important;
    flex-wrap: nowrap !important;
    width: 100%;
    box-sizing: border-box;
}

.content-quantity {
    background: #f8fafc !important;
    border: 1px solid #e2e8f0;
    border-radius: 12px !important;
    padding: 14px 10px !important;
    min-height: 76px; /* touch comfort */
    transition: transform .15s ease, border-color .2s ease, background-color .2s ease !important;
    cursor: pointer;
    position: relative;
    will-change: transform;
    width: auto !important;
    min-width: 0 !important;
    box-sizing: border-box;
}

/* FIX (Fase 53d-3): em iPhone SE (320px), 3 colunas ainda apertam.
   Quebra pra 2 colunas em viewports < 360px. */
@media (max-width: 359px) {
    .container-quantity {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

.content-quantity:active {
    transform: scale(0.98);
    background: #f1f5f9 !important;
}

/* Variante "Mais Popular" — override do sorteio-v5.css */
.content-quantity.most-popular {
    background: #ffffff !important;
    border-color: #22c55e !important;
    border-width: 2px !important;
    box-shadow: 0 2px 10px -3px rgba(34, 197, 94, 0.25);
    overflow: visible !important;
    margin-top: 12px;
}

.content-quantity.most-popular::before {
    background: linear-gradient(90deg, #14532d, #22c55e) !important;
    background-color: #22c55e !important;
    border: none !important;
    color: #ffffff !important;
    font-weight: 700 !important;
    letter-spacing: 0.06em !important;
    text-transform: uppercase !important;
    font-size: 9px !important;
    padding: 4px 10px !important;
    border-radius: 999px !important;
    width: auto !important;
    top: -10px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    white-space: nowrap !important;
    box-shadow: 0 2px 6px rgba(34, 197, 94, 0.30) !important;
    z-index: 2;
}

.content-quantity .number-select {
    font-size: 22px;
    font-weight: 700 !important;
    letter-spacing: -0.025em;
    color: #0f172a;
    margin-bottom: 2px;
    line-height: 1.1;
}

.content-quantity .number-select small {
    font-size: 14px;
    font-weight: 600;
    color: #475569;
    margin-right: 1px;
}

.content-quantity > p {
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #94a3b8;
    margin: 0;
}

.content-quantity.most-popular > p {
    color: #475569;
}

/* =========================================================================
   5. INPUT QUANTIDADE + BOTÕES +/-
   ========================================================================= */
.product-buttons-content {
    border-radius: 12px;
    padding: 4px 8px;
    box-shadow: 0 2px 10px -4px rgba(15, 23, 42, 0.10);
}

.product-buttons-content:focus-within {
    box-shadow: 0 0 0 3px rgba(240, 127, 78, 0.10);
}

.product-buttons-input input {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.02em;
    border-radius: 8px;
}

.product-buttons-input input:focus {
    outline: none;
    border-color: #d3542d;
}

/* Botões +/- — touch target ≥ 44px */
.product-buttons-base.button-auto {
    border-radius: 999px;
    width: 44px;
    height: 44px;
    transition: transform .12s ease, background-color .15s ease;
    will-change: transform;
}

.product-buttons-base.button-auto:active {
    transform: scale(0.92);
    background-color: rgba(15, 23, 42, 0.06);
}

/* =========================================================================
   6. SEÇÕES DE PRÊMIOS (Caixas, Roletas, Raspadinhas)
   ========================================================================= */
.body-cotas-premiadas {
    border-radius: 12px;
    padding: 14px;
    box-shadow: 0 2px 12px -4px rgba(15, 23, 42, 0.06);
}

.body-cotas-premiadas .title-container .title {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.body-cotas-premiadas .title-container .title-sub {
    font-size: 11px;
    font-weight: 500;
    color: #64748b;
    text-transform: uppercase;
}

.body-cotas-premiadas .btn.bg-gradient-blue,
.body-cotas-premiadas .btn.bg-gradient-green,
.body-cotas-premiadas .btn.bg-gradient-red {
    border-radius: 999px !important;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    font-size: 11px;
    padding: 4px 10px !important;
    box-shadow: 0 2px 6px -2px rgba(15, 23, 42, 0.18);
}

.row-cota {
    border-radius: 10px;
    transition: background-color .15s ease;
}

.row-cota:not(.cota-comprada):active {
    background-color: rgba(15, 23, 42, 0.04);
}

.row-cota .badge.number-cota,
.row-cota .number-cota.number-comprado {
    border-radius: 8px;
    padding: 4px 9px;
    font-weight: 700;
    font-size: 12px;
}

#btnMostrarMaisPremiosCaixas,
#btnMostrarMaisPremiosRoleta,
#btnMostrarMaisPremiosRaspadinha {
    border-radius: 10px !important;
    font-weight: 600;
    padding: 11px 14px !important;
    min-height: 44px;
    transition: transform .15s ease;
    will-change: transform;
    box-shadow: 0 3px 10px -3px rgba(0, 0, 0, 0.18);
}

#btnMostrarMaisPremiosCaixas:active,
#btnMostrarMaisPremiosRoleta:active,
#btnMostrarMaisPremiosRaspadinha:active {
    transform: scale(0.98);
}

/* =========================================================================
   7. DESCRIÇÃO / REGULAMENTO
   ========================================================================= */
.app-card.sorteio_sorteioDesc__TBYaL {
    border-radius: 12px;
    padding: 12px 14px;
    box-shadow: 0 2px 8px -3px rgba(15, 23, 42, 0.06);
}

#toggleButton {
    font-weight: 600;
    min-height: 44px;
}

/* =========================================================================
   8. ALERTAS + PROGRESS
   ========================================================================= */
.alert {
    border-radius: 12px;
    box-shadow: 0 3px 10px -3px rgba(15, 23, 42, 0.10);
}

.progress {
    border-radius: 999px;
    overflow: hidden;
    height: 14px;
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.10);
}

.progress-bar {
    border-radius: 999px;
    font-weight: 700;
    letter-spacing: 0.04em;
    transition: width .4s ease;
}

/* =========================================================================
   9. ACCESSIBILITY — prefers-reduced-motion
   ========================================================================= */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* =========================================================================
   10. DESKTOP — refinamentos para telas maiores (≥ 768px)
   Aqui ampliamos shadows pra layered, transitions com hover, paddings maiores
   ========================================================================= */
@media (min-width: 768px) {
    .card-texts h2 { font-size: 22px; }
    .card-texts p { font-size: 14px; }

    .card-container .card-item.first-card-item.carousel {
        border-radius: 14px !important;
        box-shadow:
            0 1px 2px rgba(15, 23, 42, 0.06),
            0 8px 24px -8px rgba(15, 23, 42, 0.12);
        transition: transform .25s ease, box-shadow .25s ease;
    }

    .card-container .card-item.first-card-item.carousel:hover {
        box-shadow:
            0 1px 2px rgba(15, 23, 42, 0.08),
            0 12px 32px -8px rgba(15, 23, 42, 0.18);
    }

    /* Botões com hover translate (só desktop tem mouse hover) */
    .btns-controls-actions .btn-success.inline-buttons-draw,
    .btns-controls-actions .button-item,
    .button-container .button-item.join {
        transition: transform .15s ease, filter .15s ease, box-shadow .25s ease;
    }

    .btns-controls-actions .btn-success.inline-buttons-draw:hover,
    .button-container .button-item.join:hover {
        transform: translateY(-1px);
        filter: brightness(1.04);
        box-shadow:
            0 1px 2px rgba(20, 83, 45, 0.22),
            0 12px 26px -4px rgba(34, 197, 94, 0.50);
    }

    .btns-controls-actions .button-item:hover {
        transform: translateY(-1px);
        filter: brightness(1.10);
        box-shadow:
            0 1px 2px rgba(15, 23, 42, 0.16),
            0 8px 18px -4px rgba(15, 23, 42, 0.28);
    }

    /* Cards quantidade com hover */
    .content-quantity {
        padding: 16px 12px !important;
        border-radius: 14px !important;
    }
    .content-quantity:hover {
        transform: translateY(-2px);
        background: #ffffff !important;
        border-color: #cbd5e1;
        box-shadow:
            0 1px 3px rgba(15, 23, 42, 0.05),
            0 8px 20px -6px rgba(15, 23, 42, 0.14);
    }
    .content-quantity:not(.most-popular):active {
        transform: translateY(0);
    }

    .content-quantity.most-popular {
        box-shadow:
            0 1px 3px rgba(20, 83, 45, 0.06),
            0 6px 18px -6px rgba(34, 197, 94, 0.20);
    }
    .content-quantity.most-popular:hover {
        box-shadow:
            0 1px 3px rgba(20, 83, 45, 0.10),
            0 10px 24px -6px rgba(34, 197, 94, 0.32);
    }

    .content-quantity .number-select { font-size: 24px; }
    .content-quantity > p { font-size: 10px; }

    /* Botões +/- maiores em desktop */
    .product-buttons-base.button-auto:hover {
        transform: scale(1.06);
        background-color: rgba(15, 23, 42, 0.04);
    }
    .product-buttons-base.button-auto:hover i {
        color: #d3542d;
    }

    .body-cotas-premiadas {
        padding: 16px;
        border-radius: 14px;
    }

    .body-cotas-premiadas .title-container .title {
        font-size: 18px;
    }

    .body-cotas-premiadas .btn.bg-gradient-blue,
    .body-cotas-premiadas .btn.bg-gradient-green,
    .body-cotas-premiadas .btn.bg-gradient-red {
        transition: transform .15s ease, box-shadow .2s ease;
    }
    .body-cotas-premiadas .btn.bg-gradient-blue:hover,
    .body-cotas-premiadas .btn.bg-gradient-green:hover,
    .body-cotas-premiadas .btn.bg-gradient-red:hover {
        transform: translateY(-1px);
        box-shadow:
            0 1px 2px rgba(15, 23, 42, 0.12),
            0 4px 12px -2px rgba(15, 23, 42, 0.22);
    }

    .row-cota:not(.cota-comprada):hover {
        background-color: rgba(15, 23, 42, 0.025);
        transform: translateX(2px);
    }

    .draw-date span {
        font-size: 13px;
        padding: 8px 12px;
        box-shadow:
            0 1px 2px rgba(15, 23, 42, 0.04),
            0 2px 6px rgba(15, 23, 42, 0.06);
    }

    .price-container .price-content .price-item {
        font-size: 14px;
    }
    .price-container .price-content .price-item span {
        font-size: 15px;
        padding: 8px 12px;
        box-shadow:
            0 1px 2px rgba(15, 23, 42, 0.04),
            0 2px 6px rgba(15, 23, 42, 0.06);
    }

    .draw-date p { font-size: 13px; }
}
