/* ============================================================
   MINI APP E-COMMERCE - CASA INTELIGENTE SHOPEE
   Design System: Profissional, Responsivo, Moderno
   ============================================================ */

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

:root {
    --primary: #6C5CE7;
    --primary-dark: #5A4BD1;
    --primary-light: #A29BFE;
    --secondary: #00CEC9;
    --accent: #FD79A8;
    --bg: #F8F9FA;
    --bg-card: #FFFFFF;
    --text: #2D3436;
    --text-light: #636E72;
    --text-muted: #B2BEC3;
    --border: #E9ECEF;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-hover: 0 8px 24px rgba(0,0,0,0.12);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --max-width: 1200px;
    --header-height: 64px;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    cursor: pointer;
    border: none;
    background: none;
    font-family: inherit;
}

.container {
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 16px;
}

/* ============================================================
   HEADER
   ============================================================ */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    height: var(--header-height);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    font-size: 28px;
    line-height: 1;
}

.logo-text h1 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}

.logo-subtitle {
    font-size: 11px;
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.menu-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    padding: 8px;
}

.menu-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
    transition: var(--transition);
}

/* ============================================================
   HERO
   ============================================================ */
.hero {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    padding: 48px 0 40px;
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 400px;
    height: 400px;
    background: rgba(255,255,255,0.05);
    border-radius: 50%;
    pointer-events: none;
}

.hero-content {
    position: relative;
    z-index: 1;
    text-align: center;
    max-width: 640px;
    margin: 0 auto;
}

.hero-badge {
    display: inline-block;
    background: linear-gradient(135deg, var(--accent), #E84393);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    padding: 6px 16px;
    border-radius: 50px;
    letter-spacing: 1px;
    margin-bottom: 16px;
    text-transform: uppercase;
    animation: pulse-badge 2s ease-in-out infinite;
}

@keyframes pulse-badge {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.hero h2 {
    font-size: clamp(26px, 5vw, 42px);
    font-weight: 800;
    color: #fff;
    margin-bottom: 12px;
    line-height: 1.2;
}

.hero .highlight {
    background: linear-gradient(135deg, var(--secondary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero p {
    color: rgba(255,255,255,0.9);
    font-size: 15px;
    margin-bottom: 24px;
    line-height: 1.6;
}

.hero p strong {
    color: #fff;
    font-weight: 700;
}

.search-box {
    display: flex;
    background: #fff;
    border-radius: 50px;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    max-width: 480px;
    margin: 0 auto;
}

.search-box input {
    flex: 1;
    padding: 14px 20px;
    border: none;
    outline: none;
    font-size: 15px;
    font-family: inherit;
    color: var(--text);
    background: transparent;
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.search-box button {
    padding: 14px 20px;
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.search-box button:hover {
    background: var(--primary);
    color: #fff;
}

/* ============================================================
   CATEGORIAS
   ============================================================ */
.categories {
    padding: 24px 0;
}

.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 12px;
}

.category-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: var(--transition);
    cursor: pointer;
}

.category-card:hover {
    border-color: var(--primary-light);
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

.category-card.active {
    border-color: var(--primary);
    background: linear-gradient(135deg, rgba(108,92,231,0.08), rgba(0,0,0,0.02));
}

.category-icon {
    font-size: 28px;
    line-height: 1;
}

.category-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-light);
    text-align: center;
    line-height: 1.3;
}

/* ============================================================
   PRODUTOS
   ============================================================ */
.products {
    flex: 1;
    padding: 0 0 48px;
}

.products-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.products-header h3 {
    font-size: 20px;
    font-weight: 700;
}

.products-controls {
    display: flex;
    gap: 4px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 4px;
}

.view-btn {
    padding: 8px;
    border-radius: 6px;
    color: var(--text-muted);
    transition: var(--transition);
    display: flex;
    align-items: center;
}

.view-btn.active {
    background: var(--bg-card);
    color: var(--primary);
    box-shadow: var(--shadow);
}

.view-btn:hover:not(.active) {
    color: var(--text-light);
}

/* Grid View */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
}

/* List View */
.products-grid.list-view {
    grid-template-columns: 1fr;
}

.products-grid.list-view .product-card {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 20px;
}

.products-grid.list-view .product-image {
    height: 180px;
}

.products-grid.list-view .product-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Product Card */
.product-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: var(--transition);
    cursor: pointer;
}

.product-card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-4px);
    border-color: transparent;
}

