/* shell.css - Estilos Premium para a Casca do Painel Pós-Login */

/* Animações Flúidas para Entrada do App */
@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Bloqueia scroll no body - submenus usam position:fixed e não precisam de scroll de página */
html, body {
    overflow: hidden;
    height: 100%;
    margin: 0;
    padding: 0;
}

.app-wrapper, .loading-overlay {
    --primary: #1AB394;
    --primary-hover: #18a689;
    --focus-ring: rgba(26, 179, 148, 0.25);
}

.app-wrapper {
    display: flex;
    height: 100vh;
    width: 100%;
    overflow: hidden;
    background-color: #F3F3F4;
    font-family: 'Inter', sans-serif;
    animation: fadeSlideIn 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* ==================
   SIDEBAR (MENU LATERAL)
   ================== */
.sidebar {
    width: 260px;
    background-color: #ffffff;
    /* Fundo Claro */
    color: #111827;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 15px rgba(0, 0, 0, 0.05);
    transition: width 0.3s ease;
    z-index: 100;
    border-right: 1px solid #e5e7eb;
    position: relative;
    /* Para segurar o resizer */
    overflow: hidden;
    /* Barra de rolagem na casca nunca deve aparecer - submenus usam position:fixed */
}

/* Removemos a transição enquanto estiver sendo arrastado para ser fluido */
.sidebar.is-resizing {
    transition: none !important;
}

/* Estado Recolhido (Collapsed) */
.sidebar.collapsed {
    width: 70px !important;
    /* !important garante sobreposição ao estilo inline de drag */
}

.sidebar.collapsed .sidebar-logo {
    display: none;
    /* Esconde logo longa, idealmente ter uma logo icone aqui */
}

.sidebar.collapsed .nav-item span,
.sidebar.collapsed .submenu-arrow {
    display: none;
}

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 0.85rem 0;
}

.sidebar.collapsed .nav-item i {
    margin-right: 0;
}

.sidebar.collapsed .submenu {
    display: none !important;
}

/* Puxador para redimensionar usando o mouse */
.sidebar-resizer {
    position: absolute;
    top: 0;
    right: -2px;
    /* metade do tamanho fora da borda para pegar facil */
    width: 5px;
    height: 100%;
    cursor: col-resize;
    z-index: 101;
    background-color: transparent;
    transition: background-color 0.2s;
}

.sidebar-resizer:hover,
.sidebar.is-resizing .sidebar-resizer {
    background-color: rgba(26, 179, 148, 0.5);
    /* Cor primária do tema #1AB394 */
}

.sidebar-header {
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    /* centraliza */
    border-bottom: 1px solid #e5e7eb;
    padding: 0 1.5rem;
    position: relative;
}

.sidebar-logo {
    height: 35px;
    object-fit: contain;
}

.sidebar-nav {
    flex: 1;
    overflow: visible;
    /* Necessário para não cortar o submenu dropando para fora */
    padding: 1rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem; /* Espaço entre os itens de menu */
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 0.65rem 0.85rem;
    color: #4b5563;
    text-decoration: none;
    border-radius: 0.5rem;
    font-size: 0.88rem;
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: pointer;
    white-space: nowrap;
}

.nav-item i {
    width: 20px;
    font-size: 1rem;
    margin-right: 0.65rem;
    text-align: center;
}

.nav-item:hover {
    background-color: #f3f4f6;
    /* Fundo cinza claro */
    color: #111827;
}

.nav-item.active {
    background-color: rgba(26, 179, 148, 0.1);
    color: var(--primary);
    /* Removido o box-shadow escuro */
}

/* Flyout do Menu (Abre para fora) */
.nav-group {
    display: flex;
    flex-direction: column;
    position: relative;
    /* Base para o submenu voador */
}

