/* Tema MovFy: sombras suaves para botões e cartões (evitar aspecto chapado).
   Apenas sombra — NÃO alterar background/cor de fundo (evitar !important em background). */
.mud-elevation-1,
.mud-paper {
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1) !important;
}

/* Tema claro: forçar Drawer e AppBar brancos (nenhuma cor Secondary no fundo) */
.mud-theme-light .mud-drawer,
.mud-theme-light .mud-appbar {
    background-color: #ffffff !important;
}
.mud-theme-light .mud-drawer .mud-nav-menu,
.mud-theme-light .mud-appbar .mud-toolbar {
    color: #1e293b;
}

/* Estilos base para loading e error UI do Blazor */
/* Mapa corporal (avaliações) */
.body-map-container .body-map-svg {
    cursor: crosshair;
    display: block;
}
.body-map-container .body-map-svg:hover {
    outline: 1px solid var(--mud-palette-primary);
}

.loading-progress {
    position: absolute;
    display: block;
    width: 8rem;
    height: 8rem;
    inset: 20vh 0 auto 0;
    margin: 0 auto;
}

.loading-progress circle {
    fill: none;
    stroke: #e0e0e0;
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: #2196F3;
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

.loading-progress-text:after {
    content: var(--blazor-load-percentage-text, "Carregando...");
}

/* Banner de erro do runtime Blazor (evitar faixa amarelada “lightyellow” em toda a largura). */
#blazor-error-ui {
    background: #1e293b;
    color: #f8fafc;
    bottom: 0;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.25);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui a.reload {
    color: #93c5fd;
    font-weight: 600;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.print-only {
    display: none;
}

/* AppBar rente ao logo (48px — LayoutProperties.AppbarHeight) */
.mud-appbar-movfy {
    min-height: 48px;
    padding-top: 0;
    padding-bottom: 0;
}

.mud-appbar-movfy .mud-appbar-height {
    min-height: 48px;
    height: 48px;
}

/* Conteúdo da AppBar rente: reduz padding vertical do toolbar */
.mud-appbar-movfy .mud-toolbar {
    min-height: 48px;
    padding-top: 4px;
    padding-bottom: 4px;
}

/* Logo na AppBar - proporcional à barra (rente) */
.mud-appbar-movfy .movfy-appbar-logo {
    height: 28px;
    width: auto;
    display: block;
    object-fit: contain;
}

/* Unidade na AppBar: um bloco alinhado à altura dos botões (sem chip + select redundantes) */
.mud-appbar-movfy .movfy-appbar-unit-group {
    display: flex;
    align-items: center;
    margin-left: 0.5rem;
    margin-right: 0.25rem;
    flex-shrink: 0;
}

/* Clínica e Filial como opções separadas (admin em modo visualização) */
.mud-appbar-movfy .movfy-appbar-clinic-unit-separate {
    gap: 0.5rem;
}

.mud-appbar-movfy .movfy-appbar-unit-btn {
    min-height: 34px !important;
    padding: 2px 10px !important;
    border-radius: 8px;
    max-width: min(220px, 36vw);
}

.mud-appbar-movfy .movfy-appbar-unit-btn .mud-button-label {
    max-width: 100%;
    overflow: hidden;
}

.mud-appbar-movfy .movfy-appbar-unit-label {
    display: inline-block;
    max-width: min(160px, 28vw);
    vertical-align: bottom;
}

.mud-appbar-movfy .movfy-appbar-unit-ico {
    opacity: 0.85;
    flex-shrink: 0;
}

.mud-appbar-movfy .movfy-appbar-unit-readonly {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 34px;
    padding: 2px 12px;
    border-radius: 8px;
    border: 1px solid var(--mud-palette-lines-default);
    background-color: var(--mud-palette-background-grey);
    max-width: min(220px, 36vw);
    cursor: default;
    user-select: none;
}

.mud-theme-dark .mud-appbar-movfy .movfy-appbar-unit-readonly {
    background-color: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.14);
}

/* Conteúdo principal: padding-top para AppBar (48px) + pequeno respiro visual (12px) */
.movfy-main-content-with-dense-appbar {
    padding-top: 60px !important;
}