.product-image {
    width: 100%;
    height: 220px;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.product-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 12px;
    transition: transform 0.4s ease;
}

.product-card:hover .product-image img {
    transform: scale(1.05);
}

.product-image .placeholder {
    color: var(--text-muted);
    font-size: 48px;
}

/* Botão Comprar no Card */
.btn-comprar-card {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    font-weight: 700;
    font-size: 13px;
    border-radius: 50px;
    border: none;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
    transform: translateX(-50%) translateY(10px);
    box-shadow: 0 4px 16px rgba(108,92,231,0.4);
    z-index: 2;
    white-space: nowrap;
    font-family: inherit;
    letter-spacing: 0.3px;
}

.product-card:hover .btn-comprar-card {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.btn-comprar-card:hover {
    transform: translateX(-50%) translateY(-2px) !important;
    box-shadow: 0 6px 20px rgba(108,92,231,0.6);
    background: linear-gradient(135deg, var(--primary-dark), #4A3DB8);
}

.btn-comprar-card:active {
    transform: translateX(-50%) translateY(0) !important;
}

/* Versão mobile: sempre visível */
@media (hover: none) and (pointer: coarse) {
    .btn-comprar-card {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
        padding: 8px 16px;
        font-size: 12px;
    }
}

.product-info {
    padding: 16px;
}

.product-loja {
    font-size: 11px;
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    display: block;
}

.product-nome {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
    min-height: 2.8em;
}

.product-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.product-preco {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
}

.product-vendas {
    font-size: 12px;
    color: var(--text-muted);
}

/* ============================================================
   PAGINAÇÃO
   ============================================================ */
.pagination-bar {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.total-count {
    font-size: 13px;
    color: var(--text-light);
    font-weight: 500;
}

.pagination {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
}

.pag-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
}

.pag-btn:hover:not(:disabled):not(.pag-active) {
    border-color: var(--primary-light);
    color: var(--primary);
    background: rgba(108,92,231,0.05);
}

.pag-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pag-btn.pag-active {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(108,92,231,0.3);
}

.pag-ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 40px;
    color: var(--text-muted);
    font-size: 16px;
    letter-spacing: 2px;
}

@media (max-width: 480px) {
    .pag-btn {
        min-width: 36px;
        height: 36px;
        padding: 0 8px;
        font-size: 13px;
    }
    .pag-ellipsis {
        min-width: 24px;
        height: 36px;
    }
    .pagination-bar {
        margin-top: 24px;
        padding-top: 16px;
    }
}

/* Loading */
.loading {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: var(--text-light);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Empty State */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state .empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

/* ============================================================
   MODAL
   ============================================================ */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal.open {
    display: flex;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--bg-card);
    border-radius: var(--radius);
    max-width: 700px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 24px 48px rgba(0,0,0,0.2);
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: var(--text-light);
    background: var(--bg);
    border-radius: 50%;
    z-index: 1;
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--border);
    color: var(--text);
}

.modal-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
}

.modal-image {
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    min-height: 300px;
}

.modal-image img {
    max-width: 100%;
    max-height: 350px;
    object-fit: contain;
}