.submenu {
    position: fixed; /* Desamarra completamente do painel nativo */
    min-width: 220px;
    width: max-content;
    background-color: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    box-shadow: 4px 4px 15px rgba(0, 0, 0, 0.1);
    padding: 0.5rem;
    z-index: 200;
    
    /* Regras rígidas de Bloqueio de Altura para forçar a barra do próprio menu */
    max-height: calc(100vh - 50px);
    overflow-y: auto; 
    overflow-x: hidden;

    /* Animação inicial fechado */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

/* Scrollbar Bonita p/ Submenus Gigantes */
.submenu::-webkit-scrollbar {
    width: 6px;
}
.submenu::-webkit-scrollbar-track {
    background: transparent; 
}
.submenu::-webkit-scrollbar-thumb {
    background: #d1d5db; 
    border-radius: 10px;
}
.submenu::-webkit-scrollbar-thumb:hover {
    background: #9ca3af; 
}

.nav-group.open>.submenu {
    opacity: 1;
    visibility: visible;
}

/* Destaque visual ao pai quando o filho está revelado */
.nav-group.open>.nav-item {
    background-color: #f3f4f6;
    color: var(--primary);
}

.submenu-arrow {
    margin-left: auto;
    font-size: 0.8rem;
    transition: transform 0.3s ease;
    transform: rotate(-90deg);
    /* Apontando para o lado indicando flyout */
}

.nav-group.open>.nav-item .submenu-arrow {
    transform: rotate(0deg);
    /* Destaca como selecionado */
}

.nav-item.has-submenu {
    position: relative;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid #e5e7eb;
}

.btn-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 0.75rem;
    background-color: transparent;
    color: #ef4444;
    /* Vermelho suave */
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-logout:hover {
    background-color: rgba(239, 68, 68, 0.05);
}

/* Botão Hamburger */
.toggle-sidebar-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.25rem;
    color: #4b5563;
    padding: 0.5rem;
    border-radius: 0.25rem;
    transition: all 0.2s;
}

.toggle-sidebar-btn:hover {
    background-color: #f3f4f6;
    color: #111827;
}

/* ==================
   CONTENT AREA & TOPBAR
   ================== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: #F3F3F4;
}

.topbar {
    height: 70px;
    background-color: #ffffff;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
    z-index: 50;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.search-box {
    position: relative;
    width: 300px;
}

.search-box i {
    position: absolute;
    right: 1rem;
    left: auto;
    top: 50%;
    transform: translateY(-50%) scale(1);
    color: var(--primary); /* Ícone na cor primária (verde claro) */
    font-size: 0.9rem;
    cursor: pointer;
    transition: color 0.12s ease, transform 0.12s ease;
}

.search-box i:hover,
.search-box i:focus {
    color: var(--primary-hover);
    transform: translateY(-50%) scale(1.06);
    outline: none;
}

/* Quando o input estiver focado, adicionamos a classe .focused ao ícone via JS */
.search-box i.focused {
    color: var(--primary-hover);
    transform: translateY(-50%) scale(1.12);
}

.search-box input {
    width: 100%;
    padding: 0.65rem 2.5rem 0.65rem 1rem; /* espaço à direita para o ícone */
    background-color: #f3f4f6; /* Fundo mais escuro */
    border: 1px solid #e5e7eb; /* Borda sutil para definição */
    border-radius: 2rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.search-box input::placeholder {
    color: #6b7280;
    opacity: 0.8;
}

.search-box input:focus {
    outline: none;
    border-color: #1AB394;
    background-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(26, 179, 148, 0.1);
}

/* Seletores da Topbar (Empresa e Perfil) - Estilo Pílula */
.header-selector {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.4rem 1.25rem;
    background-color: #f3f4f6;
    border-radius: 2rem;
    border: 1px solid #e5e7eb;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.header-selector:hover {
    border-color: #cdd5df;
    background-color: #f9fafb;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.company-indicator {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.company-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    font-weight: 700;
    color: #6b7280;
    letter-spacing: 0.05em;
}

.company-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: #111827;
}

/* User Profile */
.topbar-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
}

.user-avatar {
    width: 36px;
    height: 36px;
    background-color: #e0e7ff;
    color: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.95rem;
}

.user-info {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.user-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: #111827;
}

.user-role {
    font-size: 0.8rem;
    color: #6b7280;
}

/* Workflow Container (IFrame Base) */
.app-container {
    flex: 1;
    padding: 0; /* Removido para as páginas internas encostarem no topo */
    overflow-y: auto;
    position: relative;
    background-color: #F3F3F4;
}

.iframe-wrapper {
    width: 100%;
    height: 100%;
    background-color: transparent;
    border: none;
    overflow: hidden;
}

.iframe-wrapper iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Glassmorphism/Esqueleto de carregamento inicial do Painel */
.skeleton-loader {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 2rem;
}

.sk-header {
    width: 40%;
    height: 2rem;
    background-color: #e5e7eb;
    border-radius: 0.5rem;
}

.sk-block {
    width: 100%;
    height: 10rem;
    background-color: #e5e7eb;
    border-radius: 0.5rem;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: .5;
    }
}

50% {
    opacity: .5;
}
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: .5;
    }
}

50% {
    opacity: .5;
}
}