/* Área de conteúdo: altura e flex; cor de fundo apenas no tema claro (tema escuro usa var(--mud-palette-background)) */
.movfy-content-light {
    min-height: calc(100vh - 60px) !important;
    flex: 1 1 auto;
}
.mud-theme-light .mud-main-content.movfy-content-light,
.mud-theme-light .mud-layout .mud-main-content.movfy-content-light {
    background-color: #f8fafc !important;
}
.mud-theme-dark .mud-main-content.movfy-content-light,
.mud-theme-dark .mud-layout .mud-main-content.movfy-content-light {
    background-color: var(--mud-palette-background) !important;
}
/* Layout: fundo por tema; tema escuro herda palette do MudBlazor */
.mud-layout {
    min-height: 100vh;
}
.mud-theme-light .mud-layout {
    background-color: #f8fafc;
}
.mud-theme-dark .mud-layout {
    background-color: var(--mud-palette-background);
}
/* Divisor do menu lateral: visível em ambos os temas */
.mud-theme-light .movfy-drawer .movfy-nav-divider.mud-divider {
    border-color: rgba(30, 41, 59, 0.12);
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}
.mud-theme-dark .movfy-drawer .movfy-nav-divider.mud-divider {
    border-color: rgba(255, 255, 255, 0.12);
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

/* Grupos do menu: cada link com bloco próprio (reforço visual entre itens adjacentes) */
.movfy-drawer .mud-nav-group .mud-nav-link {
    margin-top: 2px;
    margin-bottom: 2px;
    border-radius: 8px;
}

/* Menu lateral: pequeno espaçamento abaixo da barra superior (evita ficar colado) */
.movfy-drawer.mud-drawer {
    top: 56px !important;   /* 48px AppBar + 8px gap */
    height: calc(100vh - 56px) !important;
}

/* Marca d'água: logo centralizado no fundo (apenas o fundo, sem afetar o conteúdo) */
.movfy-main-content-watermark {
    position: relative;
}

.movfy-main-content-watermark::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url('../images/logo.png');
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-size: contain;
    opacity: 0.03;
    pointer-events: none;
    z-index: 0;
}

.mud-theme-dark .movfy-main-content-watermark::before {
    opacity: 0.05;
}

.movfy-main-content-watermark > * {
    position: relative;
    z-index: 1;
}

/* ========== Modo debug pose (painel lateral ângulos) ========== */
.pose-exec-flex-row {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 10px;
    width: 100%;
}

.pose-exec-video-wrap {
    flex: 1 1 auto;
    min-width: 0;
}

.ai-debug-panel {
    display: none;
    width: 272px;
    flex: 0 0 272px;
    box-sizing: border-box;
    background: rgba(0, 0, 0, 0.88);
    color: #00ff88;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 12px;
    padding: 10px;
    border-radius: 8px;
    overflow-y: auto;
    align-self: stretch;
    max-height: min(90vh, 640px);
    border: 1px solid rgba(0, 255, 136, 0.25);
}

@media (max-width: 700px) {
    .pose-exec-flex-row {
        flex-wrap: wrap;
    }
    .ai-debug-panel {
        flex: 1 1 100%;
        max-height: 260px;
        width: 100%;
    }
}

/* ========== ExercisePlayer: tela gamificada e imersiva ========== */

/* Container principal: foco na câmera, conteúdo centralizado */
.exercise-player-immersive {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Palco: área da câmera com bordas arredondadas e sombra */
.video-container.exercise-stage {
    position: relative;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.06);
}

.video-stage-inner {
    position: relative;
    width: 100%;
    background: #000;
}

.exercise-video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.exercise-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* HUD: contador gigante (canto superior direito) */
.hud-counter {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
    border: 3px solid rgba(255, 255, 255, 0.3);
    z-index: 3;
}

.hud-counter-pop {
    animation: hud-counter-pop 0.4s ease-out;
}

@keyframes hud-counter-pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.12); }
    100% { transform: scale(1); }
}

/* HUD: barra de progresso na parte inferior da câmera */
.hud-progress-wrap {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px 16px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
    z-index: 3;
}

