/**
 * Estilos do Módulo de Perfis e Permissões
 * Layout hierárquico com radio buttons
 */

/* ==========================================================================
   Modal de Perfil
   ========================================================================== */

#modal-perfil-completo .modal {
    max-width: 800px;
    max-height: 90vh;
}

#modal-perfil-completo .modal-body {
    max-height: calc(90vh - 140px);
    overflow-y: auto;
    padding: 1.5rem;
}

/* ==========================================================================
   Info Row (Nome + Descrição + Ativo)
   ========================================================================== */

.profile-info-row {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--gray-200, #e5e5e5);
}

.profile-info-row .form-group {
    margin-bottom: 0;
}

.profile-info-row .form-group label {
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
}

/* ==========================================================================
   Aviso de Perfil de Sistema
   ========================================================================== */

.perm-system-notice {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--warning-bg, #fefce8);
    border: 1px solid var(--warning-border, #fde68a);
    border-radius: 6px;
    font-size: 0.85rem;
    color: var(--warning-text, #92400e);
    margin-bottom: 0.5rem;
}

.perm-system-notice svg {
    flex-shrink: 0;
    color: var(--warning, #f59e0b);
}

/* ==========================================================================
   Seção de Permissões
   ========================================================================== */

.permissions-section {
    margin-top: 1rem;
}

.permissions-section h4 {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--gray-500, #737373);
    margin: 0 0 1rem 0;
    padding: 0 0.75rem 0.75rem;
    border-bottom: 1px solid var(--gray-200, #e5e5e5);
}

#permissions-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

/* ==========================================================================
   Section Title (Comercial, Clientes, etc)
   ========================================================================== */

.perm-section-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-500, #737373);
    margin: 1rem 0 0.25rem 0;
    padding: 0 0.75rem 0.25rem;
    border-bottom: 1px solid var(--gray-200, #e5e5e5);
}

.perm-section-title:first-child {
    margin-top: 0;
}

/* ==========================================================================
   Módulo (Container pai)
   ========================================================================== */

.perm-module {
    transition: opacity 0.2s;
}

.perm-module.disabled {
    opacity: 0.6;
}

/* ==========================================================================
   Linha do Módulo e dos Filhos — layout unificado
   ========================================================================== */

.perm-module-header,
.perm-child {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    transition: background 0.15s;
}

.perm-module-header {
    padding: 0.625rem 0.75rem;
    background: var(--gray-50, #fafafa);
}

.perm-module.disabled .perm-module-header {
    background: var(--gray-100, #f5f5f5);
}

.perm-child:hover {
    background: var(--gray-50, #fafafa);
}

.perm-module-info,
.perm-child-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    flex: 1;
}

.perm-child-info {
    padding-left: 2rem;
}

.perm-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--primary-color, #8b5cf6);
}

.perm-icon svg {
    width: 20px;
    height: 20px;
}

.perm-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--gray-800, #262626);
}

/* ==========================================================================
   Filhos (Submenus)
   ========================================================================== */

.perm-children {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.perm-children.disabled {
    pointer-events: none;
    opacity: 0.5;
}

.perm-icon-sm {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    color: var(--gray-500, #737373);
}

.perm-icon-sm svg {
    width: 16px;
    height: 16px;
}

.perm-name-sm {
    font-size: 0.85rem;
    color: var(--gray-700, #404040);
}

/* ==========================================================================
   Radio Group (Nenhum | Leitura | Total)
   ========================================================================== */

.perm-levels {
    flex-shrink: 0;
    width: 210px;
}

.radio-group {
    display: flex;
    gap: 0;
    border: 1px solid var(--gray-300, #d4d4d4);
    border-radius: 6px;
    overflow: hidden;
    background: white;
    width: 100%;
}

.radio-group.disabled {
    opacity: 0.4;
    pointer-events: none;
}

.radio-label {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 0.375rem 0;
    cursor: pointer;
    transition: all 0.15s;
    border-right: 1px solid var(--gray-300, #d4d4d4);
    user-select: none;
}

.radio-label:last-child {
    border-right: none;
}

.radio-label input[type="radio"] {
    display: none;
}

.radio-text {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--gray-600, #525252);
}

/* Estado hover */
.radio-label:hover:not(.disabled):not(.active) {
    background: var(--gray-100, #f5f5f5);
}

/* Nenhum = cinza */
.radio-label.active:first-child {
    background: var(--gray-400, #a3a3a3);
}

/* Leitura = azul */
.radio-label.active:nth-child(2) {
    background: var(--info, #0ea5e9);
}

/* Total = verde */
.radio-label.active:last-child {
    background: var(--success, #22c55e);
}

.radio-label.active .radio-text {
    color: white;
}

.radio-label.disabled {
    cursor: not-allowed;
    opacity: 0.4;
}

/* ==========================================================================
   Botões de Ação em Massa
   ========================================================================== */

.perm-mass-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
    padding: 1rem 0.75rem 0.5rem;
    border-top: 1px solid var(--gray-200, #e5e5e5);
}

.perm-mass-actions .btn {
    font-size: 0.8rem;
}

/* ==========================================================================
   Responsividade
   ========================================================================== */

@media (max-width: 768px) {
    #modal-perfil-completo .modal {
        max-width: 100%;
        margin: 0.5rem;
    }
    
    .profile-info-row {
        flex-direction: column;
        align-items: stretch;
    }
    
    .profile-info-row .form-group {
        flex: 1 !important;
    }
    
    .perm-module-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    
    .perm-child {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }
    
    .perm-child-info {
        padding-left: 0;
    }
    
    .perm-levels {
        width: 100%;
    }
    
    .radio-group {
        width: 100%;
    }
    
    .radio-label {
        flex: 1;
    }
    
    .perm-mass-actions {
        flex-direction: column;
    }
    
    .perm-mass-actions .btn {
        width: 100%;
    }
}
