/**
 * App Native Styles
 * Aplicados apenas quando rodando dentro do Capacitor (iOS/Android)
 * Esconde elementos de site e ajusta safe areas
 */

/* Esconder navbar do site no app */
.app-native .navbar {
    display: none !important;
}

/* Esconder footer do site no app */
.app-native footer {
    display: none !important;
}

/* Esconder link "Voltar" para index nas paginas de auth */
.app-native .back-link {
    display: none !important;
}

/* Botao voltar visivel no app para telas internas de auth */
.app-native .app-back-link {
    display: inline-block !important;
    color: #7C3AED;
    font-size: 14px;
    text-decoration: none;
    margin-bottom: 12px;
}

/* Safe area padding para conteudo */
.app-native body {
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* Auth container ajustado para app */
.app-native .auth-container {
    padding-top: calc(env(safe-area-inset-top, 0px) + 1rem);
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 1rem);
    flex-direction: column;
    gap: 2rem;
}

/* Esconder features laterais na tela de login (so aparece no welcome) */
.app-native .auth-features {
    display: none !important;
}

/* Dashboard sidebar ajuste safe area */
.app-native .sidebar {
    padding-top: calc(env(safe-area-inset-top, 0px) + 1rem);
}

/* Dashboard mobile bottom nav safe area */
.app-native .mobile-bottom-nav {
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* Desabilitar bounce/overscroll no app */
.app-native {
    overscroll-behavior: none;
}

/* Status bar space for pages without navbar */
.app-native .auth-card {
    margin-top: 0;
}

/* Smoother transitions between pages */
.app-native * {
    -webkit-tap-highlight-color: transparent;
}

/* Keyboard open — ajustar layout para nao cobrir inputs */
.app-native.keyboard-open .auth-container {
    padding-bottom: var(--keyboard-height, 0px);
}

.app-native.keyboard-open .sidebar {
    display: none;
}

.app-native.keyboard-open .mobile-menu-toggle {
    display: none;
}

/* Checkout container safe area no app */
.app-native .checkout-container {
    padding-top: calc(env(safe-area-inset-top, 0px) + 1rem);
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 1rem);
}

/* Esconder sidebar de beneficios do checkout no app (ocupa muito espaco) */
.app-native .checkout-benefits {
    margin-top: 2rem;
}

/* ═══════════════════════════════════════════
   TRANSICOES ENTRE PAGINAS
   ═══════════════════════════════════════════ */

.app-native body {
    animation: appFadeIn 0.3s ease-out;
}

@keyframes appFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.app-native body.app-exit {
    animation: appFadeOut 0.2s ease-in forwards;
}

@keyframes appFadeOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-6px);
    }
}

/* ═══════════════════════════════════════════
   MICRO-INTERACOES — BOTOES
   ═══════════════════════════════════════════ */

.app-native .auth-button,
.app-native .plan-btn,
.app-native .sidebar-link,
.app-native #interpretBtn,
.app-native [class*="btn"],
.app-native button:not(.mobile-menu-toggle) {
    transition: transform 0.15s ease, opacity 0.15s ease, box-shadow 0.2s ease;
    will-change: transform;
}

.app-native .auth-button:active,
.app-native .plan-btn:active,
.app-native #interpretBtn:active,
.app-native [class*="btn"]:active,
.app-native button:not(.mobile-menu-toggle):active {
    transform: scale(0.96);
    opacity: 0.85;
}

/* Botoes de sentimento — feedback mais pronunciado */
.app-native .mood-btn:active,
.app-native .feeling-btn:active {
    transform: scale(0.92);
}

.app-native .mood-btn.selected,
.app-native .feeling-btn.selected {
    transform: scale(1.02);
    box-shadow: 0 0 16px rgba(124, 58, 237, 0.5);
}

/* Links do sidebar — slide sutil */
.app-native .sidebar-link:active {
    transform: translateX(4px);
    opacity: 0.8;
}

.app-native .sidebar-link.active {
    border-left: 3px solid #7C3AED;
}

/* ═══════════════════════════════════════════
   MICRO-INTERACOES — CARDS
   ═══════════════════════════════════════════ */