.hud-progress-wrap .hud-progress-bar {
    border-radius: 8px;
}

/* HUD: feedback visual IA (centro inferior) */
.hud-feedback {
    position: absolute;
    bottom: 56px;
    left: 50%;
    transform: translateX(-50%);
    min-width: 280px;
    max-width: 90%;
    z-index: 5;
}

.feedback-success-box {
    padding: 8px 20px;
    border-radius: 12px;
    background: rgba(0, 230, 118, 0.9);
    color: #000;
    font-weight: 700;
    text-align: center;
}

/* Overlay "Iniciar IA" e countdown */
.start-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    z-index: 4;
}

.countdown-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10;
}

.countdown-number {
    font-size: 140px;
    font-weight: 900;
    color: white;
    text-shadow: 0 0 60px rgba(255, 255, 255, 0.4);
}

/* Rodapé: botões grandes e arredondados */
.exercise-player-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin-top: 1.5rem;
}

.exercise-btn {
    border-radius: 28px !important;
    padding: 12px 32px !important;
    font-weight: 700 !important;
}

/* Feedback verde (pisque) ao acertar repetição */
.feedback-success-pulse {
    animation: exercise-feedback-success 1.2s ease-out;
}

@keyframes exercise-feedback-success {
    0% { opacity: 0; transform: scale(0.8); }
    20% { opacity: 1; transform: scale(1.05); }
    40% { opacity: 1; transform: scale(1); }
    100% { opacity: 0.95; transform: scale(1); }
}

/* Página do player: fundo neutro para layout imersivo sem menu */
.exercise-player-page {
    min-height: 100vh;
    background: linear-gradient(180deg, #f1f5f9 0%, #e2e8f0 100%);
}

.mud-theme-dark .exercise-player-page {
    background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
}

/* ========== Avaliação: sidebar flutuante fixo à direita (sempre visível) ========== */
.perform-evaluation-layout {
    position: relative;
}

.perform-evaluation-sidebar-col {
    min-height: calc(100vh - 140px);
}

@media (min-width: 1280px) {
    .evaluation-sidebar {
        position: fixed !important;
        right: 1.5rem;
        top: 100px;
        width: 300px;
        z-index: 100;
    }
}

.evaluation-sidebar {
    border-radius: 12px;
    border: 1px solid var(--mud-palette-lines-default);
    min-width: 280px;
    height: calc(100vh - 140px);
    max-height: calc(100vh - 140px);
}

.evaluation-sidebar-flex {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

.evaluation-sidebar-inner {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.evaluation-sidebar-fields {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    margin: 0 -0.5rem;
    padding: 0 0.5rem;
}

.evaluation-sidebar-scroll-buttons .mud-icon-button {
    min-width: 28px;
    width: 28px;
    height: 28px;
}

.evaluation-sidebar-field-item {
    border-bottom: 1px solid var(--mud-palette-lines-default);
}

.evaluation-sidebar-field-item:last-child {
    border-bottom: none;
}

.evaluation-sidebar-footer {
    flex-shrink: 0;
    flex-grow: 0;
    padding-top: 0.5rem;
    padding-bottom: 0.25rem;
    border-top: 1px solid var(--mud-palette-lines-default);
}

@media (max-width: 1279px) {
    .evaluation-sidebar {
        position: relative !important;
        right: auto;
        top: auto;
        width: 100%;
        height: auto;
        max-height: none;
    }

    .perform-evaluation-sidebar-col {
        min-height: 0;
    }
}

/* Menu do usuário (canto superior direito): cabeçalho “Bem-vindo!” + itens (Minha conta, etc.). */
.movfy-user-menu {
    min-width: 260px;
}

.movfy-user-menu-header {
    border-bottom: 1px solid var(--mud-palette-lines-default);
}

.mud-theme-dark .movfy-user-menu-header {
    border-bottom-color: rgba(255, 255, 255, 0.12);
}

@media print {
    .evaluation-sidebar {
        display: none !important;
    }

    body * {
        visibility: hidden;
    }

    .print-only,
    .print-only * {
        visibility: visible !important;
        display: block !important;
    }

    .print-only {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
    }
}
