/* Estilos Principais - Provador Virtual de Roupas */
:root {
    --bg-dark: #0b0c0f;
    --bg-panel: rgba(14, 15, 20, 0.88);
    --border-color: rgba(229, 185, 103, 0.45);
    --border-glow: rgba(229, 185, 103, 0.75);
    --primary: #d4a737;
    --primary-glow: rgba(212, 175, 55, 0.45);
    --gold-btn-gradient: linear-gradient(135deg, #f2cd77 0%, #d4a737 48%, #af7e1b 100%);
    --gold-btn-hover: linear-gradient(135deg, #fae29a 0%, #e2b747 48%, #c58f25 100%);
    --accent: #10b981;
    --text-main: #fcfcfc;
    --text-muted: #dcd7ce;
    --gold-light: #f9e29b;
    --danger: #ef4444;
    --radius-lg: 20px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --safe-bottom: env(safe-area-inset-bottom, 16px);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

body, html {
    width: 100%;
    height: 100%;
    height: 100dvh;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

/* App Container - fixado estritamente na área útil do viewport mobile (Android e iOS) */
#app-viewport {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    height: calc(var(--vh, 1vh) * 100);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: var(--bg-dark);
}

/* Telas */
.screen {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    z-index: 10;
}

/* Tela Inicial / Boas-vindas */
#screen-welcome {
    background: radial-gradient(circle at 50% 25%, #181922 0%, #0b0c0f 85%);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1.5rem;
    z-index: 30;
    text-align: center;
}

.welcome-box {
    max-width: 440px;
    width: 100%;
    background: var(--bg-panel);
    border: 1.5px solid var(--border-color);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-radius: var(--radius-lg);
    padding: 3rem 1.85rem;
    min-height: 540px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-shadow: 0 20px 48px rgba(0, 0, 0, 0.75),
                0 0 35px rgba(212, 175, 55, 0.15),
                inset 0 1px 1px rgba(255, 255, 255, 0.15);
    box-sizing: border-box;
}

.welcome-logo-box {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 1.35rem;
}

.welcome-logo-link {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.25s ease;
}

.welcome-logo-img {
    width: 105px;
    height: 105px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-color);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.7), 0 0 20px rgba(212, 175, 55, 0.25);
    background-color: #000;
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.welcome-logo-link:hover .welcome-logo-img,
.welcome-logo-img:hover {
    transform: scale(1.06);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.8), 0 0 25px rgba(229, 185, 103, 0.45);
    border-color: var(--gold-light, #f59e0b);
}

.welcome-title {
    font-family: 'Cinzel', Georgia, serif;
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.65rem;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, #fff7de 0%, #edd187 40%, #c99c37 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    width: 100%;
}

.welcome-desc {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 1.65rem;
    line-height: 1.45;
    width: 100%;
}

.privacy-badge {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: rgba(229, 185, 103, 0.12);
    border: 1px solid rgba(229, 185, 103, 0.35);
    padding: 0.75rem 0.5rem;
    border-radius: 14px;
    margin-bottom: 1.75rem;
    box-sizing: border-box;
}

.privacy-col {
    flex: 1 1 50%;
    width: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--gold-light);
    line-height: 1.25;
}

.privacy-divider {
    width: 1px;
    height: 20px;
    background: rgba(229, 185, 103, 0.35);
    flex-shrink: 0;
}

/* Botões Redondos de Contato e Redes Sociais no Provador */
.welcome-social-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.15rem;
    margin-top: 1.25rem;
    width: 100%;
}

.btn-round-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(18, 20, 26, 0.75);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1.5px solid var(--border-color);
    color: var(--gold-light);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5), 0 0 12px rgba(212, 175, 55, 0.15);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    flex-shrink: 0;
}

.btn-round-icon svg {
    width: 22px;
    height: 22px;
    stroke: var(--gold-light);
    stroke-width: 2;
    transition: transform 0.25s ease, stroke 0.25s ease;
}

.btn-round-icon:hover {
    border-color: var(--gold-light);
    transform: translateY(-2px) scale(1.08);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.65), 0 0 20px rgba(212, 175, 55, 0.35);
    background: rgba(24, 26, 34, 0.95);
    color: #fff;
}

.btn-round-icon:hover svg {
    stroke: #fff;
    transform: scale(1.05);
}

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

@media (max-height: 660px) {
    .welcome-box {
        min-height: auto;
        padding: 1.6rem 1.25rem;
    }
    .welcome-logo-box {
        margin-bottom: 0.85rem;
    }
    .welcome-logo-img {
        width: 80px;
        height: 80px;
    }
    .welcome-title {
        font-size: 1.45rem;
        margin-bottom: 0.4rem;
    }
    .welcome-desc {
        margin-bottom: 1rem;
        font-size: 0.88rem;
    }
    .privacy-badge {
        margin-bottom: 1.1rem;
        padding: 0.5rem;
    }
    .welcome-social-row {
        margin-top: 0.85rem;
    }
}