.app-native .auth-card,
.app-native .dream-card,
.app-native .checkout-card,
.app-native .plan-card,
.app-native .results-card,
.app-native [class*="card"] {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.app-native .dream-card:active,
.app-native .plan-card:active {
    transform: scale(0.985);
}

/* ═══════════════════════════════════════════
   MICRO-INTERACOES — INPUTS
   ═══════════════════════════════════════════ */

.app-native input:focus,
.app-native textarea:focus,
.app-native select:focus {
    transform: scale(1.01);
    box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.4);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* ═══════════════════════════════════════════
   ANIMACOES DE ENTRADA — STAGGER
   ═══════════════════════════════════════════ */

.app-native .auth-form .form-group,
.app-native .benefit-item,
.app-native .feature-item-auth {
    animation: appSlideUp 0.4s ease-out both;
}

.app-native .auth-form .form-group:nth-child(1) { animation-delay: 0.05s; }
.app-native .auth-form .form-group:nth-child(2) { animation-delay: 0.1s; }
.app-native .auth-form .form-group:nth-child(3) { animation-delay: 0.15s; }
.app-native .auth-form .form-group:nth-child(4) { animation-delay: 0.2s; }
.app-native .auth-form .form-group:nth-child(5) { animation-delay: 0.25s; }

@keyframes appSlideUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Resultados da interpretacao — entrada dramatica */
.app-native .results-card,
.app-native #resultsCard {
    animation: appResultReveal 0.5s ease-out;
}

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

/* ═══════════════════════════════════════════
   LOADING — SKELETON SYSTEM
   ═══════════════════════════════════════════ */

.app-native .loading-pulse,
.app-native .skeleton {
    background: linear-gradient(
        90deg,
        rgba(124, 58, 237, 0.08) 25%,
        rgba(124, 58, 237, 0.2) 50%,
        rgba(124, 58, 237, 0.08) 75%
    );
    background-size: 200% 100%;
    animation: appPulse 1.5s ease-in-out infinite;
    border-radius: 8px;
    color: transparent !important;
    pointer-events: none;
    user-select: none;
}

.app-native .skeleton * { visibility: hidden; }

.app-native .skeleton-text {
    height: 14px;
    margin-bottom: 8px;
    border-radius: 4px;
}

.app-native .skeleton-text.short { width: 40%; }
.app-native .skeleton-text.medium { width: 65%; }
.app-native .skeleton-text.long { width: 90%; }

.app-native .skeleton-title {
    height: 22px;
    width: 50%;
    margin-bottom: 12px;
    border-radius: 6px;
}

.app-native .skeleton-circle {
    border-radius: 50%;
}

.app-native .skeleton-card {
    border: 1px solid rgba(124, 58, 237, 0.1);
    border-radius: 14px;
    padding: 20px;
    min-height: 120px;
}