.modal-info {
    padding: 32px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.modal-loja {
    font-size: 12px;
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.modal-info h2 {
    font-size: 20px;
    font-weight: 700;
    line-height: 1.3;
}

.modal-price {
    font-size: 28px;
    font-weight: 800;
    color: var(--primary);
}

.modal-meta {
    display: flex;
    gap: 16px;
    font-size: 14px;
    color: var(--text-light);
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    font-weight: 600;
    font-size: 15px;
    border-radius: 50px;
    transition: var(--transition);
    margin-top: auto;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(108,92,231,0.4);
}

/* ============================================================
   FOOTER
   ============================================================ */
.footer {
    background: var(--text);
    color: rgba(255,255,255,0.7);
    text-align: center;
    padding: 24px 0;
    font-size: 13px;
    margin-top: auto;
}

.footer-disclaimer {
    font-size: 11px;
    color: rgba(255,255,255,0.4);
    margin-top: 4px;
}

/* ============================================================
   RESPONSIVIDADE
   ============================================================ */

/* Tablet */
@media (max-width: 768px) {
    .hero {
        padding: 36px 0 32px;
    }

    .categories-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 8px;
    }

    .category-card {
        padding: 12px 8px;
    }

    .category-icon {
        font-size: 22px;
    }

    .category-name {
        font-size: 11px;
    }

    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 16px;
    }

    .products-grid.list-view .product-card {
        grid-template-columns: 140px 1fr;
    }

    .products-grid.list-view .product-image {
        height: 140px;
    }

    .modal-body {
        grid-template-columns: 1fr;
    }

    .modal-image {
        min-height: 200px;
        padding: 16px;
    }

    .modal-info {
        padding: 24px;
    }

    .modal-price {
        font-size: 24px;
    }
}

/* Mobile */
@media (max-width: 480px) {
    :root {
        --header-height: 56px;
    }

    .container {
        padding: 0 12px;
    }

    .logo-icon {
        font-size: 22px;
    }

    .logo-text h1 {
        font-size: 15px;
    }

    .hero {
        padding: 28px 0 24px;
    }

    .hero h2 {
        font-size: 22px;
    }

    .hero p {
        font-size: 13px;
    }

    .search-box input {
        padding: 12px 16px;
        font-size: 14px;
    }

    .categories-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
    }

    .category-card {
        padding: 10px 6px;
        border-radius: var(--radius-sm);
    }

    .category-icon {
        font-size: 20px;
    }

    .category-name {
        font-size: 10px;
    }

    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .products-grid.list-view .product-card {
        grid-template-columns: 1fr;
    }

    .products-grid.list-view .product-image {
        height: 180px;
    }

    .product-image {
        height: 160px;
    }

    .product-info {
        padding: 12px;
    }

    .product-nome {
        font-size: 12px;
        min-height: auto;
        -webkit-line-clamp: 2;
    }

    .product-preco {
        font-size: 16px;
    }

    .product-vendas {
        font-size: 11px;
    }

    .products-header h3 {
        font-size: 16px;
    }

    .modal-content {
        max-height: 95vh;
        border-radius: var(--radius-sm);
    }

    .modal-image {
        min-height: 180px;
    }

    .modal-info h2 {
        font-size: 17px;
    }

    .btn-primary {
        padding: 12px 20px;
        font-size: 14px;
    }
}

/* Telas muito pequenas */
@media (max-width: 360px) {
    .categories-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .products-grid {
        grid-template-columns: 1fr;
    }
}

/* Landscape em mobile */
@media (max-height: 480px) and (orientation: landscape) {
    .hero {
        padding: 20px 0;
    }

    .hero h2 {
        font-size: 20px;
    }

    .hero p {
        display: none;
    }

    .search-box {
        max-width: 400px;
    }
}

/* Acessibilidade */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* Dark mode opcional */
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #1A1A2E;
        --bg-card: #16213E;
        --text: #E8E8E8;
        --text-light: #A0A0B0;
        --text-muted: #6C6C80;
        --border: #2A2A4A;
        --shadow: 0 2px 8px rgba(0,0,0,0.3);
        --shadow-hover: 0 8px 24px rgba(0,0,0,0.4);
    }

    .header {
        background: rgba(22,33,62,0.95);
    }

    .search-box {
        background: var(--bg-card);
    }

    .search-box input {
        color: var(--text);
    }

    .product-card {
        border-color: var(--border);
    }

    .modal-content {
        background: var(--bg-card);
    }

    .modal-close {
        background: var(--border);
        color: var(--text-light);
    }
}