/* Provador Screen */
#screen-fitting {
    display: none;
    z-index: 20;
}

/* Canvas Viewport */
.canvas-container {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #000;
}

#fitting-canvas {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Header Flutuante */
.fitting-topbar {
    position: absolute;
    top: 1rem;
    left: 1rem;
    right: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 25;
}

.top-pill {
    background: var(--bg-panel);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    padding: 0.4rem 0.8rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.top-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-panel);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    transition: transform 0.15s;
}

.btn-icon:active {
    transform: scale(0.92);
}

/* Indicador de Status / Orientação */
.guidance-box {
    position: absolute;
    top: 4.5rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border-color);
    color: #e2e8f0;
    font-size: 0.8rem;
    padding: 0.4rem 1rem;
    border-radius: 999px;
    pointer-events: none;
    z-index: 24;
    white-space: nowrap;
    transition: opacity 0.3s;
}

/* Painel de Ajustes Manuais Flutuante */
.adjust-panel {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-panel);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    z-index: 25;
}

.btn-adjust {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border-color);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    cursor: pointer;
}
.btn-adjust:active { background: rgba(212, 175, 55, 0.5); }

/* Barra de Ações Inferior (Tirar Foto + Catálogo) */
.fitting-bottombar {
    position: absolute;
    bottom: calc(50px + env(safe-area-inset-bottom, 8px));
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    z-index: 25;
    padding: 0 1rem;
    pointer-events: none;
}

.action-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    width: 100%;
    pointer-events: none;
}

.btn-capture {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: #fff;
    border: 4px solid rgba(229, 185, 103, 0.55);
    box-shadow: 0 0 20px var(--primary-glow);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s;
    pointer-events: auto;
}

.btn-capture::after {
    content: '';
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--gold-btn-gradient);
}

.btn-capture:active {
    transform: scale(0.92);
}

/* Gaveta do Catálogo de Roupas (Bottom Sheet) */
.catalog-drawer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-panel);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-top: 1.5px solid var(--border-color);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.65), 0 0 20px rgba(212, 175, 55, 0.12);
    z-index: 26;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    transform: translateY(calc(100% - 44px - env(safe-area-inset-bottom, 0px)));
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    max-height: 55vh;
    max-height: 55dvh;
}

.catalog-drawer.expanded {
    transform: translateY(0);
}

.drawer-handle {
    height: 44px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    touch-action: none;
    padding: 6px 0;
}

.handle-bar {
    width: 48px;
    height: 5px;
    background-color: rgba(229, 185, 103, 0.7);
    border-radius: 999px;
    box-shadow: 0 0 8px rgba(229, 185, 103, 0.35);
}

.catalog-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1rem 0.5rem;
}

.catalog-title {
    font-family: 'Cinzel', Georgia, serif;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--gold-light);
}

.category-tabs {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding: 0 1rem 0.5rem;
    scrollbar-width: none;
}
.category-tabs::-webkit-scrollbar { display: none; }

.cat-tab {
    padding: 0.4rem 0.9rem;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    font-size: 0.82rem;
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
}
.cat-tab.active {
    background: var(--gold-btn-gradient);
    color: #121008;
    font-weight: 700;
    border-color: rgba(229, 185, 103, 0.7);
    box-shadow: 0 2px 10px rgba(175, 126, 27, 0.35);
}

/* Grid de Produtos */
.product-slider {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 100px;
    gap: 0.75rem;
    overflow-x: auto;
    padding: 0.5rem 1rem 1.5rem;
    scrollbar-width: none;
}
.product-slider::-webkit-scrollbar { display: none; }

.garment-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.garment-card.selected {
    border-color: var(--primary);
    background: rgba(212, 175, 55, 0.2);
    box-shadow: 0 0 12px var(--primary-glow);
}

.garment-card img {
    width: 80px;
    height: 80px;
    object-fit: contain;
    margin-bottom: 0.35rem;
}

.garment-card span {
    font-size: 0.75rem;
    font-weight: 500;
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Modal de Prévia da Foto Capturada */
.modal-preview {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.88);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    z-index: 50;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.preview-container {
    max-width: 90vw;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.preview-container img {
    max-width: 100%;
    max-height: 65vh;
    border-radius: var(--radius-md);
    box-shadow: 0 15px 35px rgba(0,0,0,0.85);
    border: 1.5px solid var(--border-color);
}

.preview-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.25rem;
    width: 100%;
    max-width: 320px;
}

/* Botões Genéricos */
.btn-primary {
    background: var(--gold-btn-gradient);
    color: #121008;
    padding: 0.85rem 1.6rem;
    border-radius: 999px;
    border: none;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(175, 126, 27, 0.45);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.25s ease;
}
.btn-primary:hover {
    background: var(--gold-btn-hover);
    box-shadow: 0 12px 30px rgba(212, 175, 55, 0.6);
    transform: translateY(-1px);
}
.btn-primary:active { transform: scale(0.97); }

.btn-secondary {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