.app-native .skeleton-diary-card {
    border: 1px solid rgba(124, 58, 237, 0.1);
    border-radius: 14px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.app-native .skeleton-kpi {
    border: 1px solid rgba(124, 58, 237, 0.1);
    border-radius: 14px;
    padding: 20px;
    text-align: center;
    min-height: 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.app-native .skeleton-fade-out {
    animation: skeletonFadeOut 0.3s ease forwards;
}

@keyframes appPulse {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

@keyframes skeletonFadeOut {
    from { opacity: 1; }
    to { opacity: 0; height: 0; padding: 0; margin: 0; overflow: hidden; }
}

/* Skeletons only visible in app mode */
.diary-skeleton,
.kpi-skeleton { display: none; }

.app-native .diary-skeleton,
.app-native .kpi-skeleton {
    display: contents;
}

.app-native .kpi-skeleton {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    grid-column: 1 / -1;
}

/* ═══════════════════════════════════════════
   EMPTY STATES — APP
   ═══════════════════════════════════════════ */

.app-native .empty-state.app-empty-state,
.app-native .empty-pattern {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px 20px;
    gap: 16px;
}

.app-native .empty-illustration {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(124, 58, 237, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
    position: relative;
}

.app-native .empty-illustration::after {
    font-size: 32px;
    line-height: 1;
}

.app-native .empty-diary::after { content: '\1F319'; }
.app-native .empty-search::after { content: '\1F50D'; }
.app-native .empty-symbols::after { content: '\2728'; }
.app-native .empty-emotions::after { content: '\1F30A'; }
.app-native .empty-archetypes::after { content: '\1F3AD'; }

.app-native .empty-state h3,
.app-native .empty-pattern h3 {
    font-size: 18px;
    font-weight: 600;
    color: #e2dce9;
    margin: 0;
}

.app-native .empty-state p,
.app-native .empty-pattern p {
    font-size: 14px;
    color: rgba(226, 220, 233, 0.6);
    margin: 0;
    max-width: 280px;
    line-height: 1.5;
}

.app-native .empty-cta {
    margin-top: 8px;
    padding: 12px 24px;
    background: linear-gradient(135deg, #7C3AED, #6D28D9);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease, opacity 0.15s ease;
}

.app-native .empty-cta:active {
    transform: scale(0.96);
    opacity: 0.85;
}

/* ═══════════════════════════════════════════
   PULL-TO-REFRESH
   ═══════════════════════════════════════════ */

.pull-to-refresh {
    display: none;
}

.app-native .pull-to-refresh {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 0;
    overflow: hidden;
    transition: height 0.2s ease;
    color: rgba(226, 220, 233, 0.5);
    font-size: 13px;
}

.app-native .pull-to-refresh.ptr-pulling {
    transition: none;
}

.app-native .pull-to-refresh.ptr-refreshing {
    height: 48px;
}

.app-native .ptr-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(124, 58, 237, 0.2);
    border-top-color: #7C3AED;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.app-native .pull-to-refresh.ptr-pulling .ptr-spinner {
    opacity: 1;
}

.app-native .pull-to-refresh.ptr-ready .ptr-spinner,
.app-native .pull-to-refresh.ptr-refreshing .ptr-spinner {
    opacity: 1;
    animation: ptrSpin 0.6s linear infinite;
}

.app-native .pull-to-refresh.ptr-ready .ptr-text {
    color: #7C3AED;
}

.app-native .pull-to-refresh.ptr-refreshing .ptr-text {
    color: rgba(226, 220, 233, 0.6);
}

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

/* ═══════════════════════════════════════════
   TOGGLE DE MODO (Escrever/Falar)
   ═══════════════════════════════════════════ */

.app-native .mode-btn {
    transition: all 0.25s ease;
}

.app-native .mode-btn.active {
    box-shadow: 0 2px 12px rgba(124, 58, 237, 0.4);
}

/* ═══════════════════════════════════════════
   TAB BAR NATIVA — APP ONLY
   ═══════════════════════════════════════════ */

.app-tab-bar {
    display: none;
}

.app-native .app-tab-bar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(8, 5, 16, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(124, 58, 237, 0.12);
    padding: 6px 0 calc(env(safe-area-inset-bottom, 0px) + 4px);
    justify-content: space-around;
}

.app-tab-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 6px 12px;
    background: none;
    border: none;
    color: rgba(196, 181, 217, 0.4);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.62rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: color 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    position: relative;
}

.app-tab-item svg {
    width: 21px;
    height: 21px;
    transition: transform 0.15s ease;
}

.app-tab-item.active {
    color: #A855F7;
}

.app-tab-item.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 2px;
    background: #A855F7;
    border-radius: 0 0 2px 2px;
}

.app-tab-item:active svg {
    transform: scale(0.9);
}

.app-native .mobile-menu-toggle {
    display: none !important;
}

.app-native .mobile-menu-overlay {
    display: none !important;
}

.app-native .sidebar {
    display: none !important;
}

.app-native .dashboard-main {
    margin-left: 0 !important;
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 70px) !important;
}

.app-native .dashboard-header {
    padding-top: calc(env(safe-area-inset-top, 0px) + 12px);
}

/* ═══════════════════════════════════════════
   REDUCAO DE MOTION
   ═══════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
    .app-native body,
    .app-native .auth-form .form-group,
    .app-native .results-card,
    .app-native #resultsCard,
    .app-native .benefit-item,
    .app-native .feature-item-auth {
        animation: none !important;
    }

    .app-native .auth-button:active,
    .app-native [class*="btn"]:active,
    .app-native button:active,
    .app-native input:focus,
    .app-native textarea:focus {
        transform: none !important;
    }

    .app-native .loading-pulse,
    .app-native .skeleton {
        animation: none !important;
        background: rgba(124, 58, 237, 0.1) !important;
    }

    .app-native .ptr-spinner {
        animation: none !important;
    }
}
